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

« back to all changes in this revision

Viewing changes to src/tickr/tickr.h

  • 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:
21
21
 
22
22
#define APP_NAME                "Tickr"
23
23
#define APP_CMD                 "tickr"
24
 
#define APP_VERSION_NUMBER      "0.6.0"
25
 
#define APP_WEBSITE             "http://www.newsrssticker.com"
26
 
#define APP_SUPPORT_WEBSITE     "http://www.newsrssticker.com/help.php"
27
 
#define APP_DOWNLOAD_WEBSITE    "http://www.newsrssticker.com/download.php"
28
 
#define APP_SUPPORT_EMAIL       "tickrfeedreader@gmail.com"/*"contact@newsrssticker.com"*/
 
24
#define APP_VERSION_NUMBER      "0.6.1"
 
25
#define WEBSITE_URL             "http://www.newsrssticker.com"
 
26
#define SUPPORT_URL             WEBSITE_URL"/help.php"
 
27
#define DOWNLOAD_URL            WEBSITE_URL"/download.php"
 
28
#define SUPPORT_EMAIL_ADDR      "manu@newsrssticker.com"
 
29
#define CHECK4UPDATES_URL       WEBSITE_URL"/app_version_visible.php"
 
30
#define CHECK4UPDATES_ID_STR    "LSVN=" /* Stands for 'Last Stable Version Number =' */
29
31
 
30
32
#define _GNU_SOURCE
31
33
#define _ISOC99_SOURCE
32
34
 
33
 
/*#define WITHOUT_GTK_SPINNER*/         /* for karmic and jaunty */
 
35
/*#define WITHOUT_GTK_SPINNER*/         /* For karmic and jaunty (now deprecated) */
34
36
#define VERBOSE_OUTPUT
35
37
/*#define DEBUG_OUTPUT*/
36
38
 
37
 
/* for info_win_wait(..., timeout) */
38
 
/*#define INFO_WIN_WAIT_POS     GTK_WIN_POS_CENTER*/    /* same as for info_win() */
 
39
/* For info_win_wait(..., timeout) */
 
40
/*#define INFO_WIN_WAIT_POS     GTK_WIN_POS_CENTER*/    /* Same as for info_win() */
39
41
#define INFO_WIN_WAIT_POS       GTK_WIN_POS_CENTER_ON_PARENT
40
42
/*#define INFO_WIN_WAIT_POS     GTK_WIN_POS_NONE*/
41
43
#define INFO_WIN_WAIT_TIMEOUT   2000    /* in ms */
43
45
#define CONNECT_FAIL_MAX        5
44
46
#define CONNECT_FAIL_TIMEOUT    1
45
47
 
46
 
/* for correctness, 'uri' should be used instead of 'url' */
 
48
/* For correctness sake, 'uri' should be used instead of 'url'. */
47
49
 
48
50
#include <stdio.h>
49
51
#include <string.h>
64
66
# include <arpa/inet.h>
65
67
# include <sys/select.h>
66
68
#else
67
 
/* win version = xp or higher */
 
69
/* Win version = XP or higher */
68
70
# define WINVER         0x0501
69
71
# define _WIN32_WINNT   0x0501
70
72
# include <winsock2.h>
85
87
#include "tickr_socket.h"
86
88
#include "tickr_list.h"
87
89
 
88
 
#define USE_GUI                 TRUE    /* to implement or not gui/menu features at compile time
89
 
                                         * otherwise, cli only app */
90
 
#if USE_GUI
91
 
# define RESOURCE_NONE_QUIT     FALSE   /* to quit or not if no resource id specified */
92
 
# define OPTION_ERROR_QUIT      FALSE   /* to quit or not if unknown or invalid option(s) */
93
 
#else
94
 
# define RESOURCE_NONE_QUIT     TRUE
95
 
# define OPTION_ERROR_QUIT      TRUE
96
 
#endif
 
90
#define RESOURCE_NONE_QUIT      FALSE   /* To quit or not if no resource is specified */
 
91
#define OPTION_ERROR_QUIT       FALSE   /* To quit or not if unknown or invalid option(s) */
97
92
 
98
93
#define DRWA_WIDTH_MIN          100
99
94
#define DRWA_HEIGHT_MIN         10
100
95
#define TAB_SIZE                8
101
 
/* ok? previous value was FILE_NAME_MAXLEN = 255 - apply to both full file names and urls
102
 
 * maybe we should change this so that file name max len = 255 and url max len = 2047 (or more) */
103
 
#define FILE_NAME_MAXLEN        (2 * 1024 - 1)
104
 
/*#define URL_MAXLEN            (2 * 1024 - 1)*/        /* unused so far, see above */
 
96
#define FILE_NAME_MAXLEN        (2 * 1024 - 1)  /* Apply to both FULL FILE NAMES and ***URLs*** */
105
97
#define FONT_NAME_MAXLEN        64
106
98
#define FONT_SIZE_MAXLEN        3
107
99
#define FONT_MAXLEN             FONT_NAME_MAXLEN + 1 + FONT_SIZE_MAXLEN
109
101
#define OPTION_NAME_MAXLEN      31
110
102
#define OPTION_VALUE_MAXLEN     MAX(MAX(FILE_NAME_MAXLEN, FONT_MAXLEN), DELIMITER_MAXLEN)
111
103
#define OPTION_MAXLEN           OPTION_NAME_MAXLEN + OPTION_VALUE_MAXLEN + 4    /* -name="value" */
112
 
#define N_OPTION_MAX            64      /* max number of options */
113
 
#define N_URL_MAX               1024    /* max number of url's */
114
 
#define NFEEDLINKANDOFFSETMAX   256     /* max number of "open-able" links per feed */
 
104
#define N_OPTION_MAX            64      /* Max number of options */
 
105
#define N_URL_MAX               1024    /* Max number of url's */
 
106
#define NFEEDLINKANDOFFSETMAX   256     /* Max number of "open-able" links per feed */
115
107
#define LINK_TAG_CHAR           '^'     /* ascii 5E - char used internally for links, removed from feed text */
116
 
#define TMPSTR_SIZE             (2 * 1024 - 1)  /* used for most tmp strings - must be large enough */
 
108
#define TMPSTR_SIZE             (2 * 1024 - 1)  /* Used for most tmp strings - must be large enough */
117
109
#ifndef G_OS_WIN32
118
110
# define SEPARATOR_CHAR         '/'
119
111
#else
128
120
#define UNSELECTED_URL_CHAR     '-'
129
121
#define UNSELECTED_URL_STR      "-"
130
122
 
131
 
/* make sure this stuff is robust enough */
 
123
/* Make sure this stuff is robust enough */
132
124
#define XPIXMAP_MAXWIDTH        (32 * 1024 - 1) /* 32 K - 1 = max supported width for xpixmaps
133
 
                                                 * (not 64 k - 1 as sometimes uncorrectly specified)
 
125
                                                 * (not 64 k - 1 as sometimes uncorrectly specified.)
134
126
                                                 */
135
 
#define LINE_MAXLEN             128     /* max length of a single line (see tickr_render.c) */
136
 
#define WORD_MAXLEN             32      /* max length of a word that won't get cut off */
 
127
#define LINE_MAXLEN             128     /* Max length of a single line (see tickr_render.c) */
 
128
#define WORD_MAXLEN             32      /* Max length of a word that won't get cut off */
137
129
#if (LINE_MAXLEN <= WORD_MAXLEN)
138
130
# error LINE_MAXLEN must be > WORD_MAXLEN
139
131
#endif
140
132
#define FONT_MAXSIZE            200
141
133
 
 
134
#define ARBITRARY_TASKBAR_HEIGHT 25
 
135
 
142
136
/*
143
 
 * file names, paths and dirs stuff
 
137
 * File names, paths and dirs stuff
144
138
 *
145
 
 * linux version:       /usr/bin/
 
139
 * Linux version:       /usr/bin/
146
140
 *                      /usr/share/APP_CMD/
147
141
 *                      /usr/share/APP_CMD/pixmpas/
148
142
 *                      /home/<user_name>/.APP_CMD/
149
143
 *
150
 
 * win32 version:       C:\Program files\APP_NAME\      (also location for pixmaps)
 
144
 * Win32 version:       C:\Program files\APP_NAME\      (also location for pixmaps)
151
145
 *                      C:\...\Application Data\APP_NAME\
152
146
 */
153
147
#ifndef G_OS_WIN32
182
176
#define TICKR_LOGO              APP_CMD"-logo.png"
183
177
#define RSS_ICON                APP_CMD"-rss-icon.png"
184
178
 
185
 
/* default config values */
 
179
/* Default config values */
186
180
#define DELAY                   8
187
181
#define SHIFTSIZE               1
188
182
#ifndef G_OS_WIN32
191
185
# define FONTNAME               "Arial Unicode MS"
192
186
#endif
193
187
#define FONTSIZE                "14"
194
 
#define FGCOLOR                 "#ffffffff"     /* white */
195
 
#define BGCOLOR                 "#36516240"     /* some translucent blue */
 
188
#define FGCOLOR                 "#ffffffff"     /* White */
 
189
#define BGCOLOR                 "#36516240"     /* Some translucent blue */
196
190
#define WIN_X                   0
197
191
#define WIN_Y                   0
198
 
#define WIN_W                   1024    /* unused, we use get_ticker_env()->screen_w instead */
199
 
#define WIN_H                   0       /* if = 0, determined by font size */
 
192
#define WIN_W                   1024    /* Unused, we use get_ticker_env()->screen_w instead */
 
193
#define WIN_H                   0       /* If = 0, determined by font size */
200
194
#define WINDEC                  'n'
201
 
#define ALWAYSONTOP             'y'
 
195
#define ALWAYSONTOP             'n'     /* Changed to no */
202
196
#ifndef G_OS_WIN32
203
197
# define WINTRANSPARENCY        1.0
204
198
#else
212
206
#define SHADOWFX                2
213
207
#define LINEDELIMITER           " "
214
208
#define CUTLINEDELIMITER        "..."LINEDELIMITER
 
209
#define SPECIALCHARS            'n'
 
210
#define NEWPG                   '`'
 
211
#define TABCH                   '~'
215
212
#define RSSREFRESH              15
216
 
#define RSSTITLE                'y'
217
 
#define RSSTITLEDELIMITER       "        "
218
 
#define RSSDESCRIPTION          'n'
219
 
#define RSSDESCRIPTIONDELIMITER "        -        "
 
213
#define FEEDTITLE               'n'
 
214
#define FEEDTITLEDELIMITER      "        "
 
215
#define ITEMTITLE               'y'
 
216
#define ITEMTITLEDELIMITER      "        "
 
217
#define ITEMDESCRIPTION         'n'
 
218
#define ITEMDESCRIPTIONDELIMITER "        -        "
220
219
#define NITEMSPERFEED           5
221
220
#define STRIPHTMLTAGS           'y'
222
221
#define UPPERCASETEXT           'n'
223
222
#define HOMEFEED                "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml"
224
223
#ifndef G_OS_WIN32
225
 
# define OPENLINKCMD            "firefox"       /* firefox on linux */
 
224
# define OPENLINKCMD            "firefox"       /* Firefox on Linux */
226
225
#else
227
226
# define OPENLINKCMD            ""
228
227
#endif
234
233
#define CBGCOLOR                BGCOLOR
235
234
#define DISABLEPOPUPS           'n'
236
235
#define PAUSEONMOUSEOVER        'y'
 
236
#define DISABLELEFTCLICK        'n'
237
237
#define MOUSEWHEELSCROLL        's'
238
 
#define SPECIALCHARS            'n'
239
 
#define NEWPG                   '`'
240
 
#define TABCH                   '~'
241
238
#define USEAUTHENTICATION       'n'
242
239
#define USER                    ""
243
240
#define USEPROXY                'n'
246
243
#define USEPROXYAUTHENTICATION  'n'
247
244
#define PROXYUSER               ""
248
245
 
 
246
/* Global pseudo stdout and stderr on win32 */
 
247
#ifdef G_OS_WIN32
 
248
extern FILE     *stdout_fp, *stderr_fp;
 
249
#endif
 
250
 
249
251
/* typedef enum's */
250
252
typedef enum {
251
253
        SINGLE,
255
257
typedef enum {
256
258
        RESRC_TYPE_UNDETERMINED,
257
259
        RESRC_UNSPECIFIED,
258
 
        RESRC_URL,              /* will be fetched and xml-parsed */
259
 
        RESRC_FILE              /* will be processed as non-xml text file */
 
260
        RESRC_URL,              /* Will be fetched and xml-parsed */
 
261
        RESRC_FILE              /* Will be processed as non-xml text file */
260
262
} _resrc_type;
261
263
 
262
264
typedef enum {
294
296
} connection_settings_page;
295
297
 
296
298
/* typedef struct's */
297
 
/* usefull graphical (and other) ticker 'environment' values */
 
299
/* Usefull graphical (and other) ticker 'environment' values */
298
300
typedef struct {
299
 
        GdkScreen       *screen;                        /* gdk screen for win */
 
301
        GdkScreen       *screen;                        /* GDK screen for win */
300
302
        GdkVisual       *visual;
301
 
        gint            screen_w, screen_h;             /* screen width & height */
302
 
        gint            depth;                          /* screen depth */
303
 
        GtkWidget       *win;                           /* top level window */
304
 
        GtkWidget       *drw_a, *drwa_clock;            /* drawing areas (main / clock) */
305
 
        gint            drwa_width, drwa_height;        /* main drawing area dimensions */
306
 
        gint            drwa_clock_width;               /* clock drawing area width */
307
 
        cairo_surface_t *c_surf;                        /* cairo image surface onto which text is rendered */
308
 
        gint            surf_width, surf_height;        /* cairo image surface dimensions */
 
303
        gint            screen_w, screen_h;             /* Screen width & height */
 
304
        gint            depth;                          /* Screen depth */
 
305
        GtkWidget       *win;                           /* Top level window */
 
306
        GtkWidget       *drw_a, *drwa_clock;            /* Drawing areas (main / clock) */
 
307
        gint            drwa_width, drwa_height;        /* Main drawing area dimensions */
 
308
        gint            drwa_clock_width;               /* Clock drawing area width */
 
309
        cairo_surface_t *c_surf;                        /* Cairo image surface onto which text is rendered */
 
310
        gint            surf_width, surf_height;        /* Cairo image surface dimensions */
309
311
        char            active_link[FILE_NAME_MAXLEN + 1];
310
 
        /* these flags are checked by callback */
311
 
        gboolean        suspend_rq;                     /* request for doing nothing */
312
 
        gboolean        compute_rq;                     /* request for (re)computing everything (surface and win) */
313
 
        gboolean        reload_rq;                      /* request for (re)loading resource */
314
 
        _selection_mode selection_mode;                 /* default = MULTIPLE, set to SINGLE internally if selection
 
312
        /* These flags are checked by callback */
 
313
        gboolean        suspend_rq;                     /* Request for doing nothing */
 
314
        gboolean        compute_rq;                     /* Request for (re)computing everything (surface and win) */
 
315
        gboolean        reload_rq;                      /* Request for (re)loading resource */
 
316
        _selection_mode selection_mode;         /* default = MULTIPLE, set to SINGLE internally if selection
315
317
                                                         * is unavalaible/empty or after picking a single feed */
316
 
        gboolean        stream_fully_read;              /* set/checked only in render_stream_to_surface() and
 
318
        gboolean        stream_fully_read;              /* Set/checked only in render_stream_to_surface() and
317
319
                                                         * shift2left_callback() */
318
320
} TickerEnv;
319
321
 
323
325
} FeedLinkAndOffset;
324
326
 
325
327
typedef struct {
326
 
        _resrc_type     type;                           /* text file or url */
 
328
        _resrc_type     type;                           /* Text file or url */
327
329
        _rss_format     format;                         /* RSS 1.0, RSS 2.0 or Atom */
328
 
        char            id[FILE_NAME_MAXLEN + 1];       /* local = file name or remote = feed url */
329
 
        /* apply only to url/rss */
 
330
        char            id[FILE_NAME_MAXLEN + 1];       /* Local = file name or remote = feed url */
 
331
        /* Apply only to url/rss */
330
332
        _rss_format     rss_format;
331
333
        char            feed_title[FEED_TITLE_MAXLEN + 1];
332
 
        char            resrc_dump[FILE_NAME_MAXLEN + 1];       /* downloaded file/resource */
 
334
        char            resrc_dump[FILE_NAME_MAXLEN + 1];       /* Downloaded file/resource */
333
335
        char            xml_dump[FILE_NAME_MAXLEN + 1];
334
 
        FILE            *fp;                            /* file to be read (from xmldump) after some processing, */
 
336
        FILE            *fp;                            /* File to be read (from xmldump) after some processing, */
335
337
        FeedLinkAndOffset link_and_offset[NFEEDLINKANDOFFSETMAX];
336
338
        int             rss_ttl;
337
339
} Resource;
340
342
#define PSW_MAXLEN              63
341
343
#define AUTH_STR_MAXLEN         127
342
344
 
343
 
/* do we need both these auth/proxy structs and auth/proxy params? redundant... */
 
345
/* Do we need both these auth/proxy structs and auth/proxy params? redundant... */
344
346
typedef struct {
345
347
        gboolean        use_authentication;
346
348
        char            user[USER_MAXLEN + 1];
389
391
        int             shadow_fx;
390
392
        char            line_delimiter[DELIMITER_MAXLEN + 1];
391
393
        char            cutline_delimiter[DELIMITER_MAXLEN + 1];
 
394
        char            special_chars;
 
395
        char            new_page_char;
 
396
        char            tab_char;
392
397
        int             rss_refresh;
393
 
        char            rss_title;
394
 
        char            rss_title_delimiter[DELIMITER_MAXLEN + 1];
395
 
        char            rss_description;
396
 
        char            rss_description_delimiter[DELIMITER_MAXLEN + 1];
 
398
        char            feed_title;
 
399
        char            feed_title_delimiter[DELIMITER_MAXLEN + 1];
 
400
        char            item_title;
 
401
        char            item_title_delimiter[DELIMITER_MAXLEN + 1];
 
402
        char            item_description;
 
403
        char            item_description_delimiter[DELIMITER_MAXLEN + 1];
397
404
        int             n_items_per_feed;
398
405
        char            strip_html_tags;
399
406
        char            upper_case_text;
408
415
        guint16         clock_bg_color_alpha;
409
416
        char            disable_popups;
410
417
        char            pause_on_mouseover;
411
 
        char            mouse_wheel_scroll;     /* apply to s (speed) / f (feed) / n (none) */
412
 
        char            special_chars;
413
 
        char            new_page_char;
414
 
        char            tab_char;
415
 
/* do we need both these auth/proxy structs and auth/proxy params? redundant... */
 
418
        char            disable_leftclick;
 
419
        char            mouse_wheel_scroll;     /* Apply to s (speed) / f (feed) / n (none) */
 
420
/* Do we need both these auth/proxy structs and auth/proxy params? redundant... */
416
421
        char            use_authentication;
417
422
        char            user[USER_MAXLEN + 1];
418
423
        char            use_proxy;
422
427
        char            proxy_user[PROXY_USER_MAXLEN + 1];
423
428
} Params;
424
429
 
425
 
/* error codes */
 
430
/* Error codes */
426
431
typedef enum {
427
432
        OK = SOCKET_LASTERRORCODE + 1,
428
433
 
579
584
int             modify_params(Params *);
580
585
 
581
586
/* tickr_otherwins.c */
 
587
gint            esc_key_pressed(GtkWidget *, GdkEventKey *);
 
588
void            force_quit_dialog(GtkWidget *);
582
589
void            open_new_txt_file(Resource *resrc);
583
590
void            help_win();
584
591
void            about_win();
597
604
void            dump_font_list();
598
605
 
599
606
/* tickr_hlptxt.c */
600
 
#if USE_GUI
601
607
const char      **get_help_str0();
602
 
#endif
603
608
const char      **get_help_str1();
604
609
const char      **get_license_str1();
605
610
const char      *get_license_str2();
614
619
int             save_str_as_opml_file(const char *);
615
620
 
616
621
/* tickr_http.c */
 
622
void            remove_chunk_info(char **);
617
623
int             connect_with_url(sockt *, char *);
618
624
int             fetch_resource(const char *, const char *, char *);
619
625
const char      *build_http_request(const char *, const char *, const char *,\
630
636
const char      *get_path_from_url(const char*);
631
637
 
632
638
/* tickr_socket.c */
633
 
/* proto moved into tickr_socket.h */
 
639
/* Proto moved into tickr_socket.h */
634
640
 
635
641
/* tickr_connectwin.c */
636
642
void            init_authentication();
655
661
 
656
662
/* tickr_quickfeedpicker.c */
657
663
void            quick_feed_picker(int);
 
664
 
 
665
/* tickr_quicksetup.c */
 
666
void            quick_setup(Params *);
 
667
 
 
668
/* tickr_check4updates.c */
 
669
void            check_for_updates();
658
670
#endif /* INC_TICKR_H */