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

« back to all changes in this revision

Viewing changes to src/item.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:
1
1
/**
2
2
 * @file item.c common item handling
3
3
 *
4
 
 * Copyright (C) 2003-2009 Lars Lindner <lars.lindner@gmail.com>
 
4
 * Copyright (C) 2003-2010 Lars Lindner <lars.lindner@gmail.com>
5
5
 * Copyright (C) 2004-2006 Nathan J. Conrad <t98502@users.sourceforge.net>
6
6
 *            
7
7
 * This program is free software; you can redistribute it and/or modify
22
22
#include "item.h"
23
23
 
24
24
#include <glib.h>
25
 
#include <time.h>
26
 
#include <stdlib.h>
27
25
#include <string.h>
28
26
 
29
27
#include "comments.h"
30
28
#include "common.h"
 
29
#include "date.h"
31
30
#include "db.h"
 
31
#include "debug.h"
32
32
#include "metadata.h"
33
33
#include "xml.h"
34
 
#include "ui/itemview.h"        // FIXME: evil
35
34
 
36
35
itemPtr
37
36
item_new (void)
123
122
const gchar *   item_get_description(itemPtr item) { return item->description; }
124
123
const gchar *   item_get_source(itemPtr item) { return item->source; }
125
124
 
 
125
gchar *
 
126
item_make_link (itemPtr item)
 
127
{
 
128
        const gchar     *src;
 
129
        gchar           *link;
 
130
 
 
131
        src = item_get_source (item);
 
132
        if (!src)
 
133
                return NULL;
 
134
 
 
135
        /* check for relative link */
 
136
        if (*src == '/') {
 
137
                const gchar * base = item_get_base_url (item);
 
138
                gchar * pos = (gchar *)base;
 
139
                int host_url_size, i;
 
140
 
 
141
                /* Find the third /, start of link on
 
142
                 * site. */
 
143
                for (i = 0; pos && i < 3; i++) {
 
144
                        pos = strstr(pos + 1, "/");
 
145
                }
 
146
 
 
147
                if (!pos) {
 
148
                        debug0 (DEBUG_PARSING, "Feed contains relative link and invalid base URL");
 
149
                        return NULL;
 
150
                }
 
151
 
 
152
                host_url_size = pos - base + 1;
 
153
 
 
154
                link = g_malloc (host_url_size + strlen(src));
 
155
                strncpy (link, base, host_url_size - 1);
 
156
                pos = link + host_url_size - 1;
 
157
                strcpy (pos, src);
 
158
        } else {
 
159
                link = g_strdup (src);
 
160
        }
 
161
        
 
162
        return link;
 
163
}
 
164
 
126
165
void
127
166
item_unload (itemPtr item) 
128
167
{
129
 
 
130
168
        g_free (item->title);
131
169
        g_free (item->source);
132
170
        g_free (item->sourceId);
155
193
        xmlNodePtr      duplicatesNode;         
156
194
        xmlNodePtr      itemNode;
157
195
        gchar           *tmp;
 
196
        gchar           *tmp2;
158
197
        
159
198
        itemNode = xmlNewChild (parentNode, NULL, "item", NULL);
160
199
        g_return_if_fail (itemNode);
163
202
 
164
203
        if (item_get_description (item)) {
165
204
                tmp = xhtml_strip_dhtml (item_get_description (item));
166
 
                xmlNewTextChild (itemNode, NULL, "description", tmp);
 
205
                tmp2 = xhtml_strip_unsupported_tags (tmp);
 
206
                xmlNewTextChild (itemNode, NULL, "description", tmp2);
167
207
                g_free (tmp);
 
208
                g_free (tmp2);
168
209
        }
169
210
        
170
211
        if (item_get_source (item))
190
231
        xmlNewTextChild (itemNode, NULL, "time", tmp);
191
232
        g_free (tmp);
192
233
 
193
 
        tmp = itemview_format_date (item->time);
 
234
        tmp = date_format (item->time, NULL);
194
235
        xmlNewTextChild (itemNode, NULL, "timestr", tmp);
195
236
        g_free (tmp);
196
237