~ubuntu-branches/ubuntu/vivid/liferea/vivid-proposed

« back to all changes in this revision

Viewing changes to src/fl_sources/google_source_edit.c

  • Committer: Package Import Robot
  • Author(s): bojo42
  • Date: 2012-03-29 14:17:21 UTC
  • mfrom: (1.3.9) (3.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20120329141721-tbfopcrc5797wxt7
Tags: 1.8.3-0.1ubuntu1
* New upstream release (LP: #290666, #371754, #741543, #716688)
* Merge from Debian unstable (LP: #935147), remaining changes:
* debian/patches:
  - drop gtk-status-icon.patch & notification-append as in upstream
  - drop fix_systray_behavior as mostly upstreamed and rest seems unused
  - 01_ubuntu_feedlists: update & rename, move planets to "Open Source"  
  - add_X-Ubuntu-Gettext-Domain: rebase
  - libunity.patch: rebase, apply before indicator patch (liferea_shell.c)
  - libindicate_increase_version.patch: exclude from libindicate.patch
  - deactivate libindicate.patch, seems partly upstreamed and needs rework
* debian/control: libindicate-dev, libindicate-gtk-dev & libunity-dev
* debian/liferea.indicate & liferea.install: ship indicator desktop file
* debian/rules: enable libindicate

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
        g_slice_free(struct GoogleSourceActionCtxt, ctxt);
128
128
}
129
129
 
130
 
static gchar* google_source_edit_get_cachefile (GoogleSourcePtr gsource) 
131
 
{
132
 
        return common_create_cache_filename ("cache" G_DIR_SEPARATOR_S "plugins", gsource->root->id, "savedactions.xml");
133
 
}
134
 
 
135
 
static void
136
 
google_source_edit_export_helper (GoogleSourceActionPtr action, xmlTextWriterPtr writer) 
137
 
{
138
 
        xmlTextWriterStartElement (writer, BAD_CAST "action");
139
 
 
140
 
        gchar* actionType = g_strdup_printf ("%d", action->actionType);
141
 
        xmlTextWriterWriteElement (writer, BAD_CAST "action", actionType);
142
 
        g_free (actionType);
143
 
        if (action->feedUrl) 
144
 
                xmlTextWriterWriteElement (writer, BAD_CAST "feedUrl", action->feedUrl);
145
 
        if (action->guid) 
146
 
                xmlTextWriterWriteElement (writer, BAD_CAST "guid", action->guid);
147
 
        xmlTextWriterEndElement (writer);
148
 
}
149
 
 
150
 
void
151
 
google_source_edit_export (GoogleSourcePtr gsource) 
152
 
153
 
        xmlTextWriterPtr writer;
154
 
        gchar            *file = google_source_edit_get_cachefile (gsource);
155
 
        writer = xmlNewTextWriterFilename (file, 0);
156
 
        g_free (file);
157
 
        file = NULL;
158
 
        if (writer == NULL) {
159
 
                g_warning ("Could not create edit cache file\n");
160
 
                g_assert (FALSE);
161
 
                return;
162
 
        }
163
 
        xmlTextWriterStartDocument (writer, NULL, "UTF-8", NULL);
164
 
 
165
 
        xmlTextWriterStartElement (writer, BAD_CAST "actions");
166
 
        xmlTextWriterWriteAttribute (writer, BAD_CAST "version", BAD_CAST PACKAGE_VERSION);
167
 
 
168
 
        while (!g_queue_is_empty(gsource->actionQueue)) {
169
 
                GoogleSourceActionPtr action = g_queue_pop_head (gsource->actionQueue);
170
 
                google_source_edit_export_helper (action, writer);
171
 
        }
172
 
        
173
 
        xmlTextWriterEndElement (writer);
174
 
        xmlTextWriterEndDocument (writer);
175
 
        xmlFreeTextWriter (writer);
176
 
}
177
 
 
178
 
static void
179
 
google_source_edit_import_helper (xmlNodePtr match, gpointer userdata) 
180
 
{
181
 
        GoogleSourcePtr gsource = (GoogleSourcePtr) userdata ;
182
 
        GoogleSourceActionPtr action;
183
 
        xmlNodePtr cur; 
184
 
 
185
 
        action = google_source_action_new () ;
186
 
        
187
 
        cur = match->children ; 
188
 
        while (cur) {
189
 
                xmlChar *content = xmlNodeGetContent (cur);
190
 
                if (g_str_equal ((gchar*) cur->name, "action")) {
191
 
                        action->actionType = atoi (content) ;
192
 
                } else if (g_str_equal ((gchar*) cur->name, "guid")){ 
193
 
                        action->guid = g_strdup ((gchar*) content);
194
 
                } else if (g_str_equal ((gchar*) cur->name, "feedUrl")) {
195
 
                        action->feedUrl = g_strdup ((gchar*) content);
196
 
                }
197
 
                if (content) xmlFree (content);
198
 
                cur = cur->next;
199
 
        }
200
 
 
201
 
        debug3 (DEBUG_CACHE, "Found edit request: %d %s %s \n", action->actionType, action->feedUrl, action->guid);
202
 
        google_source_edit_push (gsource, action, FALSE);
203
 
}
204
 
 
205
 
void
206
 
google_source_edit_import (GoogleSourcePtr gsource) 
207
 
{
208
 
        gchar* file = google_source_edit_get_cachefile (gsource);
209
 
 
210
 
        if (!g_file_test(file, G_FILE_TEST_IS_REGULAR)) {
211
 
                debug0 (DEBUG_UPDATE, "GoogleSource: saved actions file not found.");
212
 
                g_free (file);
213
 
                return;
214
 
        }
215
 
 
216
 
        xmlDocPtr doc = xmlReadFile (file, NULL, 0);
217
 
        if (doc == NULL) {
218
 
                g_free(file);
219
 
                return; 
220
 
        }
221
 
 
222
 
        xmlNodePtr root = xmlDocGetRootElement (doc);
223
 
        
224
 
        xpath_foreach_match (root, "/actions/action", google_source_edit_import_helper, gsource);
225
 
 
226
 
        g_unlink (file); 
227
 
        xmlFreeDoc (doc);
228
 
        g_free (file);  
229
 
}
230
 
 
231
130
static void
232
131
google_source_edit_action_complete (const struct updateResult* const result, gpointer userdata, updateFlags flags) 
233
132