--- 0.98/FiSH.c 2006-03-15 22:17:58.000000000 +0100 +++ FiSH.c 2007-05-06 19:53:17.000000000 +0200 @@ -1,6 +1,6 @@ -///**************************** -// *** FiSH v0.98 for XChat *** -///**************************** +///***************************** +// *** FiSH v0.99p for XChat *** +///***************************** #include "xchat-plugin.h" @@ -12,6 +12,10 @@ unsigned char g_myPrivKey[300], g_myPubKey[300]; unsigned char iniPath[255], rndBuf[160], rndPath[255], tempPath[255]; int g_doEncrypt=1, g_doDecrypt=1, g_noFormatting=0; + +//Needed for bling +int icolor; +int doBling; miracl *mip; @@ -70,10 +74,7 @@ bf_dest[512]=0; return 166; -} - - - +} // decrypt a base64 cipher text (using key for target contactName) int FiSH_decrypt(char *msg_ptr, char *contactName) { @@ -128,8 +129,6 @@ return 166; } - - int decrypt_incoming(char *word[], char *word_eol[], void *userdata) { @@ -144,7 +143,7 @@ // word[5] = BASe.64/STRinG if(g_doDecrypt==0 || word[5]==0 || word[5][0]==0) return XCHAT_EAT_NONE; - if( (strcmp(word[4], ":+OK")!=0) && + if( (strcmp(word[4], ":+OK")!=0 && strcmp(word[4], ":++OK")!=0) && (strcmp(word[4], ":mcps")!=0) && (strncmp(word[1], ":-psyBNC!", 9)!=0)) return XCHAT_EAT_NONE; // prefix/psyBNC not found, don't process @@ -222,9 +221,63 @@ } xchat_set_context(ph, find_query_ctx); - GetPrivateProfileString("incoming_format", "crypted_privmsg", DEFAULT_FORMAT, msg_event, sizeof(msg_event), iniPath); + GetPrivateProfileString("incoming_format", "crypted_privmsg", DEFAULT_FORMAT, msg_event, sizeof(msg_event), iniPath); + + /////// Extra bling /////// + if (doBling==1) + { + int i; + const char *str; + // blink taskbar button (if configured) + if (xchat_get_prefs (ph, "input_flash_priv", &str, &i) == 3) + { + if(i==1) + xchat_commandf (ph, "GUI FLASH"); + } + // blink tray icon (if configured) + // WARNING: Only works with XChat 2.8.0 and higher + if (xchat_get_prefs (ph, "gui_tray_blink", &str, &i) == 2) + { + if (i & (1 << 8)) + { + xchat_commandf (ph, "TRAY -i 8"); + const char *network; + network = xchat_get_info (ph, "network"); + if (!network) + network = xchat_get_info (ph, "server"); + xchat_commandf (ph, "TRAY -t \"XChat: Encrypted private message from: %s (%s)\"", from_nick, network); + } + } + // colorize nick/channel in list (new message/highlight) + if (icolor!=3) + { + //Test for hilights + const char *currnick; + currnick = xchat_get_info (ph, "nick"); + if(xchat_get_prefs (ph, "irc_extra_hilight", &str, &i) == 1) + { + char delims[] = ","; + char *result = NULL; + result = strtok(str, delims); + while (result != NULL) + { + if (strstr(tolower(word_eol[4]+psylog_found), tolower(result))) + { + icolor=3; + break; + } + result = strtok(NULL, delims); + } + } + if (strstr(tolower(word_eol[4]+psylog_found), tolower(currnick))) icolor=3; + + if (icolor!=3) + icolor=2; + xchat_commandf (ph, "GUI COLOR %i", icolor); + } + } } - + // display formatted nick and decrypted message xchat_printf(ph, msg_event, from_nick, word_eol[4]+psylog_found); @@ -233,7 +286,42 @@ else return XCHAT_EAT_NONE; } +// needed for extra bling +// For now this is a simple function: +// it clears every hilighted item in the list when a new message gets received +void clear_icolor() +{ + /*xchat_context *find_query_ctx + find_query_ctx = xchat_find_context(ph, NULL, from_nick); + if(find_query_ctx) xchat_set_context(ph, find_query_ctx);*/ + icolor=0; +} +// xchat syntax: /bling [<1/on|0/off>] +int command_bling(char *word[], char *word_eol[], void *userdata) +{ + char *param=word[2]; + + if(param==0 || *param==0) + { + if(doBling==1) xchat_printf(ph, "\002FiSH:\002 Notification support is \002ON\002"); + else xchat_printf(ph, "\002FiSH:\002 Notification support is \002OFF\002"); + } + else if(stricmp(param,"on")==0 || *param=='1' || *param=='y' || *param=='Y') + { + xchat_printf(ph, "\002FiSH:\002 Set notification support to \002ON\002."); + doBling=1; + WritePrivateProfileString("FiSH", "do_bling", "1", iniPath); + } + else if(stricmp(param,"off")==0 || *param=='0' || *param=='n' || *param=='N') + { + xchat_printf(ph, "\002FiSH:\002 Set notification support to \002OFF\002."); + doBling=0; + WritePrivateProfileString("FiSH", "do_bling", "0", iniPath); + } + + return XCHAT_EAT_ALL; +} int encrypt_outgoing(char *word[], char *word_eol[], void *userdata) { @@ -918,7 +1006,7 @@ find_query_ctx = xchat_find_context(ph, NULL, from_nick); if(find_query_ctx) xchat_set_context(ph, find_query_ctx); - if(strncmp(DH_msg, ":DH1080_INIT", 12)==0) + if(strncmp(DH_msg, ":DH1080_INIT", 12)==0 || strncmp(DH_msg, ":+DH1080_INIT", 13)==0) { xchat_printf(ph, "\002FiSH:\002 Received DH1080 public key from %s, sending mine...", from_nick); @@ -929,7 +1017,7 @@ } xchat_commandf(ph, "quote NOTICE %s :DH1080_FINISH %s", from_nick, g_myPubKey); // send DH1080_FINISH (own pubkey) to from_nick } - else if(strncmp(DH_msg, ":DH1080_FINISH", 14)!=0) return XCHAT_EAT_NONE; + else if(strncmp(DH_msg, ":DH1080_FINISH", 14)!=0 && strncmp(DH_msg, ":+DH1080_FINISH", 15)!=0) return XCHAT_EAT_NONE; strcpy(hisPubKey, DH_pubkey); if(DH1080_comp(g_myPrivKey, hisPubKey)==0) return XCHAT_EAT_NONE; @@ -966,7 +1054,7 @@ *plugin_name = "FiSH"; *plugin_desc = "Blowfish IRC encryption, including secure Diffie-Hellman 1080 bit key-exchange"; - *plugin_version = "0.98"; + *plugin_version = "0.99p"; initb64(); mip=mirsys(256, 0); @@ -1072,7 +1160,14 @@ xchat_hook_command(ph, "notice+", XCHAT_PRI_NORM, command_crypt_NOTICE, "Send an encrypted notice. Usage: /notice+ ", 0); xchat_hook_command(ph, "msg+", XCHAT_PRI_NORM, command_crypt_MSG, "Send an encrypted message. Usage: /msg+ ", 0); xchat_hook_command(ph, "encrypt", XCHAT_PRI_NORM, command_encrypt, "Enable or disable FiSH encryption. Usage: /encrypt [< 1/y/on | 0/n/off >]", 0); - xchat_hook_command(ph, "decrypt", XCHAT_PRI_NORM, command_decrypt, "Enable or disable FiSH decryption. Usage: /decrypt [< 1/y/on | 0/n/off >]", 0); + xchat_hook_command(ph, "decrypt", XCHAT_PRI_NORM, command_decrypt, "Enable or disable FiSH decryption. Usage: /decrypt [< 1/y/on | 0/n/off >]", 0); + + //Needed for Extra Bling + xchat_hook_print (ph, "Focus Tab", -1, clear_icolor, NULL); + xchat_hook_command(ph, "bling", XCHAT_PRI_NORM, command_bling, "Enable or disable notification support (taskbar flash, icon blink, list colors). Usage: /bling [< 1/y/on | 0/n/off >]", 0); + GetPrivateProfileString("FiSH", "do_bling", "1", tmpBuf, sizeof(tmpBuf), iniPath); + doBling=0; + if (*tmpBuf=='1' || *tmpBuf=='y' || *tmpBuf=='Y') doBling=1; GetPrivateProfileString("FiSH", "print_onjoin", "1", tmpBuf, sizeof(tmpBuf), iniPath); if(*tmpBuf=='1' || *tmpBuf=='y' || *tmpBuf=='Y') xchat_hook_print(ph, "You Join", XCHAT_PRI_NORM, print_onjoin, 0); @@ -1082,7 +1177,7 @@ if(*iniKey==0) xchat_hook_command(ph, "fishpw", XCHAT_PRI_NORM, command_fishpw, "Set FiSH password to decrypt your key-container (blow.ini).\nUsage: /fishpw ", 0); #endif - xchat_print(ph, "\002FiSH v0.98\002 - encryption plugin for XChat \002loaded!\002 URL: http://fish.sekure.us\n"); + xchat_print(ph, "\002FiSH v0.99p\002 - encryption plugin for XChat \002loaded!\002 URL: http://fish.sekure.us\n"); return 1; // return 1 for success } @@ -1225,4 +1320,4 @@ } return FALSE; } -#endif +#endif