~ubuntu-branches/debian/sid/tickr/sid

« back to all changes in this revision

Viewing changes to src/tickr/tickr_check4updates.c

  • Committer: Package Import Robot
  • Author(s): Emmanuel Thomas-Maurin
  • Date: 2012-06-04 14:23:24 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120604142324-j6ycu0cw6vvoahhy
Tags: 0.6.1-1
* Add: 'quick setup' thing (in tickr_quicksetup.c) which is launched
  at program startup if config file doesn't exist.

* Little improvements in layout of 'feed picker win' and 'preferences
  win'.

* Fix a segfault that happens when trying to export params and no
  config file exists yet.

* Make several windows that should not be resized by user, unresizable.

* Fix Launchpad bug #1007346: When 'window always-on-top' is disabled,
  'visible on all user desktops' stops working.

* If mouse wheel scrolling applies to speed (or feed), then Ctrl +
  mouse wheel scrolling applies to feed (or speed.)

* No real code changes in libetm, only in comments, so no need for a
  new version number.

* Update tickr_helptext.c and tickr.1 (man page.)

* Add new cli option 'no-ui' (similar to 'instance-id') used by new
  IF_UI_ALLOWED macro and remove all #if USE_GUI occurences.

* In tickr_list.c, free listfname before using it. Fixed by swapping 2
  lines:
    warning(FALSE, 4, "Can't save URL list ", listfname, ...);
    l_str_free(listfname);

* Use/add #define
    FONT_MAXLEN         68
    ARBITRARY_TASKBAR_HEIGHT    25
  to replace a few 'magic' numeric values.

* Rename: rss_title/description(_delimiter) ->
    item_title/description(_delimiter)
  then add new param: feed_title(_delimiter). Now we have:
  feed title / item title / item description.

* Use table in resource properties window.

* Fix a bug in f_list_load_from_file() in tickr_list.c which
  uncorrectly retrieves any feed title string containing TITLE_TAG_CHAR
  when TITLE_TAG_CHAR has not been removed from string first, for
  instance: 'NYT > World' -> ' World'.

* New param: disable left-click.

* Add 'check for updates' feature.

* Launch 'import OPML file' if feed list doesn't exist.

* Remove code changing get_params()->disable_popups value in
    START/END_PAUSE_TICKER_WHILE_OPENING
  macros which prevents this setting to be saved and add
    START/END_PAUSE_TICKER_ENABLE_POPUPS_WHILE_OPENING
  new macros. Which ones to use depends on context.

* Move:
    #ifdef G_OS_WIN32
    extern FILE *stdout_fp, *stderr_fp;
    #endif
  from *.c into tickr.h.

* Default always-on-top setting changed to 'n' (so that tickr is not
  intrusive by default.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      TICKR - GTK-based Feed Reader - Copyright (C) Emmanuel Thomas-Maurin 2009-2012
 
3
 *      <manutm007@gmail.com>
 
4
 *
 
5
 *      This program is free software: you can redistribute it and/or modify
 
6
 *      it under the terms of the GNU General Public License as published by
 
7
 *      the Free Software Foundation, either version 3 of the License, or
 
8
 *      (at your option) any later version.
 
9
 *
 
10
 *      This program is distributed in the hope that it will be useful,
 
11
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *      GNU General Public License for more details.
 
14
 *
 
15
 *      You should have received a copy of the GNU General Public License
 
16
 *      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
#include "tickr.h"
 
20
 
 
21
static void new_version_available_win(char *version_num)
 
22
{
 
23
        GtkWidget       *dialog, *table, *label[2], *close_but;
 
24
        char            str1[256], str2[256];
 
25
 
 
26
        gtk_window_set_keep_above(GTK_WINDOW(get_ticker_env()->win), FALSE);
 
27
 
 
28
        dialog = gtk_dialog_new_with_buttons(
 
29
                        "New upstream version found", GTK_WINDOW(get_ticker_env()->win),
 
30
                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
 
31
                        NULL);
 
32
 
 
33
        close_but = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
 
34
        close_but = close_but;  /* To get rid of one annoying compiler warning */
 
35
 
 
36
        set_tickr_icon_to_dialog(GTK_WINDOW(dialog));
 
37
        gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
 
38
        gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
 
39
 
 
40
        g_signal_connect(G_OBJECT(dialog), "key-press-event", G_CALLBACK(esc_key_pressed), NULL);
 
41
        g_signal_connect(G_OBJECT(dialog), "delete_event", G_CALLBACK(force_quit_dialog), NULL);
 
42
 
 
43
        table = gtk_table_new(2, 1, FALSE);
 
44
        gtk_table_set_row_spacings(GTK_TABLE(table), 5);
 
45
        gtk_container_set_border_width(GTK_CONTAINER(table), 15);
 
46
        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
 
47
 
 
48
        /* Also send to stdout */
 
49
        fprintf(STD_OUT, "%s version %s is available for download from: <%s>\n", APP_NAME,
 
50
                version_num, DOWNLOAD_URL);
 
51
        snprintf(str1, 256, "%s version <b>%s</b> is available for download from:", APP_NAME,
 
52
                version_num);
 
53
        snprintf(str2, 256, "<a href=\"%s\">%s</a>", DOWNLOAD_URL, DOWNLOAD_URL);
 
54
        label[0] = gtk_label_new(str1);
 
55
        gtk_label_set_use_markup(GTK_LABEL(label[0]), TRUE);
 
56
        gtk_misc_set_alignment(GTK_MISC(label[0]), 0, 0.5);
 
57
        gtk_table_attach_defaults(GTK_TABLE(table), label[0], 0, 1, 0, 1);
 
58
        label[1] = gtk_label_new(str2);
 
59
        gtk_label_set_use_markup(GTK_LABEL(label[1]), TRUE);
 
60
        gtk_misc_set_alignment(GTK_MISC(label[1]), 0, 0.5);
 
61
        gtk_table_attach_defaults(GTK_TABLE(table), label[1], 0, 1, 1, 2);
 
62
 
 
63
        gtk_widget_show_all(dialog);
 
64
        while (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_CLOSE);
 
65
 
 
66
        gtk_widget_destroy(dialog);
 
67
        check_main_win_always_on_top();
 
68
}
 
69
 
 
70
void check_for_updates()
 
71
{
 
72
        sockt   sock;
 
73
        char    *response, *new_url;
 
74
        int     /*status,*/ recv_status;
 
75
        char    lsvn[32], tmp[32], *p = tmp;
 
76
        int     info = OK + 1;
 
77
 
 
78
        fprintf(STD_OUT, "Checking for updates:\n");
 
79
        if (connect_with_url(&sock, CHECK4UPDATES_URL) == OK) {
 
80
                /* TODO: check this (when http 'connection closed by server' is returned):
 
81
                if ((status = get_http_response(sock, "GET", "", CHECK4UPDATES_URL, &new_url,\
 
82
                                &response, &recv_status)) == SEND_ERROR || status == RECV_ERROR) {
 
83
                        if (recv_status == CONNECTION_CLOSED_BY_SERVER || recv_status == SOCK_SHOULD_BE_CLOSED) {
 
84
                                CLOSE_SOCK(sock);
 
85
                                if (connect_with_url(&sock, CHECK4UPDATES_URL) == OK)
 
86
                                        status = get_http_response(sock, "GET", "", CHECK4UPDATES_URL, &new_url,\
 
87
                                                &response,&recv_status);
 
88
                        }
 
89
                } if (status == OK) {*/
 
90
                if (get_http_response(sock, "GET", "", CHECK4UPDATES_URL, &new_url, &response, &recv_status) == OK) {
 
91
                        remove_chunk_info(&response);
 
92
                        if (strncmp(response, CHECK4UPDATES_ID_STR, strlen(CHECK4UPDATES_ID_STR)) == 0) {
 
93
                                str_n_cpy(lsvn, response + strlen(CHECK4UPDATES_ID_STR), 31);
 
94
                                str_n_cpy(p, APP_VERSION_NUMBER, 31);
 
95
                                while (*p != '\0') {
 
96
                                        p++;
 
97
                                        if (*p == '~') {
 
98
                                                *p =  '\0';
 
99
                                                p--;
 
100
                                                *p -= 1;
 
101
                                                break;
 
102
                                        }
 
103
                                }
 
104
                                if (strcmp(lsvn, tmp) > 0)
 
105
                                        new_version_available_win(lsvn);
 
106
                                else {
 
107
                                        /* also send to stdout */
 
108
                                        fprintf(STD_OUT, APP_NAME" is up to date\n");
 
109
                                        info_win("Check for Updates",
 
110
                                                "\n            "APP_NAME" is up to date  :)            \n",
 
111
                                                INFO, FALSE);
 
112
                                }
 
113
                                info = OK;
 
114
                        }
 
115
                        free2(response);
 
116
                }
 
117
                CLOSE_SOCK(sock);
 
118
        }
 
119
        if (info != OK)
 
120
                warning(FALSE, 1, "Couldn't retrieve requested information from website");
 
121
}