Merge lp:~mhall119/pantheon-mail/gresources-sql into lp:~elementary-apps/pantheon-mail/trunk

Proposed by Michael Hall
Status: Merged
Approved by: Corentin Noël
Approved revision: 2107
Merged at revision: 2107
Proposed branch: lp:~mhall119/pantheon-mail/gresources-sql
Merge into: lp:~elementary-apps/pantheon-mail/trunk
Diff against target: 304 lines (+61/-24)
17 files modified
data/CMakeLists.txt (+0/-3)
data/sql/mail-sql.gresource.xml (+29/-0)
data/ui/pantheon-mail.gresource.xml (+1/-1)
src/CMakeLists.txt (+2/-1)
src/client/accounts/account-dialog-account-list-pane.vala (+1/-1)
src/client/accounts/account-dialog-edit-alternate-emails-pane.vala (+1/-1)
src/client/accounts/account-dialog-remove-fail-pane.vala (+1/-1)
src/client/accounts/add-edit-page.vala (+1/-1)
src/client/application/geary-application.vala (+1/-1)
src/client/application/geary-controller.vala (+2/-2)
src/client/components/conversation-find-bar.vala (+1/-1)
src/client/components/main-toolbar.vala (+2/-2)
src/client/composer/composer-widget.vala (+2/-2)
src/client/dialogs/certificate-warning-dialog.vala (+1/-1)
src/client/dialogs/upgrade-dialog.vala (+1/-1)
src/engine/db/db-connection.vala (+9/-3)
src/engine/db/db-versioned-database.vala (+6/-2)
To merge this branch: bzr merge lp:~mhall119/pantheon-mail/gresources-sql
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+299467@code.launchpad.net

Commit message

Switch versioned database migration sql files to using GResource like the UI files are

Description of the change

Switch versioned database migration sql files to using GResource like the UI files are

Creates a new gresources.xml file which contains all current sql migration files. Switches the file lookup to resource:// URIs which GIO uses to look into GResource files. Finally read the file contents through an InputStream because FileUtils can't operate on GResource URIs.

Also changed the GResource prefix for UI files by appending /ui to it, to avoid potential naming conflicts between them and the SQL files. Renamed the class variable to reflect it's UI-specific nature.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/CMakeLists.txt'
2--- data/CMakeLists.txt 2016-07-02 21:27:21 +0000
3+++ data/CMakeLists.txt 2016-07-07 19:39:55 +0000
4@@ -40,6 +40,3 @@
5 CODE "message (STATUS \"Not updating desktop database\")"
6 )
7 endif ()
8-
9-add_subdirectory(sql)
10-
11
12=== added file 'data/sql/mail-sql.gresource.xml'
13--- data/sql/mail-sql.gresource.xml 1970-01-01 00:00:00 +0000
14+++ data/sql/mail-sql.gresource.xml 2016-07-07 19:39:55 +0000
15@@ -0,0 +1,29 @@
16+<?xml version="1.0" encoding="UTF-8"?>
17+<gresources>
18+ <gresource prefix="/io/elementary/pantheon-mail/sql">
19+ <file alias="version-001.sql" compressed="true">version-001.sql</file>
20+ <file alias="version-002.sql" compressed="true">version-002.sql</file>
21+ <file alias="version-003.sql" compressed="true">version-003.sql</file>
22+ <file alias="version-004.sql" compressed="true">version-004.sql</file>
23+ <file alias="version-005.sql" compressed="true">version-005.sql</file>
24+ <file alias="version-006.sql" compressed="true">version-006.sql</file>
25+ <file alias="version-007.sql" compressed="true">version-007.sql</file>
26+ <file alias="version-008.sql" compressed="true">version-008.sql</file>
27+ <file alias="version-009.sql" compressed="true">version-009.sql</file>
28+ <file alias="version-010.sql" compressed="true">version-010.sql</file>
29+ <file alias="version-011.sql" compressed="true">version-011.sql</file>
30+ <file alias="version-012.sql" compressed="true">version-012.sql</file>
31+ <file alias="version-013.sql" compressed="true">version-013.sql</file>
32+ <file alias="version-014.sql" compressed="true">version-014.sql</file>
33+ <file alias="version-015.sql" compressed="true">version-015.sql</file>
34+ <file alias="version-016.sql" compressed="true">version-016.sql</file>
35+ <file alias="version-017.sql" compressed="true">version-017.sql</file>
36+ <file alias="version-018.sql" compressed="true">version-018.sql</file>
37+ <file alias="version-019.sql" compressed="true">version-019.sql</file>
38+ <file alias="version-020.sql" compressed="true">version-020.sql</file>
39+ <file alias="version-021.sql" compressed="true">version-021.sql</file>
40+ <file alias="version-022.sql" compressed="true">version-022.sql</file>
41+ <file alias="version-023.sql" compressed="true">version-023.sql</file>
42+ <file alias="version-024.sql" compressed="true">version-024.sql</file>
43+ </gresource>
44+</gresources>
45
46=== modified file 'data/ui/pantheon-mail.gresource.xml'
47--- data/ui/pantheon-mail.gresource.xml 2016-07-01 23:15:50 +0000
48+++ data/ui/pantheon-mail.gresource.xml 2016-07-07 19:39:55 +0000
49@@ -1,6 +1,6 @@
50 <?xml version="1.0" encoding="UTF-8"?>
51 <gresources>
52- <gresource prefix="/io/elementary/pantheon-mail">
53+ <gresource prefix="/io/elementary/pantheon-mail/ui">
54 <file alias="accelerators.ui" compressed="true" preprocess="xml-stripblanks">accelerators.ui</file>
55 <file alias="account_list.ui" compressed="true" preprocess="xml-stripblanks">account_list.ui</file>
56 <file alias="account_cannot_remove.ui" compressed="true" preprocess="xml-stripblanks">account_cannot_remove.ui</file>
57
58=== modified file 'src/CMakeLists.txt'
59--- src/CMakeLists.txt 2016-07-01 23:15:50 +0000
60+++ src/CMakeLists.txt 2016-07-07 19:39:55 +0000
61@@ -564,6 +564,7 @@
62 # GResource
63 include (GResource)
64 glib_compile_resources (GLIB_RESOURCES_UI SOURCE ../data/ui/pantheon-mail.gresource.xml)
65+glib_compile_resources (GLIB_RESOURCES_SQL SOURCE ../data/sql/mail-sql.gresource.xml)
66
67 if (NOT DEBUG)
68 set(CFLAGS
69@@ -650,7 +651,7 @@
70 --vapidir=${CMAKE_BINARY_DIR}/src
71 )
72
73-add_executable(${CMAKE_PROJECT_NAME} ${GEARY_VALA_C} ${GLIB_RESOURCES_UI})
74+add_executable(${CMAKE_PROJECT_NAME} ${GEARY_VALA_C} ${GLIB_RESOURCES_UI} ${GLIB_RESOURCES_SQL})
75 target_link_libraries(${CMAKE_PROJECT_NAME} m ${DEPS_LIBRARIES} gthread-2.0 ${CMAKE_PROJECT_NAME}-static)
76 install(TARGETS ${CMAKE_PROJECT_NAME} RUNTIME DESTINATION bin)
77 add_custom_command(
78
79=== modified file 'src/client/accounts/account-dialog-account-list-pane.vala'
80--- src/client/accounts/account-dialog-account-list-pane.vala 2016-07-01 23:15:50 +0000
81+++ src/client/accounts/account-dialog-account-list-pane.vala 2016-07-07 19:39:55 +0000
82@@ -24,7 +24,7 @@
83
84 public AccountDialogAccountListPane(Gtk.Stack stack) {
85 base(stack);
86- var builder = new Gtk.Builder.from_resource("%s/account_list.ui".printf(GearyApplication.GRESOURCE_PREFIX));
87+ var builder = new Gtk.Builder.from_resource("%s/account_list.ui".printf(GearyApplication.GRESOURCE_UI_PREFIX));
88 pack_end((Gtk.Box) builder.get_object("container"));
89 Gtk.ActionGroup actions = (Gtk.ActionGroup) builder.get_object("account list actions");
90 edit_action = actions.get_action("edit_account");
91
92=== modified file 'src/client/accounts/account-dialog-edit-alternate-emails-pane.vala'
93--- src/client/accounts/account-dialog-edit-alternate-emails-pane.vala 2016-07-01 23:15:50 +0000
94+++ src/client/accounts/account-dialog-edit-alternate-emails-pane.vala 2016-07-07 19:39:55 +0000
95@@ -40,7 +40,7 @@
96 public AccountDialogEditAlternateEmailsPane(Gtk.Stack stack) {
97 base (stack);
98
99- var builder = new Gtk.Builder.from_resource("%s/edit_alternate_emails.ui".printf(GearyApplication.GRESOURCE_PREFIX));
100+ var builder = new Gtk.Builder.from_resource("%s/edit_alternate_emails.ui".printf(GearyApplication.GRESOURCE_UI_PREFIX));
101
102 // Primary container
103 pack_start((Gtk.Widget) builder.get_object("container"));
104
105=== modified file 'src/client/accounts/account-dialog-remove-fail-pane.vala'
106--- src/client/accounts/account-dialog-remove-fail-pane.vala 2016-07-01 23:15:50 +0000
107+++ src/client/accounts/account-dialog-remove-fail-pane.vala 2016-07-07 19:39:55 +0000
108@@ -11,7 +11,7 @@
109 public AccountDialogRemoveFailPane(Gtk.Stack stack) {
110 base(stack);
111
112- var builder = new Gtk.Builder.from_resource("%s/account_cannot_remove.ui".printf(GearyApplication.GRESOURCE_PREFIX));
113+ var builder = new Gtk.Builder.from_resource("%s/account_cannot_remove.ui".printf(GearyApplication.GRESOURCE_UI_PREFIX));
114 pack_end((Gtk.Box) builder.get_object("container"));
115 Gtk.ActionGroup actions = (Gtk.ActionGroup) builder.get_object("actions");
116 actions.get_action("ok_action").activate.connect(() => { ok(); });
117
118=== modified file 'src/client/accounts/add-edit-page.vala'
119--- src/client/accounts/add-edit-page.vala 2016-07-01 23:15:50 +0000
120+++ src/client/accounts/add-edit-page.vala 2016-07-07 19:39:55 +0000
121@@ -222,7 +222,7 @@
122 public AddEditPage() {
123 Object(orientation: Gtk.Orientation.VERTICAL, spacing: 4);
124
125- var builder = new Gtk.Builder.from_resource("%s/login.ui".printf(GearyApplication.GRESOURCE_PREFIX));
126+ var builder = new Gtk.Builder.from_resource("%s/login.ui".printf(GearyApplication.GRESOURCE_UI_PREFIX));
127
128 // Primary container.
129 container_widget = (Gtk.Widget) builder.get_object("container");
130
131=== modified file 'src/client/application/geary-application.vala'
132--- src/client/application/geary-application.vala 2016-07-01 23:15:50 +0000
133+++ src/client/application/geary-application.vala 2016-07-07 19:39:55 +0000
134@@ -29,7 +29,7 @@
135 public const string INSTALL_PREFIX = _INSTALL_PREFIX;
136 public const string GSETTINGS_DIR = _GSETTINGS_DIR;
137 public const string SOURCE_ROOT_DIR = _SOURCE_ROOT_DIR;
138- public const string GRESOURCE_PREFIX = "/io/elementary/pantheon-mail";
139+ public const string GRESOURCE_UI_PREFIX = "/io/elementary/pantheon-mail/ui";
140
141 public const string[] AUTHORS = {
142 "Jim Nelson <jim@yorba.org>",
143
144=== modified file 'src/client/application/geary-controller.vala'
145--- src/client/application/geary-controller.vala 2016-07-01 23:15:50 +0000
146+++ src/client/application/geary-controller.vala 2016-07-07 19:39:55 +0000
147@@ -173,7 +173,7 @@
148 // Setup actions.
149 setup_actions();
150 try {
151- GearyApplication.instance.ui_manager.add_ui_from_resource("%s/accelerators.ui".printf(GearyApplication.GRESOURCE_PREFIX));
152+ GearyApplication.instance.ui_manager.add_ui_from_resource("%s/accelerators.ui".printf(GearyApplication.GRESOURCE_UI_PREFIX));
153 } catch (Error e) {
154 critical (e.message);
155 }
156@@ -557,7 +557,7 @@
157 }
158 GearyApplication.instance.ui_manager.insert_action_group(action_group, 0);
159
160- var builder = new Gtk.Builder.from_resource("%s/app_menu.interface".printf(GearyApplication.GRESOURCE_PREFIX));
161+ var builder = new Gtk.Builder.from_resource("%s/app_menu.interface".printf(GearyApplication.GRESOURCE_UI_PREFIX));
162 app_menu = (MenuModel) builder.get_object("app-menu");
163
164 // We'd *like* to always export an app menu and just let the shell
165
166=== modified file 'src/client/components/conversation-find-bar.vala'
167--- src/client/components/conversation-find-bar.vala 2016-07-01 23:15:50 +0000
168+++ src/client/components/conversation-find-bar.vala 2016-07-07 19:39:55 +0000
169@@ -36,7 +36,7 @@
170 public ConversationFindBar(ConversationWebView web_view) {
171 this.web_view = web_view;
172
173- builder = new Gtk.Builder.from_resource("%s/find_bar.ui".printf(GearyApplication.GRESOURCE_PREFIX));
174+ builder = new Gtk.Builder.from_resource("%s/find_bar.ui".printf(GearyApplication.GRESOURCE_UI_PREFIX));
175
176 key_press_event.connect(on_key_press);
177 button_press_event.connect(on_button_press);
178
179=== modified file 'src/client/components/main-toolbar.vala'
180--- src/client/components/main-toolbar.vala 2016-07-01 23:15:50 +0000
181+++ src/client/components/main-toolbar.vala 2016-07-07 19:39:55 +0000
182@@ -51,7 +51,7 @@
183
184 // Assemble mark menu.
185 try {
186- GearyApplication.instance.ui_manager.add_ui_from_resource("%s/toolbar_mark_menu.ui".printf(GearyApplication.GRESOURCE_PREFIX));
187+ GearyApplication.instance.ui_manager.add_ui_from_resource("%s/toolbar_mark_menu.ui".printf(GearyApplication.GRESOURCE_UI_PREFIX));
188 } catch (Error e) {
189 critical (e.message);
190 }
191@@ -66,7 +66,7 @@
192
193 // Set accel labels for EmptyTrash and EmptySpam context menus
194 try {
195- GearyApplication.instance.ui_manager.add_ui_from_resource("%s/context_empty_menu.ui".printf(GearyApplication.GRESOURCE_PREFIX));
196+ GearyApplication.instance.ui_manager.add_ui_from_resource("%s/context_empty_menu.ui".printf(GearyApplication.GRESOURCE_UI_PREFIX));
197 } catch (Error e) {
198 critical (e.message);
199 }
200
201=== modified file 'src/client/composer/composer-widget.vala'
202--- src/client/composer/composer-widget.vala 2016-07-01 23:15:50 +0000
203+++ src/client/composer/composer-widget.vala 2016-07-07 19:39:55 +0000
204@@ -290,7 +290,7 @@
205 setup_drag_destination(this);
206
207 add_events(Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.KEY_RELEASE_MASK);
208- builder = new Gtk.Builder.from_resource("%s/composer.ui".printf(GearyApplication.GRESOURCE_PREFIX));
209+ builder = new Gtk.Builder.from_resource("%s/composer.ui".printf(GearyApplication.GRESOURCE_UI_PREFIX));
210
211 Gtk.Box box = builder.get_object("composer") as Gtk.Box;
212 attachments_box = builder.get_object("attachments_box") as Gtk.Box;
213@@ -429,7 +429,7 @@
214 ui = new Gtk.UIManager();
215 ui.insert_action_group(actions, 0);
216 try {
217- ui.add_ui_from_resource("%s/composer_accelerators.ui".printf(GearyApplication.GRESOURCE_PREFIX));
218+ ui.add_ui_from_resource("%s/composer_accelerators.ui".printf(GearyApplication.GRESOURCE_UI_PREFIX));
219 add_extra_accelerators();
220 } catch (Error e) {
221 critical (e.message);
222
223=== modified file 'src/client/dialogs/certificate-warning-dialog.vala'
224--- src/client/dialogs/certificate-warning-dialog.vala 2016-07-01 23:15:50 +0000
225+++ src/client/dialogs/certificate-warning-dialog.vala 2016-07-07 19:39:55 +0000
226@@ -17,7 +17,7 @@
227
228 public CertificateWarningDialog(Gtk.Window? parent, Geary.AccountInformation account_information,
229 Geary.Service service, TlsCertificateFlags warnings, bool is_validation) {
230- var builder = new Gtk.Builder.from_resource("%s/certificate_warning_dialog.ui".printf(GearyApplication.GRESOURCE_PREFIX));
231+ var builder = new Gtk.Builder.from_resource("%s/certificate_warning_dialog.ui".printf(GearyApplication.GRESOURCE_UI_PREFIX));
232
233 dialog = (Gtk.Dialog) builder.get_object("CertificateWarningDialog");
234 dialog.transient_for = parent;
235
236=== modified file 'src/client/dialogs/upgrade-dialog.vala'
237--- src/client/dialogs/upgrade-dialog.vala 2016-07-01 23:15:50 +0000
238+++ src/client/dialogs/upgrade-dialog.vala 2016-07-07 19:39:55 +0000
239@@ -22,7 +22,7 @@
240 */
241 public UpgradeDialog() {
242 // Load UI.
243- var builder = new Gtk.Builder.from_resource("%s/upgrade_dialog.ui".printf(GearyApplication.GRESOURCE_PREFIX));
244+ var builder = new Gtk.Builder.from_resource("%s/upgrade_dialog.ui".printf(GearyApplication.GRESOURCE_UI_PREFIX));
245 dialog = (Gtk.Dialog) builder.get_object("dialog");
246
247 // Hook up signals.
248
249=== modified file 'src/engine/db/db-connection.vala'
250--- src/engine/db/db-connection.vala 2015-03-12 01:11:48 +0000
251+++ src/engine/db/db-connection.vala 2016-07-07 19:39:55 +0000
252@@ -120,10 +120,16 @@
253 public void exec_file(File file, Cancellable? cancellable = null) throws Error {
254 check_cancelled("Connection.exec_file", cancellable);
255
256- string sql;
257- FileUtils.get_contents(file.get_path(), out sql);
258+ var sql_builder = new StringBuilder();
259+ DataInputStream ins = new DataInputStream(file.read());
260+ string line = ins.read_line();
261+ while (line != null) {
262+ sql_builder.append(line);
263+ sql_builder.append("\n");
264+ line = ins.read_line();
265+ }
266
267- exec(sql, cancellable);
268+ exec(sql_builder.str, cancellable);
269 }
270
271 /**
272
273=== modified file 'src/engine/db/db-versioned-database.vala'
274--- src/engine/db/db-versioned-database.vala 2015-02-06 20:43:33 +0000
275+++ src/engine/db/db-versioned-database.vala 2016-07-07 19:39:55 +0000
276@@ -5,6 +5,8 @@
277 */
278
279 public class Geary.Db.VersionedDatabase : Geary.Db.Database {
280+ public const string GRESOURCE_SQL_PREFIX = "/io/elementary/pantheon-mail/sql";
281+
282 public delegate void WorkCallback();
283
284 private static Mutex upgrade_mutex = new Mutex();
285@@ -56,7 +58,9 @@
286 }
287
288 private File get_schema_file(int db_version) {
289- return schema_dir.get_child("version-%03d.sql".printf(db_version));
290+ string schema_file_uri = "resource://"+GRESOURCE_SQL_PREFIX+"/"+"version-%03d.sql".printf(db_version);
291+ debug("Looking for schema file: %s", schema_file_uri);
292+ return File.new_for_uri(schema_file_uri);
293 }
294
295 /**
296@@ -123,7 +127,7 @@
297 check_cancelled("VersionedDatabase.open", cancellable);
298
299 try {
300- debug("Upgrading database to version %d with %s", db_version, upgrade_script.get_path());
301+ debug("Upgrading database to version %d with %s", db_version, upgrade_script.get_uri());
302 cx.exec_transaction(TransactionType.EXCLUSIVE, (cx) => {
303 cx.exec_file(upgrade_script, cancellable);
304 cx.set_user_version_number(db_version);

Subscribers

People subscribed via source and target branches