Ticket #388: autoprofile-pidgin.diff

File autoprofile-pidgin.diff, 60.7 kB (added by bettse, 11 months ago)

diff against AutoProfile? 2.14 to get it working with Pidgin 2.2.1

  • Makefile

    Only in .: autoprofile.so
    diff -ru /home/bettse/MyDownloads/autoprofile-2.14/Makefile ./Makefile
    old new  
    22# Makefile 
    33# 
    44# Description: Autoprofile makefile for linux/unix systems 
    5 # Thanks to the gaim-blogger guys for providing a useful script 
     5# Thanks to the pidgin-blogger guys for providing a useful script 
    66# to start from 
    77# 
    88# This file really should be temporary/an autoconf setup would 
     
    1515PREFIX = /usr/local 
    1616GTK_PREFIX = $(PREFIX) 
    1717GTK_PREFIX2 = /usr 
    18 GAIM_TOP = ../.. 
    19 GAIM_TOP2 = ../gaim 
    20 GAIM_TOP3 = /usr/include/gaim 
    21 GTK_GAIM_INCLUDES = `pkg-config --cflags gtk+-2.0 gaim` 
     18PIDGIN_TOP = ../../.. 
     19PIDGIN_TOP2 = ../.. 
     20PIDGIN_TOP3 = /usr/include/pidgin 
     21PIDGIN_TOP4 = $(PIDGIN_TOP)/libpurple 
     22GTK_PIDGIN_INCLUDES = `pkg-config --cflags gtk+-2.0 pidgin` 
    2223 
    2324## 
    2425## VARIABLE DEFINITIONS 
     
    3839## 
    3940 
    4041INCLUDES = \ 
    41       -I$(GAIM_TOP2) \ 
    42       -I${GAIM_TOP2}/src \ 
    43       -I$(GAIM_TOP) \ 
    44       -I$(GAIM_TOP)/src \ 
    45       -I$(GAIM_TOP3) \ 
    46       -I$(GAIM_TOP3)/src \ 
     42      -I$(PIDGIN_TOP2) \ 
     43      -I${PIDGIN_TOP2}/src \ 
     44      -I$(PIDGIN_TOP) \ 
     45      -I$(PIDGIN_TOP)/src \ 
     46      -I$(PIDGIN_TOP3) \ 
     47      -I$(PIDGIN_TOP3)/src \ 
     48      -I$(PIDGIN_TOP4) \ 
     49      -I$(PIDGIN_TOP4)/src \ 
    4750      -I$(GTK_PREFIX)/include \ 
    4851      -I$(GTK_PREFIX)/include/gtk-2.0 \ 
    4952      -I$(GTK_PREFIX)/include/glib-2.0 \ 
     
    5861      -I$(GTK_PREFIX2)/include/atk-1.0 \ 
    5962      -I$(GTK_PREFIX2)/lib/glib-2.0/include \ 
    6063      -I$(GTK_PREFIX2)/lib/gtk-2.0/include \ 
    61       $(GTK_GAIM_INCLUDES) 
     64      $(GTK_PIDGIN_INCLUDES) 
    6265 
    6366LIB_PATHS = 
    6467 
     
    113116all: $(TARGET) 
    114117 
    115118install: 
    116     install -m 755 $(TARGET) $(PREFIX)/lib/gaim 
     119    install -m 755 $(TARGET) $(PREFIX)/lib/pidgin 
    117120 
    118121$(TARGET): $(OBJECTS) 
    119122    $(CC) $(OBJECTS) $(LDFLAGS) $(LIB_PATHS) $(LIBS) -o $(TARGET) 
  • src/autoprofile.c

    Only in ./src: .autoprofile.c~
    diff -ru /home/bettse/MyDownloads/autoprofile-2.14/src/autoprofile.c ./src/autoprofile.c
    old new  
    2020 * along with this program; if not, write to the Free Software              * 
    2121 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA * 
    2222 *--------------------------------------------------------------------------*/ 
     23#ifndef GAIM_COMPAT 
     24#define GAIM_COMPAT 
     25#include "gaim-compat.h" 
     26#include "gtkgaim-compat.h" 
     27#endif /* #ifndef GAIM_COMPAT */ 
    2328 
    2429#include "autoprofile.h" 
    2530 
     
    4550static guint away_timeout = 0; 
    4651 
    4752struct auto_response { 
    48   GaimAccount *account; 
    49   char *recepient; 
    50   time_t time_sent; 
     53    GaimAccount *account; 
     54    char *recepient; 
     55    time_t time_sent; 
    5156}; 
    5257 
    5358static GList *auto_recepients = NULL; 
     
    5661static GaimCmdId cmd_away_id = 0; 
    5762static GaimCmdId cmd_back_id = 0; 
    5863static GaimCmdRet cmd_away_cb (GaimConversation *, const gchar *, gchar **, 
    59   gchar **, void *); 
     64                               gchar **, void *); 
    6065static GaimCmdRet cmd_back_cb (GaimConversation *, const gchar *, gchar **, 
    61   gchar **, void *); 
     66                               gchar **, void *); 
    6267 
    6368/*-------------------------------------------------------------------------- 
    6469 * REQUIRED GAIM FUNCTIONS- INFO, INITIALIZATION, UNLOADING 
    6570 *------------------------------------------------------------------------*/ 
    6671void queue_cb ( 
    67   const char *name, GaimPrefType type, gconstpointer val, gpointer data) { 
    68   if (is_away) { 
    69     if (gaim_prefs_get_bool("/plugins/gtk/autoprofile/queue_messages_when_away")) { 
    70       gaim_prefs_set_string ("/gaim/gtk/conversations/im/hide_new", "away"); 
    71     } else { 
    72       gaim_prefs_set_string ("/gaim/gtk/conversations/im/hide_new", "never"); 
     72    const char *name, GaimPrefType type, gconstpointer val, gpointer data) { 
     73    if (is_away) { 
     74        if (gaim_prefs_get_bool("/plugins/gtk/autoprofile/queue_messages_when_away")) { 
     75            gaim_prefs_set_string ("/gaim/gtk/conversations/im/hide_new", "away"); 
     76        } else { 
     77            gaim_prefs_set_string ("/gaim/gtk/conversations/im/hide_new", "never"); 
     78        } 
    7379    } 
    74   } 
    7580} 
    7681 
    7782/* What to do when plugin is loaded */ 
    78 static gboolean plugin_load (GaimPlugin *plugin) 
    79 { 
    80   int interval; 
    81   GList *comp_list; 
    82   struct component *comp; 
    83   
    84   /* TODO: This should go into a gtk_load or something like that */ 
    85   gaim_prefs_connect_callback ( 
    86     plugin_handle,  
    87     "/plugins/gtk/autoprofile/queue_messages_when_away", queue_cb, NULL); 
    88  
    89   
    90   /* Initialize variables */ 
    91   components = get_components (); 
    92   is_away = FALSE; 
    93   sending_auto = FALSE; 
    94   response_timeout = time (NULL); 
    95  
    96   plugin_handle = plugin; 
    97  
    98   /* Let components initialize */ 
    99   comp_list = components; 
    100   while (comp_list) { 
    101     comp = comp_list->data; 
    102     if (comp->load)         
    103       (comp->load) (); 
    104     comp_list = comp_list->next; 
    105   } 
    106    
    107   /* Begin updating profiles */ 
    108   interval = 60 * 1000 * gaim_prefs_get_int ( 
    109     "/plugins/gtk/autoprofile/delay_profile"); 
    110   profile_timeout = GINT_TO_POINTER (g_timeout_add ( 
    111     interval, profile_update, NULL)); 
    112   profile_update (NULL);  
    113  
    114   /* Connect command detector */ 
    115   gaim_cmd_register ("away", "S", GAIM_CMD_P_PLUGIN,  
    116     GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "", 
    117     cmd_away_cb, 
    118     "away <text>: Activate AutoProfile away with optional text " 
    119     "added to message", NULL); 
    120  
    121   gaim_cmd_register ("back", "", GAIM_CMD_P_PLUGIN, 
    122     GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "", 
    123     cmd_back_cb, 
    124     "back: Turn off AutoProfile away status", NULL); 
     83static gboolean plugin_load (GaimPlugin *plugin) { 
     84    int interval; 
     85    GList *comp_list; 
     86    struct component *comp; 
     87 
     88    /* TODO: This should go into a gtk_load or something like that */ 
     89    gaim_prefs_connect_callback ( 
     90        plugin_handle, 
     91        "/plugins/gtk/autoprofile/queue_messages_when_away", queue_cb, NULL); 
     92 
     93 
     94    /* Initialize variables */ 
     95    components = get_components (); 
     96    is_away = FALSE; 
     97    sending_auto = FALSE; 
     98    response_timeout = time (NULL); 
     99 
     100    plugin_handle = plugin; 
     101 
     102    /* Let components initialize */ 
     103    comp_list = components; 
     104    while (comp_list) { 
     105        comp = comp_list->data; 
     106        if (comp->load) 
     107            (comp->load) (); 
     108        comp_list = comp_list->next; 
     109    } 
    125110 
    126   return TRUE; 
     111    /* Begin updating profiles */ 
     112    interval = 60 * 1000 * gaim_prefs_get_int ( 
     113                   "/plugins/gtk/autoprofile/delay_profile"); 
     114    profile_timeout = GINT_TO_POINTER (g_timeout_add ( 
     115                                           interval, profile_update, NULL)); 
     116    profile_update (NULL); 
     117 
     118    /* Connect command detector */ 
     119    gaim_cmd_register ("away", "S", GAIM_CMD_P_PLUGIN, 
     120                       GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "", 
     121                       cmd_away_cb, 
     122                       "away <text>: Activate AutoProfile away with optional text " 
     123                       "added to message", NULL); 
     124 
     125    gaim_cmd_register ("back", "", GAIM_CMD_P_PLUGIN, 
     126                       GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "", 
     127                       cmd_back_cb, 
     128                       "back: Turn off AutoProfile away status", NULL); 
     129 
     130    return TRUE; 
    127131} 
    128132 
    129133/* What to do when plugin is unloaded */ 
    130 static gboolean plugin_unload (GaimPlugin *plugin) 
    131 { 
    132   GList *comp_list; 
    133   struct component *comp; 
    134  
    135   /* Remove global variables */ 
    136   g_source_remove (GPOINTER_TO_INT (profile_timeout)); 
    137   
    138   /* Unload components */ 
    139   comp_list = components; 
    140   while (comp_list) { 
    141     comp = comp_list->data; 
    142     if (comp->unload)        // Make sure init_pref not null 
    143       (comp->unload) (); 
    144     comp_list = comp_list->next; 
    145   }  
    146  
    147   /* Not sure if component contents should be free'd as well */ 
    148   g_list_free (components); 
    149   components = NULL; 
    150  
    151   /* Remove command detector */ 
    152   gaim_cmd_unregister (cmd_away_id); 
    153   gaim_cmd_unregister (cmd_back_id); 
     134static gboolean plugin_unload (GaimPlugin *plugin) { 
     135    GList *comp_list; 
     136    struct component *comp; 
     137 
     138    /* Remove global variables */ 
     139    g_source_remove (GPOINTER_TO_INT (profile_timeout)); 
     140 
     141    /* Unload components */ 
     142    comp_list = components; 
     143    while (comp_list) { 
     144        comp = comp_list->data; 
     145        if (comp->unload)        // Make sure init_pref not null 
     146            (comp->unload) (); 
     147        comp_list = comp_list->next; 
     148    } 
    154149 
    155   /* If away, restore */ 
    156   if (is_away) 
    157     status_back (); 
     150    /* Not sure if component contents should be free'd as well */ 
     151    g_list_free (components); 
     152    components = NULL; 
     153 
     154    /* Remove command detector */ 
     155    gaim_cmd_unregister (cmd_away_id); 
     156    gaim_cmd_unregister (cmd_back_id); 
     157 
     158    /* If away, restore */ 
     159    if (is_away) 
     160        status_back (); 
    158161 
    159   return TRUE; 
     162    return TRUE; 
    160163} 
    161164 
    162165/* General information */ 
    163 static GaimPluginInfo info = 
    164 { 
    165   GAIM_PLUGIN_MAGIC, 
    166   GAIM_MAJOR_VERSION, 
    167   GAIM_MINOR_VERSION, 
    168   GAIM_PLUGIN_STANDARD,                                 /* type           */ 
    169   GAIM_GTK_PLUGIN_TYPE,                                 /* ui_requirement */ 
    170   0,                                                    /* flags          */ 
    171   NULL,                                                 /* dependencies   */ 
    172   GAIM_PRIORITY_DEFAULT,                                /* priority       */ 
    173  
    174   N_("gtk-kluge-autoprofile"),                          /* id             */ 
    175   N_("AutoProfile"),                                    /* name           */ 
    176   AUTOPROFILE_VERSION,                                  /* version        */ 
    177   N_("User profile and away message management system"),/* summary        */ 
    178                                                           /* description    */ 
    179   N_("Allows user to set up automatically updating\n" 
    180      "away messages and profiles that contain dynamic " 
    181      "text"), 
    182                                                         /* author         */ 
    183   N_("Casey Ho <caseyho at berkeley-edu>" 
    184      "\n\t\t\taim:caseyho"), 
    185   N_("http://hkn.eecs.berkeley.edu/~casey/" 
    186      "autoprofile/"),                                   /* homepage       */ 
    187  
    188   plugin_load,                                          /* load           */ 
    189   plugin_unload,                                        /* unload         */ 
    190   NULL,                                                 /* destroy        */ 
    191  
    192   &ui_info,                                             /* ui_info        */ 
    193   NULL,                                                 /* extra_info     */ 
    194   NULL,                                                 /* prefs_info     */ 
    195   actions                                               /* actions        */ 
     166static GaimPluginInfo info = { 
     167    GAIM_PLUGIN_MAGIC, 
     168    GAIM_MAJOR_VERSION, 
     169    GAIM_MINOR_VERSION, 
     170    GAIM_PLUGIN_STANDARD,                                 /* type           */ 
     171    GAIM_GTK_PLUGIN_TYPE,                                 /* ui_requirement */ 
     172    0,                                                    /* flags          */ 
     173    NULL,                                                 /* dependencies   */ 
     174    GAIM_PRIORITY_DEFAULT,                                /* priority       */ 
     175 
     176    N_("gtk-kluge-autoprofile"),                          /* id             */ 
     177    N_("AutoProfile"),                                    /* name           */ 
     178    AUTOPROFILE_VERSION,                                  /* version        */ 
     179    N_("User profile and away message management system"),/* summary        */ 
     180    /* description    */ 
     181    N_("Allows user to set up automatically updating\n" 
     182    "away messages and profiles that contain dynamic " 
     183    "text"), 
     184    /* author         */ 
     185    N_("Casey Ho <caseyho at berkeley-edu>" 
     186    "\n\t\t\taim:caseyho"), 
     187    N_("http://hkn.eecs.berkeley.edu/~casey/" 
     188    "autoprofile/"),                                   /* homepage       */ 
     189 
     190    plugin_load,                                          /* load           */ 
     191    plugin_unload,                                        /* unload         */ 
     192    NULL,                                                 /* destroy        */ 
     193 
     194    &ui_info,                                             /* ui_info        */ 
     195    NULL,                                                 /* extra_info     */ 
     196    NULL,                                                 /* prefs_info     */ 
     197    actions                                               /* actions        */ 
    196198}; 
    197199 
    198200/*-------------------------------------------------------------------------- 
    199  * CORE FUNCTIONS                                           
     201 * CORE FUNCTIONS 
    200202 *------------------------------------------------------------------------*/ 
    201203 
    202204/* The workhorse generation function ! */ 
    203205char *autoprofile_generate (const char *format) { 
    204   char *output, *single_char, *cur_addition, *cur_addition_copy; 
    205    
    206   GList *search_list; 
    207   struct component *cur_comp; 
    208   int space_left; 
    209   int state; 
    210  
    211   /* Set up strings */ 
    212   output = (char *)malloc (sizeof(char) * AP_SIZE_MAXIMUM); 
    213   *output = '\0'; 
    214   single_char = (char *)malloc(2); 
    215   *(single_char + 1) = '\0'; 
    216   *single_char = 'a'; 
    217  
    218   space_left = AP_SIZE_MAXIMUM - 1; 
    219  
    220   /* When previous char was a %, state is 1, otherwise 0 */ 
    221   state = 0; 
    222   /* Process the format string, one char at a time! */ 
    223   while (*format && space_left > 0) { 
    224     if (state == 1) { 
    225       /* Handle percentage value */ 
    226       if (*format == '%') { 
    227         /* Copy char straight over */ 
    228         *single_char = *format++; 
    229         strcat (output, single_char); 
    230         space_left--; 
    231       } else if (*format == 'a') { 
    232         /* Copy string in */ 
    233         cur_addition = (char *)gaim_prefs_get_string ( 
    234           "/plugins/gtk/autoprofile/added_text"); 
    235         if (strlen (cur_addition) < space_left) { 
    236           strcat (output, cur_addition); 
    237           space_left = space_left - strlen (cur_addition); 
    238         } else { 
    239           auto_debug ("generate", "added text too large, dropped"); 
    240         } 
    241         format++; 
    242       } else if (*format == 'n' || 
    243                  *format == 't' || 
    244                  *format == 'd') { 
    245         /* Copy %char straight over */ 
    246         if (space_left > 1) { 
    247           *single_char = '%'; 
    248           strcat (output, single_char); 
    249           *single_char = *format++; 
    250           strcat (output, single_char); 
    251           space_left = space_left - 2; 
    252         } 
    253       } else { 
    254         /* Generate some string associated with char */ 
    255         search_list = components; 
    256         while (TRUE) { 
    257           if (search_list == NULL) { 
    258             auto_debug ("generate", "no matching component found "); 
    259             if (space_left < 2) 
    260               break; 
    261             *single_char = '%'; 
    262             strcat (output, single_char); 
    263             *single_char = *format; 
    264             strcat (output, single_char); 
    265             space_left = space_left - 2; 
    266             break; 
    267           } else { 
    268             cur_comp = (struct component *)search_list->data; 
    269             if (cur_comp->format_char == *format) { 
    270               cur_addition = (cur_comp->generate)(); 
    271               /* Check for NULL component output */ 
    272               if (!cur_addition)  
    273                 break; 
    274               /* Insert <br> for \n to get more accurate size */ 
    275               cur_addition_copy = gaim_strdup_withhtml (cur_addition); 
    276               free (cur_addition); 
    277               if (strlen (cur_addition_copy) < space_left) { 
    278                 strcat (output, cur_addition_copy); 
    279                 space_left = space_left - strlen (cur_addition_copy); 
    280               } else { 
    281                 auto_debug ("generate", "component too large, dropped"); 
    282               } 
     206    char *output, *single_char, *cur_addition, *cur_addition_copy; 
    283207 
    284               free (cur_addition_copy); 
    285               break; 
     208    GList *search_list; 
     209    struct component *cur_comp; 
     210    int space_left; 
     211    int state; 
     212 
     213    /* Set up strings */ 
     214    output = (char *)malloc (sizeof(char) * AP_SIZE_MAXIMUM); 
     215    *output = '\0'; 
     216    single_char = (char *)malloc(2); 
     217    *(single_char + 1) = '\0'; 
     218    *single_char = 'a'; 
     219 
     220    space_left = AP_SIZE_MAXIMUM - 1; 
     221 
     222    /* When previous char was a %, state is 1, otherwise 0 */ 
     223    state = 0; 
     224    /* Process the format string, one char at a time! */ 
     225    while (*format && space_left > 0) { 
     226        if (state == 1) { 
     227            /* Handle percentage value */ 
     228            if (*format == '%') { 
     229                /* Copy char straight over */ 
     230                *single_char = *format++; 
     231                strcat (output, single_char); 
     232                space_left--; 
     233            } else if (*format == 'a') { 
     234                /* Copy string in */ 
     235                cur_addition = (char *)gaim_prefs_get_string ( 
     236                                   "/plugins/gtk/autoprofile/added_text"); 
     237                if (strlen (cur_addition) < space_left) { 
     238                    strcat (output, cur_addition); 
     239                    space_left = space_left - strlen (cur_addition); 
     240                } else { 
     241                    auto_debug ("generate", "added text too large, dropped"); 
     242                } 
     243                format++; 
     244            } else if (*format == 'n' || 
     245                       *format == 't' || 
     246                       *format == 'd') { 
     247                /* Copy %char straight over */ 
     248                if (space_left > 1) { 
     249                    *single_char = '%'; 
     250                    strcat (output, single_char); 
     251                    *single_char = *format++; 
     252                    strcat (output, single_char); 
     253                    space_left = space_left - 2; 
     254                } 
    286255            } else { 
    287               search_list = search_list->next; 
     256                /* Generate some string associated with char */ 
     257                search_list = components; 
     258                while (TRUE) { 
     259                    if (search_list == NULL) { 
     260                        auto_debug ("generate", "no matching component found "); 
     261                        if (space_left < 2) 
     262                            break; 
     263                        *single_char = '%'; 
     264                        strcat (output, single_char); 
     265                        *single_char = *format; 
     266                        strcat (output, single_char); 
     267                        space_left = space_left - 2; 
     268                        break; 
     269                    } else { 
     270                        cur_comp = (struct component *)search_list->data; 
     271                        if (cur_comp->format_char == *format) { 
     272                            cur_addition = (cur_comp->generate)(); 
     273                            /* Check for NULL component output */ 
     274                            if (!cur_addition) 
     275                                break; 
     276                            /* Insert <br> for \n to get more accurate size */ 
     277                            cur_addition_copy = gaim_strdup_withhtml (cur_addition); 
     278                            free (cur_addition); 
     279                            if (strlen (cur_addition_copy) < space_left) { 
     280                                strcat (output, cur_addition_copy); 
     281                                space_left = space_left - strlen (cur_addition_copy); 
     282                            } else { 
     283                                auto_debug ("generate", "component too large, dropped"); 
     284                            } 
     285 
     286                            free (cur_addition_copy); 
     287                            break; 
     288                        } else { 
     289                            search_list = search_list->next; 
     290 
     291                        } 
     292                    } 
     293                } 
    288294 
     295                format++; 
    289296            } 
    290           } 
    291         } 
    292     
    293         format++; 
    294       } 
    295       state = 0; 
    296     } else { 
    297       if (*format == '%') { 
    298         format++; 
    299         state = 1; 
    300       } else if (*format == '\n') { 
    301         if (space_left >= 4) { 
    302           strcat (output, "<br>"); 
    303           format++; 
    304           space_left = space_left - 4; 
     297            state = 0; 
    305298        } else { 
    306           break; 
     299            if (*format == '%') { 
     300                format++; 
     301                state = 1; 
     302            } else if (*format == '\n') { 
     303                if (space_left >= 4) { 
     304                    strcat (output, "<br>"); 
     305                    format++; 
     306                    space_left = space_left - 4; 
     307                } else { 
     308                    break; 
     309                } 
     310            } else { 
     311                *single_char = *format++; 
     312                strcat (output, single_char); 
     313                space_left--; 
     314            } 
    307315        } 
    308       } else { 
    309         *single_char = *format++;  
    310         strcat (output, single_char); 
    311         space_left--; 
    312       } 
    313     } 
    314   } 
    315  
    316   free (single_char); 
    317   auto_debug ("generate", "message created from components"); 
    318   return output; 
     316    } 
     317 
     318    free (single_char); 
     319    auto_debug ("generate", "message created from components"); 
     320    return output; 
    319321} 
    320322 
    321323/* Change status to away */ 
    322 gboolean status_away () 
    323 { 
    324   GList *accounts; 
    325   int interval; 
    326   GaimAccount *current; 
    327  
    328   if (gaim_prefs_get_bool ("/plugins/gtk/autoprofile/queue_messages_when_away")) { 
    329     gaim_prefs_set_string ("/gaim/gtk/conversations/im/hide_new", "away"); 
    330   } else { 
    331     gaim_prefs_set_string ("/gaim/gtk/conversations/im/hide_new", "never"); 
    332   } 
    333  
    334   /* Make sure at least one account is activated */ 
    335   accounts = gaim_accounts_get_all (); 
     324gboolean status_away () { 
     325    GList *accounts; 
     326    int interval; 
     327    GaimAccount *current; 
    336328 
    337   while (TRUE) { 
    338     if (accounts == NULL) { 
    339       gaim_notify_error (NULL, NULL, 
    340         _("No accounts have been activated to go away"), 
    341         _("Toggle the desired accounts under the accounts tab in " 
    342           "AutoProfile preferences")); 
    343       status_back (); 
    344       return FALSE; 
    345     } 
    346     current = (GaimAccount *)accounts->data; 
    347     if (gaim_account_is_connected (current) &&  
    348         get_account_boolean (current, "enable_away")) 
    349       break; 
    350     accounts = accounts->next; 
    351   } 
    352  
    353   interval = 60 * 1000 * gaim_prefs_get_int ( 
    354     "/plugins/gtk/autoprofile/delay_away"); 
    355  
    356   /* Disable troublesome variable values */ 
    357   if (!is_away) { 
    358     original_autoreply = strdup (gaim_prefs_get_string ( 
    359       "/core/away/auto_reply")); 
    360     if (!strcmp (original_autoreply, "never")) { 
    361       original_autoresponse = FALSE; 
     329    if (gaim_prefs_get_bool ("/plugins/gtk/autoprofile/queue_messages_when_away")) { 
     330        gaim_prefs_set_string ("/gaim/gtk/conversations/im/hide_new", "away"); 
    362331    } else { 
    363       original_autoresponse = TRUE; 
     332        gaim_prefs_set_string ("/gaim/gtk/conversations/im/hide_new", "never"); 
    364333    } 
    365   } 
    366334 
    367   gaim_prefs_set_string ("/core/away/auto_reply", "never"); 
     335    /* Make sure at least one account is activated */ 
     336    accounts = gaim_accounts_get_all (); 
    368337 
    369   is_away = TRUE; 
    370   if (away_timeout)  
    371     g_source_remove (away_timeout); 
    372   away_timeout = g_timeout_add (interval, away_update, NULL); 
    373   away_update (NULL);  
     338    while (TRUE) { 
     339        if (accounts == NULL) { 
     340            gaim_notify_error (NULL, NULL, 
     341                               _("No accounts have been activated to go away"), 
     342                               _("Toggle the desired accounts under the accounts tab in " 
     343                                 "AutoProfile preferences")); 
     344            status_back (); 
     345            return FALSE; 
     346        } 
     347        current = (GaimAccount *)accounts->data; 
     348        if (gaim_account_is_connected (current) && 
     349                get_account_boolean (current, "enable_away")) 
     350            break; 
     351        accounts = accounts->next; 
     352    } 
    374353 
    375   return TRUE; 
     354    interval = 60 * 1000 * gaim_prefs_get_int ( 
     355                   "/plugins/gtk/autoprofile/delay_away"); 
     356 
     357    /* Disable troublesome variable values */ 
     358    if (!is_away) { 
     359        original_autoreply = strdup (gaim_prefs_get_string ( 
     360                                         "/purple/away/auto_reply")); 
     361        if (!strcmp (original_autoreply, "never")) { 
     362            original_autoresponse = FALSE; 
     363        } else { 
     364            original_autoresponse = TRUE; 
     365        } 
     366    } 
     367 
     368    gaim_prefs_set_string ("/purple/away/auto_reply", "never"); 
     369 
     370    is_away = TRUE; 
     371    if (away_timeout) 
     372        g_source_remove (away_timeout); 
     373    away_timeout = g_timeout_add (interval, away_update, NULL); 
     374    away_update (NULL); 
     375 
     376    return TRUE; 
    376377} 
    377378 
    378379/* Change status to back */ 
    379 void status_back () 
    380 { 
    381   GList *tmp; 
    382   struct auto_response *p; 
    383  
    384   gaim_prefs_set_string ("/gaim/gtk/conversations/im/hide_new", "never"); 
    385  
    386   is_away = FALSE; 
    387   gaim_prefs_set_int ("/plugins/gtk/autoprofile/current_away", -1); 
    388  
    389   /* Restore original preferences */ 
    390   if (original_autoreply) {