]> jfr.im git - irc/xchat.git/commitdiff
implement per-channel settings saving. chanopt.conf now loaded & written. How's it...
authorzed <redacted>
Sun, 24 Feb 2008 02:56:02 +0000 (02:56 +0000)
committerzed <redacted>
Sun, 24 Feb 2008 02:56:02 +0000 (02:56 +0000)
git-svn-id: svn://svn.code.sf.net/p/xchat/svn@1278 893a96be-7f27-4fdf-9d1e-6aeec9d3cce1

src/common/Makefile.am
src/common/outbound.c
src/common/xchat.c
src/common/xchat.h

index 8355b794b848b2d0ed46b1fd0082ced914fc04b4..ff89e329e97c8c0e1fbe500c3b09ef3e57e1210b 100644 (file)
@@ -6,6 +6,7 @@ INCLUDES = $(COMMON_CFLAGS)
 
 EXTRA_DIST = makefile.msc \
        cfgfiles.h \
+       chanopt.h \
        ctcp.h \
        dcc.h \
        fe.h \
@@ -50,7 +51,7 @@ libxchatcommon_a_LIBADD =                             \
 endif
 SUBDIRS = $(dbusdir) .
 
-libxchatcommon_a_SOURCES = cfgfiles.c ctcp.c dcc.c history.c ignore.c \
+libxchatcommon_a_SOURCES = cfgfiles.c chanopt.c ctcp.c dcc.c history.c ignore.c \
        inbound.c modes.c msproxy.c network.c notify.c outbound.c \
        plugin.c plugin-timer.c proto-irc.c server.c servlist.c $(ssl_c) \
        text.c tree.c url.c userlist.c util.c xchat.c
index 305dc5f59923274ba9b427f237006ffce5d88b37..3e2600b54de7a2b0a26068fbbd445eab9cefa6ab 100644 (file)
@@ -573,110 +573,11 @@ cmd_unban (struct session *sess, char *tbuf, char *word[], char *word_eol[])
        }
 }
 
-/* per-channel/dialog settings :: /CHANOPT */
-
-typedef struct
-{
-       char *name;
-       char *alias;    /* old names from 2.8.4 */
-       int offset;
-} channel_options;
-
-#define S_F(xx) STRUCT_OFFSET_STR(struct session,xx)
-
-channel_options chanopt[] =
-{
-       {"alert_beep", "BEEP", S_F(alert_beep)},
-       {"alert_taskbar", NULL, S_F(alert_taskbar)},
-       {"alert_tray", "TRAY", S_F(alert_tray)},
-
-       {"text_hidejoinpart", "CONFMODE", S_F(text_hidejoinpart)},
-       {"text_logging", NULL, S_F(text_logging)},
-       {"text_scrollback", NULL, S_F(text_scrollback)},
-};
-
-#undef SESS_FIELD
-
-static char *
-chanopt_value (guint8 val)
-{
-       switch (val)
-       {
-       case SET_OFF:
-               return "OFF";
-       case SET_ON:
-               return "ON";
-       default:
-               return "{unset}";
-       }
-}
-
 static int
 cmd_chanopt (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 {
-       int dots, i = 0, j, p = 0;
-       guint8 val;
-       int offset = 2;
-       char *find;
-       gboolean quiet = FALSE;
-       int newval = -1;
-
-       if (!strcmp (word[2], "-quiet"))
-       {
-               quiet = TRUE;
-               offset++;
-       }
-
-       find = word[offset++];
-
-       if (word[offset][0])
-       {
-               if (!strcasecmp (word[offset], "ON"))
-                       newval = 1;
-               else if (!strcasecmp (word[offset], "OFF"))
-                       newval = 0;
-               else if (word[offset][0] == 'u')
-                       newval = SET_DEFAULT;
-               else
-                       newval = atoi (word[offset]);
-       }
-
-       if (!quiet)
-               PrintTextf (sess, "\002Network\002: %s \002Channel\002: %s\n",
-                                               sess->server->network ? server_get_network (sess->server, TRUE) : _("<none>"),
-                                               sess->channel[0] ? sess->channel : _("<none>"));
-
-       while (i < sizeof (chanopt) / sizeof (channel_options))
-       {
-               if (find[0] == 0 || match (find, chanopt[i].name) || (chanopt[i].alias && match (find, chanopt[i].alias)))
-               {
-                       if (newval != -1)       /* set new value */
-                       {
-                               *(guint8 *)G_STRUCT_MEMBER_P(sess, chanopt[i].offset) = newval;
-                       }
-
-                       if (!quiet)     /* print value */
-                       {
-                               strcpy (tbuf, chanopt[i].name);
-                               p = strlen (tbuf);
-
-                               tbuf[p++] = 3;
-                               tbuf[p++] = '2';
-
-                               dots = 20 - strlen (chanopt[i].name);
-
-                               for (j = 0; j < dots; j++)
-                                       tbuf[p++] = '.';
-                               tbuf[p++] = 0;
-
-                               val = G_STRUCT_MEMBER (guint8, sess, chanopt[i].offset);
-                               PrintTextf (sess, "%s\0033:\017 %s", tbuf, chanopt_value (val));
-                       }
-               }
-               i++;
-       }
-
-       return TRUE;
+       /* chanopt.c */
+       return chanopt_command (sess, tbuf, word, word_eol);
 }
 
 static int
@@ -2805,8 +2706,14 @@ cmd_notify (struct session *sess, char *tbuf, char *word[], char *word_eol[])
                                EMIT_SIGNAL (XP_TE_DELNOTIFY, sess, word[i], NULL, NULL, NULL, 0);
                                return TRUE;
                        }
-                       notify_adduser (word[i], net);
-                       EMIT_SIGNAL (XP_TE_ADDNOTIFY, sess, word[i], NULL, NULL, NULL, 0);
+
+                       if (strcmp (net, "ASK") == 0)
+                               fe_notify_ask (word[i], NULL);
+                       else
+                       {
+                               notify_adduser (word[i], net);
+                               EMIT_SIGNAL (XP_TE_ADDNOTIFY, sess, word[i], NULL, NULL, NULL, 0);
+                       }
                }
        } else
                notify_showlist (sess);
@@ -3894,8 +3801,8 @@ auto_insert (char *dest, int destlen, unsigned char *src, char *word[],
                                        if ((dest - orig) + 2 >= destlen)
                                                return 2;
                                        dest[0] = '%';
+                                       dest[1] = 0;
                                        dest++;
-                                       dest[0] = 0;
                                        break;
                                case 'a':
                                        utf = a; break;
index b30123d7579d710d3ffe3039650aa70b582c3034..3158bd4c9637631f4a91a6b314d757980b9791e9 100644 (file)
@@ -36,6 +36,7 @@
 #include "fe.h"
 #include "util.h"
 #include "cfgfiles.h"
+#include "chanopt.h"
 #include "ignore.h"
 #include "xchat-plugin.h"
 #include "plugin.h"
@@ -395,6 +396,7 @@ new_ircwindow (server *serv, char *name, int type, int focus)
 
        irc_init (sess);
        scrollback_load (sess);
+       chanopt_load (sess);
        plugin_emit_dummy_print (sess, "Open Context");
 
        return sess;
@@ -511,6 +513,7 @@ session_free (session *killsess)
 
        log_close (killsess);
        scrollback_close (killsess);
+       chanopt_save (killsess);
 
        send_quit_or_part (killsess);
 
@@ -841,6 +844,7 @@ xchat_exit (void)
        notify_save ();
        ignore_save ();
        free_sessions ();
+       chanopt_save_all ();
        fe_exit ();
 }
 
index 7b42d76790836394883b8c958c769aeea245b255..5beabe2c26315ac1040af9174b220c9d8d925e52 100644 (file)
@@ -322,6 +322,17 @@ struct xchatprefs
 
 typedef struct session
 {
+       /* Per-Channel Alerts */
+       /* use a byte, because we need a pointer to each element */
+       guint8 alert_beep;
+       guint8 alert_taskbar;
+       guint8 alert_tray;
+
+       /* Per-Channel Settings */
+       guint8 text_hidejoinpart;
+       guint8 text_logging;
+       guint8 text_scrollback;
+
        struct server *server;
        void *usertree_alpha;                   /* pure alphabetical tree */
        void *usertree;                                 /* ordered with Ops first */
@@ -358,17 +369,6 @@ typedef struct session
 
        int type;                                       /* SESS_* */
 
-       /* Per-Channel Alerts */
-       /* use a byte, because we need a pointer to each element */
-       guint8 alert_beep;
-       guint8 alert_taskbar;
-       guint8 alert_tray;
-
-       /* Per-Channel Settings */
-       guint8 text_hidejoinpart;
-       guint8 text_logging;
-       guint8 text_scrollback;
-
        int new_data:1;                 /* new data avail? (purple tab) */
        int nick_said:1;                /* your nick mentioned? (blue tab) */
        int msg_said:1;                 /* new msg available? (red tab) */