From: Piotr S. <ps...@us...> - 2009-09-17 12:05:39
|
Update of /cvsroot/ayttm/ayttm/modules/utility In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12682/modules/utility Modified Files: autotrans.c custom_message.c middle.c notes.c rainbow.c Log Message: reformatted source code Index: autotrans.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/utility/autotrans.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- autotrans.c 19 Aug 2009 04:07:04 -0000 1.16 +++ autotrans.c 17 Sep 2009 12:04:59 -0000 1.17 @@ -41,29 +41,26 @@ #include "llist.h" #include "platform_defs.h" - /* already declared in dialog.h - but that uses gtk */ -void do_list_dialog(char * message, char * title, char **list, - void (*action) (char *text, gpointer data), - gpointer data); - +void do_list_dialog(char *message, char *title, char **list, + void (*action) (char *text, gpointer data), gpointer data); + /******************************************************************************* * Begin Module Code ******************************************************************************/ /* Module defines */ #ifndef USE_POSIX_DLOPEN - #define plugin_info autotrans_LTX_plugin_info - #define module_version autotrans_LTX_module_version +#define plugin_info autotrans_LTX_plugin_info +#define module_version autotrans_LTX_module_version #endif - /* Function Prototypes */ -static char *translate_out(const eb_local_account * local, const eb_account * remote, - const struct contact *contact, const char * s); +static char *translate_out(const eb_local_account *local, + const eb_account *remote, const struct contact *contact, const char *s); static int trans_init(); static int trans_finish(); -static void language_select(ebmCallbackData * data); +static void language_select(ebmCallbackData *data); static int doTrans = 0; static int myLanguage = 0; @@ -74,7 +71,6 @@ static int ref_count = 0; - /* Module Exports */ PLUGIN_INFO plugin_info = { PLUGIN_FILTER, @@ -87,9 +83,13 @@ trans_finish, NULL }; + /* End Module Exports */ -unsigned int module_version() {return CORE_VERSION;} +unsigned int module_version() +{ + return CORE_VERSION; +} static int trans_init() { @@ -119,9 +119,9 @@ il->name = "myLanguage"; il->label = _("My language code:"); { - LList *l=NULL; + LList *l = NULL; int i; - for(i=0; languages[i]; i++) + for (i = 0; languages[i]; i++) l = l_list_append(l, languages[i]); il->widget.listbox.list = l; @@ -130,21 +130,27 @@ eb_debug(DBG_MOD, "Auto-trans initialised\n"); - outgoing_message_filters = l_list_prepend(outgoing_message_filters, &translate_out); - incoming_message_filters = l_list_append(incoming_message_filters, &translate_out); + outgoing_message_filters = + l_list_prepend(outgoing_message_filters, &translate_out); + incoming_message_filters = + l_list_append(incoming_message_filters, &translate_out); /* the following is adapted from notes.c */ if ((tag1 = eb_add_menu_item(_("Set Language"), EB_CHAT_WINDOW_MENU, - language_select, ebmCONTACTDATA, NULL)) == NULL) { - eb_debug(DBG_MOD, "Error! Unable to add Language menu to chat window menu\n"); + language_select, ebmCONTACTDATA, + NULL)) == NULL) { + eb_debug(DBG_MOD, + "Error! Unable to add Language menu to chat window menu\n"); return (-1); } if ((tag2 = eb_add_menu_item(_("Set Language"), EB_CONTACT_MENU, - language_select, ebmCONTACTDATA, NULL)) == NULL) { + language_select, ebmCONTACTDATA, + NULL)) == NULL) { eb_remove_menu_item(EB_CHAT_WINDOW_MENU, tag1); - eb_debug(DBG_MOD, "Error! Unable to add Language menu to contact menu\n"); + eb_debug(DBG_MOD, + "Error! Unable to add Language menu to contact menu\n"); return (-1); } @@ -156,12 +162,14 @@ int result = 0; eb_debug(DBG_MOD, "Auto-trans shutting down\n"); - outgoing_message_filters = l_list_remove(outgoing_message_filters, &translate_out); - incoming_message_filters = l_list_remove(incoming_message_filters, &translate_out); - - while(plugin_info.prefs) { + outgoing_message_filters = + l_list_remove(outgoing_message_filters, &translate_out); + incoming_message_filters = + l_list_remove(incoming_message_filters, &translate_out); + + while (plugin_info.prefs) { input_list *il = plugin_info.prefs->next; - if(il && il->type==EB_INPUT_LIST) + if (il && il->type == EB_INPUT_LIST) l_list_free(il->widget.listbox.list); free(plugin_info.prefs); plugin_info.prefs = il; @@ -171,12 +179,14 @@ result = eb_remove_menu_item(EB_CHAT_WINDOW_MENU, tag1); if (result) { - g_warning("Unable to remove Language menu item from chat window menu!"); + g_warning + ("Unable to remove Language menu item from chat window menu!"); return (-1); } result = eb_remove_menu_item(EB_CONTACT_MENU, tag2); if (result) { - g_warning("Unable to remove Language menu item from chat window menu!"); + g_warning + ("Unable to remove Language menu item from chat window menu!"); return (-1); } @@ -188,7 +198,7 @@ ******************************************************************************/ static void language_selected(char *text, gpointer data) { - struct contact *cont = (struct contact *) data; + struct contact *cont = (struct contact *)data; cont->language[0] = text[0]; cont->language[1] = text[1]; @@ -197,19 +207,20 @@ write_contact_list(); if (!doTrans) { - ay_do_warning( _("Auto-Translation Warning"), _("You have just selected a language " - "with which to talk to a buddy. This will " - "only affect you if you have the auto-translator" - "plugin turned on. If you do, beware that it will" - "hang each time you send or receive a message, for" - "the time it takes to contact BabelFish. This can" - "take several seconds.") ); + ay_do_warning(_("Auto-Translation Warning"), + _("You have just selected a language " + "with which to talk to a buddy. This will " + "only affect you if you have the auto-translator" + "plugin turned on. If you do, beware that it will" + "hang each time you send or receive a message, for" + "the time it takes to contact BabelFish. This can" + "take several seconds.")); } } -static void language_select(ebmCallbackData * data) +static void language_select(ebmCallbackData *data) { - ebmContactData *ecd = (ebmContactData *) data; + ebmContactData *ecd = (ebmContactData *)data; struct contact *cont; char buf[1024]; @@ -219,11 +230,12 @@ return; } - g_snprintf(buf, 1024, _("Select the code for the language to use when talking to %s"), - cont->nick); + g_snprintf(buf, 1024, + _("Select the code for the language to use when talking to %s"), + cont->nick); do_list_dialog(buf, _("Select Language"), languages, - &language_selected, (gpointer) cont); + &language_selected, (gpointer) cont); } /* @@ -237,14 +249,14 @@ int i = 0; unsigned int n; char *result = NULL; - result = (char *) malloc(strlen(in) + 1); + result = (char *)malloc(strlen(in) + 1); /* convert a string from UTF-8 Format */ for (n = 0; n < strlen(in); n++) { unsigned char c = in[n]; if (c < 128) { - result[i++] = (char) c; + result[i++] = (char)c; } else { result[i++] = (c << 6) | (in[++n] & 63); } @@ -260,35 +272,36 @@ static char *trans_urlencode(const char *instr) { - int ipos=0, bpos=0; + int ipos = 0, bpos = 0; char *str = NULL; int len = strlen(instr); - if(!(str = malloc(sizeof(char) * (3*len + 1)) )) + if (!(str = malloc(sizeof(char) * (3 * len + 1)))) return strdup(""); - while(instr[ipos]) { - while(isurlchar(instr[ipos])) + while (instr[ipos]) { + while (isurlchar(instr[ipos])) str[bpos++] = instr[ipos++]; - if(!instr[ipos]) + if (!instr[ipos]) break; - - snprintf(&str[bpos], 4, "%%%.2x", - (instr[ipos]=='\r' || instr[ipos]=='\n'? - ' ':instr[ipos])); - bpos+=3; + + snprintf(&str[bpos], 4, "%%%.2x", + (instr[ipos] == '\r' || instr[ipos] == '\n' ? + ' ' : instr[ipos])); + bpos += 3; ipos++; } - str[bpos]='\0'; + str[bpos] = '\0'; /* free extra alloc'ed mem. */ len = strlen(str); - str = realloc(str, sizeof(char) * (len+1)); + str = realloc(str, sizeof(char) * (len + 1)); return str; } -static int do_http_post(const char *host, const char *path, const char *enc_data) +static int do_http_post(const char *host, const char *path, + const char *enc_data) { char buff[1024]; int fd; @@ -297,13 +310,12 @@ if (fd > 0) { snprintf(buff, sizeof(buff), - "POST %s HTTP/1.1\r\n" - "Host: %s\r\n" - "User-Agent: Mozilla/4.5 [en] (%s/%s)\r\n" - "Content-type: application/x-www-form-urlencoded\r\n" - "Content-length: %d\r\n" - "\r\n", - path, host, PACKAGE, VERSION, strlen(enc_data)); + "POST %s HTTP/1.1\r\n" + "Host: %s\r\n" + "User-Agent: Mozilla/4.5 [en] (%s/%s)\r\n" + "Content-type: application/x-www-form-urlencoded\r\n" + "Content-length: %d\r\n" + "\r\n", path, host, PACKAGE, VERSION, strlen(enc_data)); write(fd, buff, strlen(buff)); write(fd, enc_data, strlen(enc_data)); @@ -314,40 +326,39 @@ #define START_POS "<input type=hidden name=\"q\" value=\"" #define END_POS "\">" -static char *doTranslate(const char * ostring, const char * from, const char * to) +static char *doTranslate(const char *ostring, const char *from, const char *to) { char buf[2048]; int fd; - int offset=0; + int offset = 0; char *string; char *result; string = trans_urlencode(ostring); - snprintf(buf, 2048, "tt=urltext&lp=%s_%s&urltext=%s", - from, to, string); + snprintf(buf, 2048, "tt=urltext&lp=%s_%s&urltext=%s", from, to, string); free(string); fd = do_http_post("babelfish.altavista.com", "/babelfish/tr", buf); - while((ay_tcp_readline(buf+offset, sizeof(buf)-offset, fd)) > 0) { + while ((ay_tcp_readline(buf + offset, sizeof(buf) - offset, fd)) > 0) { char *end, *start = strstr(buf, START_POS); - offset=0; - if(!start) + offset = 0; + if (!start) continue; - + start += strlen(START_POS); end = strstr(start, END_POS); - if(end) { - *end='\0'; + if (end) { + *end = '\0'; string = start; break; } else { /* append next line */ offset = strlen(buf); } - + } - + eb_debug(DBG_MOD, "Translated %s to %s\n", ostring, string); result = Utf8ToStr(string); @@ -355,8 +366,8 @@ return result; } -static char *translate_out(const eb_local_account * local, const eb_account * remote, - const struct contact *contact, const char * s) +static char *translate_out(const eb_local_account *local, + const eb_account *remote, const struct contact *contact, const char *s) { char *p; char l[3]; @@ -369,7 +380,7 @@ } // no translation strncpy(l, languages[myLanguage], 2); - l[2]=0; + l[2] = 0; if (!strcmp(contact->language, l)) { return strdup(s); } // speak same language Index: custom_message.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/utility/custom_message.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- custom_message.c 27 Jul 2009 16:42:04 -0000 1.3 +++ custom_message.c 17 Sep 2009 12:04:59 -0000 1.4 @@ -42,26 +42,25 @@ ******************************************************************************/ /* Module defines */ #ifndef USE_POSIX_DLOPEN - #define plugin_info custmsg_LTX_plugin_info - #define plugin_init custmsg_LTX_plugin_init - #define plugin_finish custmsg_LTX_plugin_finish - #define module_version custmsg_LTX_module_version +#define plugin_info custmsg_LTX_plugin_info +#define plugin_init custmsg_LTX_plugin_init +#define plugin_finish custmsg_LTX_plugin_finish +#define module_version custmsg_LTX_module_version #endif - /* Function Prototypes */ /* ebmCallbackData is a parent struct, the child of which will be an ebmContactData */ static int plugin_init(); static int plugin_finish(); -static int eb_custom_msg_timeout_callback(void * data); +static int eb_custom_msg_timeout_callback(void *data); -static int ref_count=0; +static int ref_count = 0; /* Module Exports */ PLUGIN_INFO plugin_info = { - PLUGIN_UTILITY, - "Custom Message", - "Pick a custom away message from a file", + PLUGIN_UTILITY, + "Custom Message", + "Pick a custom away message from a file", "$Revision$", "$Date$", &ref_count, @@ -69,17 +68,21 @@ plugin_finish, NULL }; + /* End Module Exports */ -unsigned int module_version() {return CORE_VERSION;} +unsigned int module_version() +{ + return CORE_VERSION; +} static char custom_away_msg[MAX_PREF_LEN]; -static int enable_plugin=0; -static int custom_msg_tag=0; +static int enable_plugin = 0; +static int custom_msg_tag = 0; static int plugin_init() { - input_list * il = calloc(1, sizeof(input_list)); + input_list *il = calloc(1, sizeof(input_list)); plugin_info.prefs = il; il->widget.entry.value = custom_away_msg; @@ -91,22 +94,22 @@ il = il->next; il->widget.checkbox.value = &enable_plugin; il->name = "enable_plugin"; - il->label= _("_Automatically update status:"); + il->label = _("_Automatically update status:"); il->type = EB_INPUT_CHECKBOX; - custom_msg_tag = eb_timeout_add(5 * 1000, - (void *) eb_custom_msg_timeout_callback, 0); + custom_msg_tag = eb_timeout_add(5 * 1000, + (void *)eb_custom_msg_timeout_callback, 0); return 0; } static int plugin_finish() { - if(custom_msg_tag) { + if (custom_msg_tag) { eb_timeout_remove(custom_msg_tag); - custom_msg_tag=0; + custom_msg_tag = 0; } - while(plugin_info.prefs) { + while (plugin_info.prefs) { input_list *il = plugin_info.prefs->next; free(plugin_info.prefs); plugin_info.prefs = il; @@ -123,12 +126,12 @@ { LList *list; - for (list = accounts; list; list = list->next) - { + for (list = accounts; list; list = list->next) { eb_local_account *ela = list->data; /* Only change state for those accounts which are connected */ - if(ela->connected) - eb_services[ela->service_id].sc->set_away(ela, a_message, 0); + if (ela->connected) + eb_services[ela->service_id].sc->set_away(ela, + a_message, 0); } } @@ -139,24 +142,24 @@ int fd, n, i; char buf[1024]; - if(!enable_plugin) - return 1; + if (!enable_plugin) + return 1; - if( !custom_away_msg[0] ) + if (!custom_away_msg[0]) return 1; stat(custom_away_msg, &s); - if(file_time >= s.st_mtime) + if (file_time >= s.st_mtime) return 1; file_time = s.st_mtime; fd = open(custom_away_msg, O_RDONLY); - n=read(fd, buf, sizeof(buf)-1); - buf[n]=0; - for(i=n-1; buf[i]=='\n'; i--) - buf[i]=0; + n = read(fd, buf, sizeof(buf) - 1); + buf[n] = 0; + for (i = n - 1; buf[i] == '\n'; i--) + buf[i] = 0; close(fd); @@ -164,5 +167,3 @@ return 1; } - - Index: middle.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/utility/middle.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- middle.c 27 Jul 2009 16:42:04 -0000 1.11 +++ middle.c 17 Sep 2009 12:04:59 -0000 1.12 @@ -42,27 +42,25 @@ ******************************************************************************/ /* Module defines */ #ifndef USE_POSIX_DLOPEN - #define plugin_info middle_LTX_plugin_info - #define plugin_init middle_LTX_plugin_init - #define plugin_finish middle_LTX_plugin_finish - #define module_version middle_LTX_module_version +#define plugin_info middle_LTX_plugin_info +#define plugin_init middle_LTX_plugin_init +#define plugin_finish middle_LTX_plugin_finish +#define module_version middle_LTX_module_version #endif - /* Function Prototypes */ -static char *plstripHTML(const eb_local_account * local, const eb_account * remote, - const struct contact *contact, const char *s); -static int middle_init( void ); -static int middle_finish( void ); +static char *plstripHTML(const eb_local_account *local, + const eb_account *remote, const struct contact *contact, const char *s); +static int middle_init(void); +static int middle_finish(void); -static int s_doLeet = 0; -static int s_doExtremeLeet = 0; +static int s_doLeet = 0; +static int s_doExtremeLeet = 0; -static int s_ref_count = 0; +static int s_ref_count = 0; /* Module Exports */ -PLUGIN_INFO plugin_info = -{ +PLUGIN_INFO plugin_info = { PLUGIN_FILTER, "L33t-o-matic", "Turns all incoming and outgoing messages into l33t-speak", @@ -73,161 +71,177 @@ middle_finish, NULL }; + /* End Module Exports */ -unsigned int module_version() {return CORE_VERSION;} +unsigned int module_version() +{ + return CORE_VERSION; +} -static int middle_init( void ) +static int middle_init(void) { - input_list *il = calloc( 1, sizeof(input_list) ); + input_list *il = calloc(1, sizeof(input_list)); plugin_info.prefs = il; il->widget.checkbox.value = &s_doLeet; il->name = "s_doLeet"; - il->label = strdup( _("Enable L33t-speak conversion") ); + il->label = strdup(_("Enable L33t-speak conversion")); il->type = EB_INPUT_CHECKBOX; - - il->next = calloc( 1, sizeof(input_list) ); + + il->next = calloc(1, sizeof(input_list)); il = il->next; il->widget.checkbox.value = &s_doExtremeLeet; il->name = "s_doExtremeLeet"; - il->label = strdup( _("Enable 3x7r3m3 L33t-speak [implies previous]") ); + il->label = strdup(_("Enable 3x7r3m3 L33t-speak [implies previous]")); il->type = EB_INPUT_CHECKBOX; eb_debug(DBG_MOD, "L33tSp33k initialised\n"); - outgoing_message_filters = l_list_prepend( outgoing_message_filters, &plstripHTML ); - incoming_message_filters = l_list_append( incoming_message_filters, &plstripHTML ); + outgoing_message_filters = + l_list_prepend(outgoing_message_filters, &plstripHTML); + incoming_message_filters = + l_list_append(incoming_message_filters, &plstripHTML); - return( 0 ); + return (0); } -static int middle_finish( void ) +static int middle_finish(void) { eb_debug(DBG_MOD, "L33tSp33k shutting down\n"); - outgoing_message_filters = l_list_remove( outgoing_message_filters, &plstripHTML ); - incoming_message_filters = l_list_remove( incoming_message_filters, &plstripHTML ); - - while( plugin_info.prefs ) - { + outgoing_message_filters = + l_list_remove(outgoing_message_filters, &plstripHTML); + incoming_message_filters = + l_list_remove(incoming_message_filters, &plstripHTML); + + while (plugin_info.prefs) { input_list *il = plugin_info.prefs->next; - free( plugin_info.prefs ); + free(plugin_info.prefs); plugin_info.prefs = il; } - return( 0 ); + return (0); } /******************************************************************************* * End Module Code ******************************************************************************/ -static char *plstripHTML(const eb_local_account * local, const eb_account * remote, - const struct contact *contact, const char *in) +static char *plstripHTML(const eb_local_account *local, + const eb_account *remote, const struct contact *contact, const char *in) { - int pos = 0; - int post = 0; - char *s = strdup(in); - char *t = NULL; - - - if ( !s_doLeet && !s_doExtremeLeet ) - return( s ); - - t = calloc( 3, strlen( s ) ); - - while ( s[pos] != '\0' ) - { - switch ( s[pos] ) - { - case 'a': case 'A': - t[post] = '4'; - break; - - case 'c': case 'C': - t[post] = '('; - break; - - case 'e': case 'E': - t[post] = '3'; - break; - - case 'l': case 'L': - t[post] = '1'; - break; - - case 's': case 'S': - t[post] = '5'; - break; - - case 't': case 'T': - t[post] = '7'; + int pos = 0; + int post = 0; + char *s = strdup(in); + char *t = NULL; + + if (!s_doLeet && !s_doExtremeLeet) + return (s); + + t = calloc(3, strlen(s)); + + while (s[pos] != '\0') { + switch (s[pos]) { + case 'a': + case 'A': + t[post] = '4'; + break; + + case 'c': + case 'C': + t[post] = '('; + break; + + case 'e': + case 'E': + t[post] = '3'; + break; + + case 'l': + case 'L': + t[post] = '1'; + break; + + case 's': + case 'S': + t[post] = '5'; + break; + + case 't': + case 'T': + t[post] = '7'; + break; + + default: + t[post] = s[pos]; + break; + } + + if (s_doExtremeLeet) { + switch (s[pos]) { + case 'd': + case 'D': + t[post++] = '|'; + t[post] = ')'; break; - - default: - t[post] = s[pos]; + + case 'h': + case 'H': + t[post++] = '|'; + t[post++] = '-'; + t[post] = '|'; + break; + + case 'k': + case 'K': + t[post++] = '|'; + t[post] = '<'; + break; + + case 'm': + case 'M': + t[post++] = '/'; + t[post++] = 'v'; + t[post] = '\\'; + break; + + case 'n': + case 'N': + t[post++] = '|'; + t[post++] = '\\'; + t[post] = '|'; + break; + + case 'o': + case 'O': + t[post++] = '('; + t[post] = ')'; + break; + + case 'v': + case 'V': + t[post++] = '\\'; + t[post] = '/'; break; - } - - if ( s_doExtremeLeet ) - { - switch ( s[pos] ) - { - case 'd': case 'D': - t[post++] = '|'; - t[post] = ')'; - break; - - case 'h': case 'H': - t[post++] = '|'; - t[post++] ='-'; - t[post] ='|'; - break; - - case 'k': case 'K': - t[post++] = '|'; - t[post] ='<'; - break; - - case 'm': case 'M': - t[post++] = '/'; - t[post++] = 'v'; - t[post] = '\\'; - break; - - case 'n': case 'N': - t[post++] = '|'; - t[post++] = '\\'; - t[post] = '|'; - break; - - case 'o': case 'O': - t[post++] = '('; - t[post] = ')'; - break; - - case 'v': case 'V': - t[post++] = '\\'; - t[post] = '/'; - break; - - case 'w': case 'W': - t[post++] = '\\'; - t[post++] = '^'; - t[post] = '/'; - break; - default: - break; + case 'w': + case 'W': + t[post++] = '\\'; + t[post++] = '^'; + t[post] = '/'; + break; + + default: + break; } } - + pos++; post++; } - + t[post] = '\0'; - - free( s ); - - return( t ); + + free(s); + + return (t); } Index: notes.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/utility/notes.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- notes.c 27 Jul 2009 16:42:04 -0000 1.14 +++ notes.c 17 Sep 2009 12:04:59 -0000 1.15 @@ -43,12 +43,11 @@ #define NAME_MAX 512 #endif - static char notes_dir[NAME_MAX]; #ifdef __MINGW32__ -static char notes_editor[MAX_PREF_LEN]="notepad"; +static char notes_editor[MAX_PREF_LEN] = "notepad"; #else -static char notes_editor[MAX_PREF_LEN]="xedit"; +static char notes_editor[MAX_PREF_LEN] = "xedit"; #endif /******************************************************************************* @@ -56,26 +55,25 @@ ******************************************************************************/ /* Module defines */ #ifndef USE_POSIX_DLOPEN - #define plugin_info notes_LTX_plugin_info - #define plugin_init notes_LTX_plugin_init - #define plugin_finish notes_LTX_plugin_finish - #define module_version notes_LTX_module_version +#define plugin_info notes_LTX_plugin_info +#define plugin_init notes_LTX_plugin_init +#define plugin_finish notes_LTX_plugin_finish +#define module_version notes_LTX_module_version #endif - /* Function Prototypes */ /* ebmCallbackData is a parent struct, the child of which will be an ebmContactData */ static void notes_feature(ebmCallbackData *data); static int plugin_init(); static int plugin_finish(); -static int ref_count=0; +static int ref_count = 0; /* Module Exports */ PLUGIN_INFO plugin_info = { - PLUGIN_UTILITY, - "Notes", - "Store notes about your contacts and buddies", + PLUGIN_UTILITY, + "Notes", + "Store notes about your contacts and buddies", "$Revision$", "$Date$", &ref_count, @@ -83,19 +81,23 @@ plugin_finish, NULL }; + /* End Module Exports */ -static void *notes_tag1=NULL; -static void *notes_tag2=NULL; +static void *notes_tag1 = NULL; +static void *notes_tag2 = NULL; -unsigned int module_version() {return CORE_VERSION;} +unsigned int module_version() +{ + return CORE_VERSION; +} /* 929347 */ static void rename_notes(char *onick, char *nnick) { char cmd1[1024]; char cmd2[1024]; - if (strcmp(onick,nnick) == 0) + if (strcmp(onick, nnick) == 0) return; eb_debug(DBG_MOD, "> Rename %s to %s\n", onick, nnick); snprintf(cmd1, 1024, "%s/%s", notes_dir, onick); @@ -106,20 +108,26 @@ static int plugin_init() { - input_list * il = calloc(1, sizeof(input_list)); - int result=0; + input_list *il = calloc(1, sizeof(input_list)); + int result = 0; eb_debug(DBG_MOD, "notes init\n"); - notes_tag1=eb_add_menu_item("Notes", EB_CHAT_WINDOW_MENU, notes_feature, ebmCONTACTDATA, NULL); - if(!notes_tag1) { - eb_debug(DBG_MOD, "Error! Unable to add Notes menu to chat window menu\n"); - return(-1); - } - notes_tag2=eb_add_menu_item("Notes", EB_CONTACT_MENU, notes_feature, ebmCONTACTDATA, NULL); - if(!notes_tag2) { - result=eb_remove_menu_item(EB_CHAT_WINDOW_MENU, notes_tag1); - eb_debug(DBG_MOD, "Error! Unable to add Notes menu to contact menu\n"); - return(-1); + notes_tag1 = + eb_add_menu_item("Notes", EB_CHAT_WINDOW_MENU, notes_feature, + ebmCONTACTDATA, NULL); + if (!notes_tag1) { + eb_debug(DBG_MOD, + "Error! Unable to add Notes menu to chat window menu\n"); + return (-1); + } + notes_tag2 = + eb_add_menu_item("Notes", EB_CONTACT_MENU, notes_feature, + ebmCONTACTDATA, NULL); + if (!notes_tag2) { + result = eb_remove_menu_item(EB_CHAT_WINDOW_MENU, notes_tag1); + eb_debug(DBG_MOD, + "Error! Unable to add Notes menu to contact menu\n"); + return (-1); } snprintf(notes_dir, NAME_MAX, "%s/notes", eb_config_dir()); mkdir(notes_dir, 0700); @@ -130,33 +138,35 @@ il->label = _("Notes Editor:"); il->type = EB_INPUT_ENTRY; /* 929347 */ - nick_modify_utility = l_list_append(nick_modify_utility,&rename_notes); - return(0); + nick_modify_utility = l_list_append(nick_modify_utility, &rename_notes); + return (0); } static int plugin_finish() { - int result=0; - - while(plugin_info.prefs) { + int result = 0; + + while (plugin_info.prefs) { input_list *il = plugin_info.prefs->next; free(plugin_info.prefs); plugin_info.prefs = il; } - result=eb_remove_menu_item(EB_CHAT_WINDOW_MENU, notes_tag1); - if(result) { - eb_debug(DBG_MOD, "Unable to remove Notes menu item from chat window menu!\n"); - return(-1); - } - result=eb_remove_menu_item(EB_CONTACT_MENU, notes_tag2); - if(result) { - eb_debug(DBG_MOD, "Unable to remove Notes menu item from chat window menu!\n"); - return(-1); + result = eb_remove_menu_item(EB_CHAT_WINDOW_MENU, notes_tag1); + if (result) { + eb_debug(DBG_MOD, + "Unable to remove Notes menu item from chat window menu!\n"); + return (-1); + } + result = eb_remove_menu_item(EB_CONTACT_MENU, notes_tag2); + if (result) { + eb_debug(DBG_MOD, + "Unable to remove Notes menu item from chat window menu!\n"); + return (-1); } /* 929347 */ - nick_modify_utility = l_list_remove(nick_modify_utility,&rename_notes); - return(0); + nick_modify_utility = l_list_remove(nick_modify_utility, &rename_notes); + return (0); } /******************************************************************************* @@ -166,7 +176,7 @@ /* We're really going to get back an ebmContactData object */ static void notes_feature(ebmCallbackData *data) { - ebmContactData *ecd=NULL; + ebmContactData *ecd = NULL; char buff[256]; char cmd_buff[1024]; #ifndef __MINGW32__ @@ -174,13 +184,15 @@ #endif eb_debug(DBG_MOD, ">\n"); - if(IS_ebmContactData(data)) - ecd=(ebmContactData *)data; - else { /* This should never happen, unless something is horribly wrong */ - eb_debug(DBG_MOD, "*** Warning *** Unexpected ebmCallbackData type returned!\n"); + if (IS_ebmContactData(data)) + ecd = (ebmContactData *)data; + else { /* This should never happen, unless something is horribly wrong */ + eb_debug(DBG_MOD, + "*** Warning *** Unexpected ebmCallbackData type returned!\n"); return; } - eb_debug(DBG_MOD, "contact: %s remote_account: %s\n", ecd->contact, ecd->remote_account); + eb_debug(DBG_MOD, "contact: %s remote_account: %s\n", ecd->contact, + ecd->remote_account); snprintf(buff, 255, "Notes on %s", ecd->contact); snprintf(cmd_buff, 1023, "%s/%s", notes_dir, ecd->contact); Index: rainbow.c =================================================================== RCS file: /cvsroot/ayttm/ayttm/modules/utility/rainbow.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- rainbow.c 27 Jul 2009 16:42:04 -0000 1.9 +++ rainbow.c 17 Sep 2009 12:04:59 -0000 1.10 @@ -36,24 +36,21 @@ #include "prefs.h" #include "platform_defs.h" - /******************************************************************************* * Begin Module Code ******************************************************************************/ /* Module defines */ #ifndef USE_POSIX_DLOPEN - #define plugin_info rainbow_LTX_plugin_info - #define plugin_init rainbow_LTX_plugin_init - #define plugin_finish rainbow_LTX_plugin_finish - #define module_version rainbow_LTX_module_version +#define plugin_info rainbow_LTX_plugin_info +#define plugin_init rainbow_LTX_plugin_init +#define plugin_finish rainbow_LTX_plugin_finish +#define module_version rainbow_LTX_module_version #endif - /* Function Prototypes */ /* ebmCallbackData is a parent struct, the child of which will be an ebmContactData */ -static char *dorainbow(const eb_local_account * local, - const eb_account * remote, - const struct contact *contact, const char *s); +static char *dorainbow(const eb_local_account *local, + const eb_account *remote, const struct contact *contact, const char *s); static int rainbow_init(); static int rainbow_finish(); @@ -68,8 +65,10 @@ static char send_b[MAX_PREF_LEN] = "255"; static char *html_tags[] = - { "html", "body", "font", "p", "i", "b", "u", "img", "a", "br", "hr", -"head" }; + { "html", "body", "font", "p", "i", "b", "u", "img", "a", "br", "hr", + "head" +}; + static int num_tags = 12; static int ref_count = 0; @@ -86,9 +85,13 @@ rainbow_finish, NULL }; + /* End Module Exports */ -unsigned int module_version() {return CORE_VERSION;} +unsigned int module_version() +{ + return CORE_VERSION; +} static int rainbow_init() { @@ -141,7 +144,7 @@ eb_debug(DBG_MOD, "Rainbow initialised\n"); outgoing_message_filters = - l_list_append(outgoing_message_filters, &dorainbow); + l_list_append(outgoing_message_filters, &dorainbow); return 0; } @@ -150,9 +153,9 @@ { eb_debug(DBG_MOD, "Rainbow shutting down\n"); outgoing_message_filters = - l_list_remove(outgoing_message_filters, &dorainbow); - - while(plugin_info.prefs) { + l_list_remove(outgoing_message_filters, &dorainbow); + + while (plugin_info.prefs) { input_list *il = plugin_info.prefs->next; free(plugin_info.prefs); plugin_info.prefs = il; @@ -164,9 +167,8 @@ /******************************************************************************* * End Module Code ******************************************************************************/ -static char *dorainbow(const eb_local_account * local, - const eb_account * remote, - const struct contact *contact, const char *s) +static char *dorainbow(const eb_local_account *local, + const eb_account *remote, const struct contact *contact, const char *s) { char *retval; char *wptr; @@ -214,8 +216,8 @@ } // strip space before HTML tag for (a = 0; a < num_tags; a++) { if (!strncasecmp - (s + p2, html_tags[a], - strlen(html_tags[a]))) { + (s + p2, html_tags[a], + strlen(html_tags[a]))) { found = 1; break; } @@ -225,7 +227,7 @@ while (1) { *(wptr++) = s[pos++]; if (s[pos - 1] == '\0' - || s[pos - 1] == '>') { + || s[pos - 1] == '>') { break; } } @@ -235,16 +237,13 @@ } } - wptr += - snprintf(wptr, 22 * (len - pos), - "<font color=#%02x%02x%02x>%c", - (pos * end_r + (len - pos) * start_r) / len, - (pos * end_g + (len - pos) * start_g) / len, - (pos * end_b + (len - pos) * start_b) / len, - s[pos]); + wptr += snprintf(wptr, 22 * (len - pos), + "<font color=#%02x%02x%02x>%c", + (pos * end_r + (len - pos) * start_r) / len, + (pos * end_g + (len - pos) * start_g) / len, + (pos * end_b + (len - pos) * start_b) / len, s[pos]); pos++; } - return retval; } |