~ubuntu-branches/ubuntu/oneiric/irssi/oneiric

« back to all changes in this revision

Viewing changes to src/fe-common/core/fe-common-core.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2009-05-05 15:50:50 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090505155050-aoqlnpes7che9rtd
Tags: 0.8.13-1ubuntu1
* Merge from debian unstable (LP: #372411), remaining changes:
  - debian/patches: 03firsttimer_text
    + Adapt it so it tells you about connecting to irc.ubuntu.com and
      joining #ubuntu instead of irc.debian.org and #debian.
  - debian/patches: 90irc-ubuntu-com
* Fixed debian/patches/90irc-ubuntu-com for new irssi.conf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "misc.h"
25
25
#include "levels.h"
26
26
#include "settings.h"
27
 
#ifdef HAVE_NL_LANGINFO
28
 
#  include <langinfo.h>
29
 
#endif
30
27
 
31
28
#include "servers.h"
32
29
#include "channels.h"
33
30
#include "servers-setup.h"
34
 
#include "recode.h"
35
31
 
36
 
#include "autorun.h"
 
32
#include "special-vars.h"
37
33
#include "fe-core-commands.h"
38
34
#include "fe-queries.h"
39
35
#include "hilight-text.h"
43
39
#include "printtext.h"
44
40
#include "formats.h"
45
41
#include "themes.h"
46
 
#include "translation.h"
47
42
#include "fe-channels.h"
48
43
#include "fe-windows.h"
49
44
#include "window-activity.h"
125
120
 
126
121
void fe_common_core_register_options(void)
127
122
{
128
 
        static struct poptOption options[] = {
129
 
                POPT_AUTOHELP
130
 
                { "connect", 'c', POPT_ARG_STRING, &autocon_server, 0, "Automatically connect to server/network", "SERVER" },
131
 
                { "password", 'w', POPT_ARG_STRING, &autocon_password, 0, "Autoconnect password", "PASSWORD" },
132
 
                { "port", 'p', POPT_ARG_INT, &autocon_port, 0, "Autoconnect port", "PORT" },
133
 
                { "noconnect", '!', POPT_ARG_NONE, &no_autoconnect, 0, "Disable autoconnecting", NULL },
134
 
                { "nick", 'n', POPT_ARG_STRING, &cmdline_nick, 0, "Specify nick to use", NULL },
135
 
                { "hostname", 'h', POPT_ARG_STRING, &cmdline_hostname, 0, "Specify host name to use", NULL },
136
 
                { NULL, '\0', 0, NULL }
 
123
        static GOptionEntry options[] = {
 
124
                { "connect", 'c', 0, G_OPTION_ARG_STRING, &autocon_server, "Automatically connect to server/network", "SERVER" },
 
125
                { "password", 'w', 0, G_OPTION_ARG_STRING, &autocon_password, "Autoconnect password", "PASSWORD" },
 
126
                { "port", 'p', 0, G_OPTION_ARG_INT, &autocon_port, "Autoconnect port", "PORT" },
 
127
                { "noconnect", '!', 0, G_OPTION_ARG_NONE, &no_autoconnect, "Disable autoconnecting", NULL },
 
128
                { "nick", 'n', 0, G_OPTION_ARG_STRING, &cmdline_nick, "Specify nick to use", NULL },
 
129
                { "hostname", 'h', 0, G_OPTION_ARG_STRING, &cmdline_hostname, "Specify host name to use", NULL },
 
130
                { NULL }
137
131
        };
138
132
 
139
133
        autocon_server = NULL;
147
141
 
148
142
void fe_common_core_init(void)
149
143
{
 
144
        const char *str;
 
145
 
150
146
        settings_add_bool("lookandfeel", "timestamps", TRUE);
151
147
        settings_add_level("lookandfeel", "timestamp_level", "ALL");
152
148
        settings_add_time("lookandfeel", "timestamp_timeout", "0");
162
158
 
163
159
        settings_add_bool("lookandfeel", "use_status_window", TRUE);
164
160
        settings_add_bool("lookandfeel", "use_msgs_window", FALSE);
165
 
#if defined (HAVE_NL_LANGINFO) && defined(CODESET)
166
 
        settings_add_str("lookandfeel", "term_charset", 
167
 
                         *nl_langinfo(CODESET) != '\0' ? 
168
 
                         nl_langinfo(CODESET) : "ISO8859-1");
169
 
#else
170
 
        settings_add_str("lookandfeel", "term_charset", "ISO8859-1");
171
 
#endif
 
161
        g_get_charset(&str);
 
162
        settings_add_str("lookandfeel", "term_charset", str);
172
163
        themes_init();
173
164
        theme_register(fecommon_core_formats);
174
165
 
187
178
        fe_modules_init();
188
179
        fe_server_init();
189
180
        fe_settings_init();
190
 
        translation_init();
191
181
        windows_init();
192
182
        window_activity_init();
193
183
        window_commands_init();
231
221
        fe_modules_deinit();
232
222
        fe_server_deinit();
233
223
        fe_settings_deinit();
234
 
        translation_deinit();
235
224
        windows_deinit();
236
225
        window_activity_deinit();
237
226
        window_commands_deinit();
397
386
                create_windows();
398
387
}
399
388
 
 
389
static void autorun_startup(void)
 
390
{
 
391
        char *path;
 
392
        GIOChannel *handle;
 
393
        GString *buf;
 
394
        gsize tpos;
 
395
 
 
396
        /* open ~/.irssi/startup and run all commands in it */
 
397
        path = g_strdup_printf("%s/startup", get_irssi_dir());
 
398
        handle = g_io_channel_new_file(path, "r", NULL);
 
399
        g_free(path);
 
400
        if (handle == NULL) {
 
401
                /* file not found */
 
402
                return;
 
403
        }
 
404
 
 
405
        g_io_channel_set_encoding(handle, NULL, NULL);
 
406
        buf = g_string_sized_new(512);
 
407
        while (g_io_channel_read_line_string(handle, buf, &tpos, NULL) == G_IO_STATUS_NORMAL) {
 
408
                buf->str[tpos] = '\0';
 
409
                if (buf->str[0] != '#') {
 
410
                        eval_special_string(buf->str, "",
 
411
                                            active_win->active_server,
 
412
                                            active_win->active);
 
413
                }
 
414
        }
 
415
        g_string_free(buf, TRUE);
 
416
 
 
417
        g_io_channel_unref(handle);
 
418
}
 
419
 
400
420
void fe_common_core_finish_init(void)
401
421
{
402
422
        int setup_changed;
443
463
        autorun_startup();
444
464
        autoconnect_servers();
445
465
}
 
466
 
 
467
gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest)
 
468
{
 
469
        g_return_val_if_fail(array != NULL, FALSE);
 
470
 
 
471
        if (strarray_find(array, dest->target) != -1)
 
472
                return TRUE;
 
473
 
 
474
        if (dest->server_tag != NULL) {
 
475
                char *tagtarget = g_strdup_printf("%s/%s", dest->server_tag, dest->target);
 
476
                int ret = strarray_find(array, tagtarget);
 
477
                g_free(tagtarget);
 
478
                if (ret != -1)
 
479
                        return TRUE;
 
480
        }
 
481
        return FALSE;
 
482
}