__________________________________ Simple example of how to use pY! Voice Chat as a plugin. 3/18/2004 __________________________________ Example Yahoo Chat Room Join Packet: sess id : 1987566637 data len : 829 pkt type : 0x98 59 4d 53 47 00 00 00 00 03 3d 00 98 00 00 00 01 c2 6f 0d 13 Y M S G . . . . . = . . . . . .  o . . 31 30 34 c0 80 45 6e 20 65 73 70 61 6e 6f 6c 3a 104À.En espanol: 31 38 c0 80 31 30 35 c0 80 42 69 65 6e 76 65 6e 18À.105À.Bienven 69 64 6f 73 21 20 48 61 62 6c 61 20 45 73 70 61 idos! Habla Espa 6e 6f 6c 3f c0 80 31 32 38 c0 80 31 36 30 30 30 nol?À.128À.16000 34 33 33 32 35 c0 80 31 30 38 c0 80 31 33 c0 80 43325À.108À.13À. 31 32 39 c0 80 31 36 30 30 33 32 36 34 35 37 c0 129À.1600326457À 80 31 33 30 c0 80 4b 63 6f 57 41 42 4c 75 41 6f .130À.KcoWABLuAo 6e 34 34 2e 4d 34 64 73 5f 49 54 46 75 68 35 56 n44.M4ds_ITFuh5V 2e 48 66 6d 54 6f 34 2d c0 80 31 32 36 c0 80 2d .HfmTo4-À.126À.- 32 31 34 37 31 35 34 34 33 32 c0 80 31 33 c0 80 2147154432À.13À. 31 c0 80 36 31 c0 80 4b 63 6f 57 41 42 4a 55 42 1À.61À.KcoWABJUB 4f 34 5a 6c 77 46 32 4b 59 74 47 73 52 71 5f 75 O4ZlwF2KYtGsRq_u 43 57 65 71 5f 36 54 6f 2d c0 80 31 30 39 c0 80 CWeq_6To-À.109À. 6c 61 6e 65 67 72 61 5f 61 6c 62 61 c0 80 31 31 lanegra_albaÀ.11 30 c0 80 30 c0 80 31 31 33 c0 80 31 30 32 34 c0 0À.0À.113À.1024À 80 31 30 39 c0 80 65 6c 5f 70 69 70 69 72 69 70 .109À.el_pipirip 61 6f 38 c0 80 31 31 30 c0 80 30 c0 80 31 31 33 ao8À.110À.0À.113 c0 80 31 30 32 34 c0 80 31 30 39 c0 80 65 6c 5f À.1024À.109À.el_ 63 61 64 69 6c 6c 6f 32 30 30 34 c0 80 31 31 30 cadillo2004À.110 c0 80 30 c0 80 31 34 32 c0 80 74 65 78 61 73 20 À.0À.142À.texas 75 2e 73 2e 61 c0 80 31 31 33 c0 80 33 33 37 39 u.s.aÀ.113À.3379 32 c0 80 31 30 39 c0 80 6c 69 6c 5f 5f 63 6a c0 2À.109À.lil__cjÀ 80 31 31 30 c0 80 32 33 c0 80 31 34 31 c0 80 c2 .110À.23À.141À. b9 71 20 4c 61 64 79 20 43 4a 20 c2 b9 71 c0 80 ¹q Lady CJ ¹qÀ. 31 34 32 c0 80 73 6f 6d 65 77 68 65 72 65 c0 80 142À.somewhereÀ. 31 31 33 c0 80 36 36 35 36 30 c0 80 31 30 39 c0 113À.66560À.109À 80 61 66 67 67 31 32 31 c0 80 31 31 30 c0 80 31 .afgg121À.110À.1 38 c0 80 31 34 31 c0 80 53 65 65 79 61 c0 80 31 8À.141À.SeeyaÀ.1 34 32 c0 80 53 79 72 61 63 75 73 65 c0 80 31 31 42À.SyracuseÀ.11 33 c0 80 31 30 34 30 c0 80 31 30 39 c0 80 6e 6f 3À.1040À.109À.no 63 68 65 73 5f 65 74 65 72 6e 61 73 5f 63 6f 6e ches_eternas_con 74 69 67 6f 5f 6d 75 6a 65 72 c0 80 31 31 30 c0 tigo_mujerÀ.110À 80 30 c0 80 31 31 33 c0 80 31 30 32 34 c0 80 31 .0À.113À.1024À.1 30 39 c0 80 61 6e 67 65 6c 5f 62 61 6d 6a 36 37 09À.angel_bamj67 c0 80 31 31 30 c0 80 30 c0 80 31 31 33 c0 80 33 À.110À.0À.113À.3 33 37 39 32 c0 80 31 30 39 c0 80 65 6c 63 68 69 3792À.109À.elchi 75 68 75 61 68 75 61 c0 80 31 31 30 c0 80 30 c0 uhuahuaÀ.110À.0À 80 31 31 33 c0 80 33 33 37 39 32 c0 80 31 30 39 .113À.33792À.109 c0 80 62 6c 61 78 61 64 6f 77 c0 80 31 31 30 c0 À.blaxadowÀ.110À 80 30 c0 80 31 31 33 c0 80 31 30 32 34 c0 80 31 .0À.113À.1024À.1 30 39 c0 80 61 6d 6f 72 6f 73 61 5f 33 35 32 30 09À.amorosa_3520 30 33 c0 80 31 31 30 c0 80 30 c0 80 31 31 33 c0 03À.110À.0À.113À 80 31 30 34 30 c0 80 31 30 39 c0 80 6a 6f 73 68 .1040À.109À.josh 75 61 72 77 31 37 c0 80 31 31 30 c0 80 30 c0 80 uarw17À.110À.0À. 31 31 33 c0 80 33 33 37 39 32 c0 80 31 30 39 c0 113À.33792À.109À 80 65 6c 5f 72 61 70 69 64 6f 37 35 32 30 30 33 .el_rapido752003 c0 80 31 31 30 c0 80 30 c0 80 31 31 33 c0 80 31 À.110À.0À.113À.1 30 32 34 c0 80 31 30 39 c0 80 6a 65 73 73 65 6d 024À.109À.jessem 75 6e 37 37 c0 80 31 31 30 c0 80 33 33 c0 80 31 un77À.110À.33À.1 34 31 c0 80 4a 65 73 75 73 6d 75 6e 37 37 c0 80 41À.Jesusmun77À. 31 34 32 c0 80 4c 61 72 65 64 6f 20 54 78 c0 80 142À.Laredo TxÀ. 31 31 33 c0 80 33 33 37 39 32 c0 80 00 113À.33792À.. 104 = 'En espanol:18' 105 = 'Bienvenidos! Habla Espanol?' 128 = '1600043325' 108 = '13' 129 = '1600326457' 130 = 'KcoWABLuAon44.M4ds_ITFuh5V.HfmTo4-' 126 = '-2147154432' 13 = '1' 61 = 'KcoWABJUBO4ZlwF2KYtGsRq_uCWeq_6To-' 109 = 'lanegra_alba' 110 = '0' 113 = '1024' 109 = 'el_pipiripao8' 110 = '0' 113 = '1024' 109 = 'el_cadillo2004' 110 = '0' 142 = 'texas u.s.a' 113 = '33792' 109 = 'lil__cj' 110 = '23' 141 = '¹q Lady CJ ¹q' 142 = 'somewhere' 113 = '66560' 109 = 'afgg121' 110 = '18' 141 = 'Seeya' 142 = 'Syracuse' 113 = '1040' 109 = 'noches_eternas_contigo_mujer' 110 = '0' 113 = '1024' 109 = 'angel_bamj67' 110 = '0' 113 = '33792' 109 = 'elchiuhuahua' 110 = '0' 113 = '33792' 109 = 'blaxadow' 110 = '0' 113 = '1024' 109 = 'amorosa_352003' 110 = '0' 113 = '1040' 109 = 'joshuarw17' 110 = '0' 113 = '33792' 109 = 'el_rapido752003' 110 = '0' 113 = '1024' 109 = 'jessemun77' 110 = '33' 141 = 'Jesusmun77' 142 = 'Laredo Tx' 113 = '33792' ___________________________________________ Handling Chat room join packets, parsing for voice chat cookies and serial numbers...excerpt: ___________________________________________ char current_chat_serial[50]=""; char current_chat_cookie[120]=""; char current_chat_user[75]=""; char current_chat_name[75]=""; int voice_enabled=0; /* now, we need to collect some info needed for voice chat - PhrozenSmoke: field 130 = chat room cookie, 128 & 129 = room 'serial number', 61 = some other cookie (use unknown), also useful...108 = number of people in the room, 104 = room name - the 'chat room' cookie changes with each room and is different from the 'session' cookie we get when we log on. If a room was opened because it didnt exist, but the user didn't explicitly 'make' the room, then the chat serial # (129) will be '0', and there will be no chat room cookie (130)...if, somebody deliberately made a room with voice chat DISABLED, there will be a chat serial (129), but no chat room cookie (130). - I THINK these are the reasons, but either way - we CANNOT enter voice chat without both fields 128/129 AND 130...and 128/129 must not = 0...field 128 is the room 'category' not the room itself the actual room serial is in 129, sometimes 128 and 129 are the same (like user-created rooms), but 129 is the field we need. */ strncpy(current_chat_cookie,"", 118); /* clear old */ strncpy(current_chat_serial,"" ,48); /* clear old */ strncpy(current_chat_name,ymsg_field( "104" ), 73); /* room name */ strncpy(current_chat_user,ymsg_sess->user, 73); /* user name */ voice_enabled=0; if ( strcmp( ymsg_field( "130" ), "" )) { /* voice chat cookie */ strncpy(current_chat_cookie,ymsg_field( "130" ), 118); } if ( strcmp( ymsg_field( "129" ), "" )) { /* voice chat serial number */ strncpy(current_chat_serial,ymsg_field( "129" ), 48); } if ( (strlen(current_chat_cookie)>3) && (strlen(current_chat_serial)>3) ) { voice_enabled=1; } strcat(buf,"\n"); strcat(buf,YAHOO_STYLE_BOLDON); strcat(buf,YAHOO_COLOR_PURPLE); strcat(buf,_("Voice Chat")); strcat(buf,": "); if (voice_enabled==1) { strcat(buf,YAHOO_COLOR_GREEN); strcat(buf, _("Enabled")); } else { strcat(buf,YAHOO_COLOR_RED); strcat(buf,_("Disabled")); } strcat(buf,YAHOO_COLOR_BLACK); strcat(buf,YAHOO_STYLE_BOLDON); strcat(buf,"\n"); voice_launch(0); /* from voice_chat.c, launch without warning */ ________________ voice_chat.c excerpt: ________________ char *voice_start_file=NULL; char *get_voice_start_file() { char *user="user"; char storage[75]=""; char *stor=storage; if (voice_start_file) {return voice_start_file;} if (getenv("USER")) {user=getenv("USER");} strcpy(storage,"/tmp/pyvoice_chat_start_"); strncat(storage,user, 48); voice_start_file=strdup(stor); return voice_start_file; } void voice_launch(int with_warning) /* for regular chat rooms */ { char vchat_data[600]=""; char *vdata=vchat_data; FILE *vchat_file; char mymsg[350]=""; if (!allow_py_voice_helper) {return;} if (! voice_enabled) { if (with_warning) { char *mss=strdup(_("Voice chat is not available in this room.")); show_ok_dialog(mss); free(mss); } return; } vchat_file = fopen(get_voice_start_file(), "wb"); if (! vchat_file) { char *mss=NULL; snprintf(mymsg,348, "%s:\n%s", _("Voice chat: could not open file for writing"), get_voice_start_file() ); mss=strdup(mymsg); show_ok_dialog(mss); free(mss); return; } snprintf(vchat_data,597, "%s\n%s\n%s\n%s", current_chat_user, current_chat_name, current_chat_cookie, current_chat_serial); fwrite(vdata, 1, strlen(vdata), vchat_file); fflush(vchat_file); fclose(vchat_file); if (with_warning) { char *mss=strdup(_("Voice chat has been enabled. Start pY! Voice Chat.")); show_ok_dialog(mss); free(mss); } } ________________ Launching pY! Voice Chat: ________________ Usually this is done by running the command: '/usr/local/share/gyach/pyvoice/pyvoiceui.py' (this is the normal location, but of course this would depend on where you install pY! Voice Chat as a plugin. The important thing is to run the 'pyvoiceui.py' script, or the unmaintained, but working 'pyvoiceui-Gtk1.py' script if a Gtk-1/PyGtk-1 interface is needed/preferred. The main script, 'pyvoiceui.py' uses Gtk-2/PyGtk-2. The library that holds the network functionality, 'pyvoice.py' is *pretty much* clean of UI code, so if someone wanted to write a different user interface, they easily could by simply importing the 'pyvoice.py' library and changing around a few lines.)