home *** CD-ROM | disk | FTP | other *** search
/ Treasure Hunt 2001 PRESSKIT / TH2001_PRESSKIT.iso / demo / scol_install / Partition / comm / comchat.pkg < prev    next >
Encoding:
Text File  |  2000-09-18  |  18.1 KB  |  848 lines

  1. /* Comchat.pkg */
  2.  
  3. defcom ChatACK = ChatACK S;; 
  4. defcom NewUser = NewUser S I S;; 
  5. defcom DelUser = DelUser S I S;; 
  6. defcom Hear = Hear S;; 
  7. defcom Info = Info S S;; 
  8. defcom ComClose= ComClose;; 
  9. defcom ComConnected= ComConnected S;; 
  10.  
  11. var RedirectText=0;; 
  12. var RedirectAudio=0;; 
  13. var RedirectEvents=0;; 
  14.  
  15. var sendvideo=0;;
  16.  
  17. typeof thischn=Chn;; 
  18. typeof thisenv=Env;; 
  19. typeof SendFileF=fun [ObjButton I] I;; 
  20.  
  21. var servernick="";; 
  22. var serverIP="";; 
  23. var MyNick="";; 
  24. var Nusers=0;; 
  25. var IsAServer=0;; 
  26. var PhoneASK=0;; 
  27. var FileSend=0;; 
  28.  
  29. struct TPlayer = [ PlayerChannel : Chn, PlayerNick : S , PlayerID : I , PlayerIP : S ] Const_Player ;; 
  30. typeof Players=[TPlayer r1];; 
  31. typeof CurrentUser=TPlayer;; typeof Chatw=ObjWin;; 
  32. typeof chattext=ObjText;; 
  33. typeof chatinput=ObjText;; 
  34. typeof userlist=ObjBox;; 
  35. typeof userinfo=ObjButton;; 
  36. typeof sendfile=ObjButton;; typeof connect=ObjButton;; 
  37. typeof VideoBMP=ObjBitmap;; 
  38. typeof Videobmp=ObjBitmap;; 
  39.  
  40. fun AddPlayer(player)= 
  41.   set Players=player::Players; 
  42. };; 
  43.  
  44. fun PlayerNickcmp (player,nick)=
  45.   if !(strcmp player.PlayerNick nick) then 1 else 0;; 
  46.  
  47. fun PlayerIPcmp (player,IP)=
  48.   if !(strcmp player.PlayerIP IP) then 1 else 0;; 
  49.  
  50. fun PlayerIDcmp (player,ID)=
  51.   if player.PlayerID==ID then 1 else 0;; 
  52.  
  53. fun PlayerChcmp (player,ch)=
  54.   if player.PlayerChannel==ch then 1 else 0;; 
  55.  
  56. fun GetPlayerByNick (s)=
  57.   searchlist Players @PlayerNickcmp s;; 
  58.  
  59. fun GetPlayerByChannel (s)=
  60.   searchlist Players @PlayerChcmp s;; 
  61.  
  62. fun GetPlayerByID (s)=
  63.   searchlist Players @PlayerIDcmp s;; 
  64.  
  65. fun GetPlayerByIP (s)=
  66.   searchlist Players @PlayerIPcmp s;; 
  67.  
  68. fun DelPlayerByID(id)=
  69.   deletelist Players GetPlayerByID id;; 
  70.  
  71. fun DelPlayerByIP(ip)=
  72.   deletelist Players GetPlayerByIP ip;; 
  73.  
  74. fun DelPlayerByNick(n)=
  75.   deletelist Players GetPlayerByNick n;; 
  76.  
  77. fun DelPlayerByChannel(ch)=
  78.   deletelist Players GetPlayerByChannel ch;; 
  79.  
  80. fun UpdateCurrentUser ()= 
  81.   let _GETcombo userlist->[rang nick] in 
  82.   { 
  83.     set CurrentUser=GetPlayerByNick nick; 
  84.   } 
  85. };; 
  86.  
  87. fun LedOn ()= 
  88.   0 
  89. ;; 
  90.  
  91. fun LedOff ()= 
  92.   0 
  93. ;; 
  94.  
  95. fun print(s)= 
  96.   _ADDtext chattext s; 
  97.   LimitText chattext 1000 14
  98. ;; 
  99.  
  100. fun ComAPIplug ()= 
  101.   _load "comm/comapi3.pkg"; 
  102.   _script "APIengage"
  103. ;; 
  104.  
  105. fun __Hear (s)= 
  106.   let GetPlayerByChannel _channel -> player in print strloc loc "HEAR" player.PlayerNick::s::nil; 
  107.   if (RedirectText==1) then 
  108.   { 
  109.     _on APIchn Hear [s]; 
  110.     0 
  111.   } 
  112.   else 0 
  113. ;; 
  114.  
  115. fun __Info (s1,s2)= 
  116.   let GetPlayerByChannel _channel -> player in 
  117.     print strcat strcat strcat s1 player.PlayerNick s2 "\n"; 
  118.   if (RedirectText==1) then 
  119.   { 
  120.     _on APIchn Info [s1 s2]; 
  121.     0 
  122.   } 
  123.   else 0 
  124. };; 
  125.  
  126. fun updatesendbutton ()= 
  127.   if (Nusers>1 || FileSend==1) then 
  128.   { 
  129.     if (sendfile!=nil) then 
  130.     { 
  131.       _DSbutton sendfile; 
  132.       set sendfile=nil; 
  133.       0 
  134.     } 
  135.     else 0 
  136.   } 
  137.   else 
  138.   { 
  139.     if (sendfile==nil) then 
  140.     { 
  141.       set sendfile=_CRbutton _channel Chatw 310 60 100 20 0 loc "SENDFILE"; 
  142.       _CBbutton sendfile SendFileF 0; 
  143.       0 
  144.     } 
  145.     else 0 
  146.   } 
  147. };; 
  148.  
  149. fun __NewUser (nick,ID,IP)= 
  150.   print strloc loc "JOIN" nick::IP::(_channelIP _channel)::nil; 
  151.   AddPlayer Const_Player [_channel nick ID IP]; 
  152.   set Nusers=Nusers+1; 
  153.   _ADDcombo userlist 0 nick; 
  154.   if (RedirectEvents==1) then 
  155.   { 
  156.     _on APIchn NewUser [nick ID IP]; 
  157.     0 
  158.   } 
  159.   else 0; 
  160.   updatesendbutton; 
  161. };; 
  162.  
  163. fun __DelUser (nick,ID,IP)= 
  164.   print strloc loc "LEAVE" nick::IP::(_channelIP _channel)::nil; 
  165.   DelPlayerByNick nick; 
  166.   set Nusers=Nusers-1; 
  167.   _SDELcombo userlist nick; 
  168.   if (RedirectEvents==1) then 
  169.   { 
  170.     _on APIchn DelUser [nick ID IP]; 
  171.     0 
  172.   } 
  173.   else 0; 
  174.   updatesendbutton; 
  175. };; 
  176.  
  177. fun Chatwdestroy (obj,r)= 
  178.   _delline thischn; 
  179.   if (APIchn!=nil) then 
  180.   { 
  181.     _on APIchn ComClose []; 
  182.     0 
  183.   } 
  184.   else 0; 
  185.  
  186.   _killchannel thischn; 
  187.   _killchannel APIchn;  
  188.   stopvideo;
  189. };; 
  190.  
  191. fun ProcessInput (text)= 
  192.   print strloc loc "PROMPT" text::nil; 
  193.   _on thischn Hear [text]; 
  194. };; 
  195.  
  196. fun textinputCB (obj,u)= 
  197.   let _GETtext obj -> text in 
  198.   { 
  199.     if (nth_char text ((strlen text)-1))==10 then 
  200.     { 
  201.       _DELline obj 0; 
  202.       _DELline obj 0; 
  203.       ProcessInput text; 
  204.       obj 
  205.     } 
  206.     else 
  207.     {
  208.       obj 
  209.     } 
  210.   } 
  211. };; 
  212.  
  213. fun GetUserInfos (obj,r)= 
  214.   UpdateCurrentUser; 
  215.   if (CurrentUser!=nil) then 
  216.   { 
  217.     print (strloc loc "INFO1" CurrentUser.PlayerNick::CurrentUser.PlayerIP::nil); 
  218.     print (strloc loc "INFO2" (itoa CurrentUser.PlayerID)::(_channelIP CurrentUser.PlayerChannel)::nil); 
  219.   } 
  220.   else 
  221.   { 
  222.     print (loc "INFOERR"); 
  223.   } 
  224. };; 
  225.  
  226. typeof FilePerso=TPlayer;; 
  227. typeof FileP=P;; 
  228. typeof FileW=W;; 
  229. typeof FileF=File;; 
  230. typeof FileN=S;; 
  231. typeof FileO=S;; 
  232. typeof FileSize=I;; 
  233. typeof FileSizeGot=I;; 
  234. typeof FileChn=Chn;; 
  235.  
  236. var BlockSize=256;; 
  237.  
  238. defcom ProposeFile = ProposeFile S S I S I;; 
  239. defcom AcceptFile = AcceptFile S I S;; 
  240. defcom FileBlock = FileBlock S I S S;; 
  241. defcom FileLast = FileLast S I S S;; 
  242. defcom FileAbort = FileAbort S I S;; 
  243. defcom FileAck = FileAck S I S;; 
  244.  
  245. typeof ProgressBar=ObjBitmap;; 
  246.  
  247. fun Chatwpaint (obj,r)= 
  248.   UpdateStatus; 
  249.   _BLTbitmap Chatw ProgressBar 310 60; 
  250.   _BLTbitmap Chatw Videobmp 310 115 
  251. };; 
  252.  
  253. fun InitFileProgress ()= 
  254.   _DSbutton sendfile; 
  255.   set ProgressBar=_CRbitmap _channel 100 20; 
  256.   _DRAWrectangle ProgressBar 0 0 100 20 DRAW_SOLID 1 0 DRAW_SOLID (255+(255<<8)+(255<<16)); 
  257.   _BLTbitmap Chatw ProgressBar 310 60; 
  258.   0 
  259. };; 
  260.  
  261. fun UpdateFileProgress ()= 
  262.   if (FileSize!=0) then 
  263.   {
  264.     _DRAWrectangle ProgressBar 2 2 ((96*FileSizeGot)/FileSize) 16 DRAW_SOLID 1 0 DRAW_SOLID (255); 
  265.     0
  266.   } 
  267.   else 0; 
  268.   _BLTbitmap Chatw ProgressBar 310 60; 
  269.   0 
  270. };; 
  271.  
  272. fun GetFileBlock ()= 
  273.   let _FILERead FileF BlockSize -> block in 
  274.   { 
  275.     set FileSizeGot=FileSizeGot+strlen block; 
  276.     UpdateFileProgress; 
  277.     if (_FILETell FileF) >= FileSize then 
  278.     { 
  279.       [block 1] 
  280.     } 
  281.     else 
  282.     { 
  283.       [block 0] 
  284.     } 
  285.   } 
  286. };; 
  287.  
  288. fun SaveFileBlock (block)= 
  289.   set FileSizeGot=FileSizeGot+strlen block; 
  290.   UpdateFileProgress; 
  291.   _appendpack block FileW; 
  292. };; 
  293.  
  294. fun CloseFileProgress ()= 
  295.   set FileSend=0; 
  296.   _DSbitmap ProgressBar; 
  297.   set ProgressBar=nil; 
  298.   set sendfile=_CRbutton _channel Chatw 310 60 100 20 0 loc "SENDFILE"; 
  299.   _AFFfontButton sendfile mediumfont; 
  300.   _CBbutton sendfile SendFileF 0; 
  301.   0 
  302. };; 
  303.  
  304. fun __FileAbort (nick,id,file)= 
  305.   if (FileChn==_channel) && (FileSend==1) then 
  306.   { 
  307.     set FileSend=0; 
  308.     if (FileF!=nil) then 
  309.     { 
  310.       _FILEClose FileF; 
  311.       set FileF=nil;
  312.       0 
  313.     } 
  314.     else 0; 
  315.     CloseFileProgress ;
  316.     0 
  317.   } 
  318.   else 
  319.   { 
  320.     print loc "FILEABORT"; 
  321.     0 
  322.   } 
  323. };; 
  324.  
  325. fun __AcceptFile (nick,id,file)= 
  326.   if (FileChn==_channel) && (FileSend==1) then 
  327.   { 
  328.     set FileF=_FILEOpen FileChn FileP; 
  329.     if (FileF==nil) then 
  330.     { 
  331.       print loc "FILEERR"; 
  332.       _on FileChn FileAbort [FilePerso.PlayerNick FilePerso.PlayerID FileN]; 
  333.       CloseFileProgress ; 
  334.       0 
  335.     } 
  336.     else 
  337.     { 
  338.       print loc "FILEACC"; 
  339.       set FileSize=_FILESize FileF; 
  340.       let GetFileBlock -> [block ended] in 
  341.         if (ended==1) then 
  342.         { 
  343.           _on FileChn FileLast [nick id file block]; 
  344.           _status "!File UpLoaded succesfully\n"; 
  345.           _fooS "First FileBlock Is Last One..."; 
  346.           CloseFileProgress ; 
  347.           0 
  348.         } 
  349.         else 
  350.         { 
  351.           _on FileChn FileBlock [nick id file block]; 
  352.           _fooS "First FileBlock"; 
  353.           UpdateFileProgress; 
  354.           0 
  355.         } 
  356.     } 
  357.   } 
  358.   else 
  359.   { 
  360.     print loc "FILEABORT"; 
  361.     0 
  362.   } 
  363. };; 
  364.  
  365. fun __FileLast (nick,id,file,block)= 
  366.   if (FileChn==_channel) && (FileSend==1) then 
  367.   { 
  368.     let SaveFileBlock block -> error in 
  369.       if (error!=0) then 
  370.       { 
  371.         _on _channel FileAbort [nick id file]; 
  372.         print strloc loc "FILESVERR" file::nil; 
  373.         set FileSend=0; 
  374.         _FILEClose FileF; 
  375.         set FileF=nil; 
  376.         CloseFileProgress ; 
  377.         0 
  378.       } 
  379.       else 
  380.       { 
  381.         print loc "FILEDOWN"; 
  382.         set FileSend=0; 
  383.         if (FileF!=nil) then 
  384.         { 
  385.           _FILEClose FileF; 
  386.           set FileF=nil;
  387.           0 
  388.         } 
  389.         else 0; 
  390.         CloseFileProgress ; 
  391.         0 
  392.       } 
  393.   } 
  394.   else 
  395.   { 
  396.     print "FILEABORT"; 
  397.     CloseFileProgress ; 
  398.     0 
  399.   } 
  400. };; 
  401.  
  402. fun __FileBlock (nick,id,file,block)= 
  403.   if (FileChn==_channel) && (FileSend==1) then 
  404.   { 
  405.     let SaveFileBlock block -> error in 
  406.     if (error==1) then 
  407.     { 
  408.       _on _channel FileAbort [nick id file]; 
  409.       print strloc loc "FILESVERR" file::nil; 
  410.       set FileSend=0; 
  411.       if (FileF!=nil) then 
  412.       { 
  413.         _FILEClose FileF; 
  414.         set FileF=nil;
  415.         0 
  416.       } 
  417.       else 0; 
  418.       CloseFileProgress ; 
  419.       0 
  420.     } 
  421.     else 
  422.     { 
  423.       _on _channel FileAck [nick id file]; 
  424.       _fooS "ACKing"; 
  425.       0 
  426.     } 
  427.   } 
  428.   else 
  429.   { 
  430.     print loc "FILEABORT";
  431.     CloseFileProgress ; 
  432.     0 
  433.   } 
  434. };; 
  435.  
  436. fun __FileAck (nick,id,file)= 
  437.   if (FileChn==_channel) && (FileSend==1) then 
  438.   { 
  439.     let GetFileBlock -> [block ended] in 
  440.       if (ended==1) then 
  441.       { 
  442.         _on FileChn FileLast [nick id file block]; 
  443.         _fooS "FILE LAST"; 
  444.         set FileSend=0; 
  445.         updatesendbutton; 
  446.         CloseFileProgress; 
  447.         print loc "FILEOK"; 
  448.         0 
  449.       } 
  450.       else 
  451.       { 
  452.         _on FileChn FileBlock [nick id file block]; 
  453.         _fooS "FILE BLOCK"; 
  454.         UpdateFileProgress; 
  455.       } 
  456.   } 
  457.   else 
  458.   {
  459.     print "FILEABORT"; 
  460.     0 
  461.   } 
  462. };; 
  463.  
  464. fun SaveFile (obj,u,filename)= 
  465.   if (filename!=nil) then 
  466.   { 
  467.     set FileW=filename; 
  468.     set FileN=_GetFileNameFromW filename; 
  469.     if ((_createpack "" FileW)!=0) then 
  470.     { 
  471.       print loc "FILEERR"; 
  472.       _on FileChn FileAbort [FilePerso.PlayerNick FilePerso.PlayerID FileN]; 
  473.       CloseFileProgress ; 
  474.       0 
  475.     } 
  476.     else 
  477.     { 
  478.       _on FileChn AcceptFile [FilePerso.PlayerNick FilePerso.PlayerID FileN]; 
  479.       print strloc loc "FILEDOWNLING" FilePerso.PlayerNick::FileO::FileN::nil; 
  480.       InitFileProgress; 
  481.     } 
  482.   } 
  483.   else 
  484.   { 
  485.     _on FileChn FileAbort [FilePerso.PlayerNick FilePerso.PlayerID FileN]; 
  486.     CloseFileProgress ; 
  487.     0 
  488.   } 
  489. };; 
  490.  
  491. fun __ProposeFile (nick,to,id,file,size)= 
  492.   if FileSend then 
  493.   { 
  494.     print strloc loc "FILEPROPERR" nick::file::nil; 
  495.     _on _channel FileAbort [nick id file]; 
  496.   } 
  497.   else 
  498.   {
  499.     set FilePerso = GetPlayerByNick nick; 
  500.     set FileChn=_channel; 
  501.     set FileSize=size; 
  502.     set FileSizeGot=0; 
  503.     if (FilePerso==nil) then 
  504.     { 
  505.       print strloc loc "FILEPROPERR" nick::file::nil; 
  506.       _on FileChn FileAbort [nick id file]; 
  507.       0 
  508.     } 
  509.     else 
  510.     { 
  511.       print strloc loc "FILEPROP" nick::file::nil; 
  512.       InitFileProgress ; 
  513.       _DLGrflsave (_DLGSaveFile _channel Chatw file "" "") @SaveFile 0; 
  514.       set FileSend=1; 
  515.       set FileO=file; 
  516.       0
  517.     } 
  518.   } 
  519. };; 
  520.  
  521. fun OpenFile (obj,u,filename)= 
  522.   if (filename!=nil) then 
  523.   { 
  524.     set FileP=filename; 
  525.     set FileN=_GetFileNameFromP filename; 
  526.     set FileChn=_channel; 
  527.     set FileSize=_FILESize _FILEOpen _channel FileP; 
  528.     set FileSizeGot=0; 
  529.     _on FileChn ProposeFile [MyNick FilePerso.PlayerNick FilePerso.PlayerID FileN FileSize]; 
  530.     print strloc loc "PROPOSING" FileN::FilePerso.PlayerNick::nil; 
  531.   }
  532.   else 
  533.   {
  534.     CloseFileProgress ; 
  535.     0 
  536.   }
  537. };; 
  538.  
  539. fun SendFile (obj,r)= 
  540.   if (FileSend!=0) then 0 
  541.   else 
  542.   { 
  543.     set FileSend=1; 
  544.     UpdateCurrentUser; 
  545.     InitFileProgress ; 
  546.     set FilePerso=CurrentUser; 
  547.     _DLGrflopen (_DLGOpenFile _channel Chatw "" "" "") @OpenFile 0; 
  548.     0 
  549.   } 
  550. };; 
  551.  
  552. fun Connect (obj,r)= 
  553.   UpdateCurrentUser; 
  554.   print strloc loc "NEW" CurrentUser.PlayerNick::CurrentUser.PlayerIP::nil; 
  555.   Contact CurrentUser.PlayerIP; 
  556.   0 
  557. };; 
  558.  
  559. defcom GetPhone = GetPhone;; 
  560. defcom PhoneOK=PhoneOK;; 
  561. defcom PhoneDENY=PhoneDENY;; 
  562. defcom ReleasePhone = ReleasePhone;; 
  563.  
  564. var AskPhone=0;; 
  565.  
  566. fun PhoneClick (obj,r,x,y,but)= 
  567.   if (x>=420) && (x<=450) && (y>=50) && (y<=80) && (AskPhone==0) && playing>=0 then 
  568.   { 
  569.     set AskPhone=1;  
  570.     _on thischn GetPhone []; 
  571.   } 
  572.   else if (x>=420) && (x<=450) && (y>=10) && (y<=40) then 
  573.     if playing==-1 then 
  574.       unmute 
  575.     else 
  576.       mute 
  577.   else 0;
  578.   UpdateStatus 
  579. };; 
  580.  
  581. fun __GetPhone ()= 
  582.   _on _channel PhoneOK []; 
  583. };; 
  584.  
  585. fun __PhoneOK ()= 
  586.   if (AskPhone==1) then 
  587.   { 
  588.     _fooS "Phone Is OK"; 
  589.     set AskPhone=2; 
  590.     Record; 
  591.   } 
  592.   else 
  593.     0; 
  594. };; 
  595.  
  596. fun __ReleasePhone ()= 
  597.   _fooS "ReleasePhone"; 
  598.   0 
  599. };; 
  600.  
  601. fun __PhoneDENY ()= 
  602.   _fooS "PhoneDeny"; 
  603.   if (AskPhone==1) then 
  604.   { 
  605.     set AskPhone=0; 
  606.     PauseRecord ; 
  607.   } 
  608.   else if AskPhone==2 then 
  609.   { 
  610.     set AskPhone=0; 
  611.     PauseRecord ; 
  612.   } 
  613.   else 0 
  614. };; 
  615.  
  616. fun PhoneUnclick (obj,r,x,y,but)= 
  617.   _fooS "UNCLICK"; 
  618.   if (AskPhone==2) then 
  619.   { 
  620.     _fooS "PHONE"; 
  621.     set AskPhone=0; 
  622.     PauseRecord ; 
  623.     _on thischn ReleasePhone []; 
  624.     0 
  625.   } 
  626.   else if (AskPhone==1) then 
  627.   { 
  628.     set AskPhone=0; 
  629.     PauseRecord ; 
  630.     _on thischn ReleasePhone []; 
  631.   } 
  632.   else 
  633.   { 
  634.     PauseRecord ; 
  635.     0 
  636.   } 
  637. };; 
  638.  
  639. defcom HaveVideo=HaveVideo I I I S I;; 
  640. defcom HadVideo=HadVideo;; 
  641.  
  642. var videosend=0;; 
  643. var localframe=0;;
  644.  
  645. var tempv="";; 
  646.  
  647. fun __HadVideo ()= 
  648. {  
  649.   if (videoready==nil || sendvideo==0 || localframe==globalframe) then {_on thischn HadVideo []; nil}
  650.   else 
  651.   { 
  652.     set localframe=globalframe;
  653.     set tempv=strdup videoready; 
  654.     let tempv->s2 in 
  655.       let strlen s2 -> len in 
  656.       { 
  657.         while (len!=0) do 
  658.         { 
  659.           _fooS "Sending Video"; 
  660.           if (len>256) then 
  661.           { 
  662.             let substr s2 0 256 -> sb in 
  663.               _on thischn HaveVideo [quality vx vy sb 0]; 
  664.               set s2=substr s2 256 len; 
  665.               set len=len-256; 
  666.           } 
  667.           else 
  668.           { 
  669.             _on thischn HaveVideo [quality vx vy s2 1]; 
  670.             set videosend=videosend+1; 
  671.             set len=0; 
  672.           } 
  673.         } 
  674.       } 
  675.   } 
  676. };; 
  677.  
  678. typeof CurrentFrame=S;; 
  679.  
  680. fun __HaveVideo (q,w,h,vid,EndTrame)= 
  681.   if vid!=nil then 
  682.     if EndTrame==1 then 
  683.     { 
  684.       set CurrentFrame=strcat CurrentFrame vid; 
  685.       _SETbitmap VideoBMP _InvertCapBitmap (_c32to15 (_JDecomp CurrentFrame h w q)) w; 
  686.       _BLTbitmap Chatw VideoBMP 310 115; 
  687.       _on thischn HadVideo []; 
  688.       set CurrentFrame=nil; 
  689.     } 
  690.     else 
  691.     { 
  692.       set CurrentFrame=strcat CurrentFrame vid; 
  693.     }
  694.   else 
  695.   { 
  696.     _on thischn HadVideo []; 
  697.     nil; 
  698.   } 
  699. };; 
  700.  
  701. typeof Chatmenu=ObjMenu;; 
  702. typeof Linksmenu=ObjMenu;; 
  703.  
  704. fun SendVideoCheck (o,u,i)=
  705. /*  _fooS "SendvideoCheckBox :"; _fooI i;*/
  706.   set sendvideo=i;;
  707.  
  708. fun InitChatWindow ()= 
  709.   set SendFileF=@SendFile; 
  710.   set Chatw=_CRwindow _channel nil 400 100 490 250 (WN_MENU+WN_MINBOX) strloc loc "TITLE" servernick::(_channelIP _channel)::nil; 
  711.   set mainobj=Chatw; 
  712.   _CBwinPaint Chatw @Chatwpaint 0; 
  713.   _CBwinDestroy Chatw @Chatwdestroy 0; 
  714.   _CBwinClick Chatw @PhoneClick 0; 
  715.   _CBwinUnclick Chatw @PhoneUnclick 0; 
  716.   set chatinput=_CReditText _channel Chatw 5 230 300 20 ET_DOWN|ET_AHSCROLL|ET_AVSCROLL ""; 
  717.   _CBtext chatinput @textinputCB 0; 
  718.   set chattext =_CRtext _channel Chatw 5 5 300 220 ET_DOWN|ET_AVSCROLL|ET_VSCROLL|ET_BORDER ""; 
  719.   set userlist=_CRcombo _channel Chatw 310 5 100 210 CB_NOEDIT|CB_AHSCROLL ""; 
  720.   set userinfo=_CRbutton _channel Chatw 310 35 100 20 0 loc "GETINFOS"; 
  721.   _CBbutton userinfo @GetUserInfos 0; 
  722.   set sendfile=_CRbutton _channel Chatw 310 60 100 20 0 loc "SENDFILE"; 
  723.   _CBbutton sendfile @SendFile 0; 
  724.   set connect=_CRbutton _channel Chatw 310 85 100 20 0 loc "CHAT"; 
  725.   _CBbutton connect @Connect 0;  
  726.   _AFFfontText chattext mediumfont; 
  727.   _AFFfontText chatinput mediumfont; 
  728.   _AFFfontButton userinfo mediumfont; 
  729.   _AFFfontButton sendfile mediumfont; 
  730.   _AFFfontButton connect mediumfont;  
  731.   set Chatmenu=_CRmenu _channel Chatw; 
  732.   set Linksmenu=_APPpopup _channel Chatmenu loc "LINKS"; 
  733.   set VideoBMP=_CRbitmap _channel vx vy; 
  734.   set Videobmp=_LDjpeg _channel _checkpack loc "JPGVID"; 
  735.   _BLTbitmap Chatw Videobmp 310 115;
  736.   let _CBcheck (_CRcheck _channel Chatw 415 85 100 30 0 loc "SENDVID") @SendVideoCheck 0 -> ck in
  737.     _SETcheck ck (set sendvideo=(if (strcmp _getress "VideoCamera" "Yes") then 0 else 1));
  738.   _PAINTwindow Chatw; 
  739. };; 
  740.  
  741. fun LinksMenu (obj,link)= 
  742.   print strloc loc "NEWL" link::nil; 
  743.   Contact link; 
  744. };; 
  745.  
  746. fun __AddLink (name,link)= 
  747. {
  748.   _CBmenu (_APPitem _channel Linksmenu ME_ENABLED name ) @LinksMenu link; 
  749. };; 
  750.  
  751. fun InitChat (nick,room)= 
  752.   set servernick=nick; 
  753.   set serverisroom=room; 
  754.   set serverIP=_channelIP _channel; 
  755.   set MyNick=_GETtext nickname; 
  756.   _status strcat strcat "Chating with " nick ".\n"; 
  757.   set thischn=_channel; 
  758.   set thisenv=_envchannel _channel; 
  759.   _status "Module Loaded\n"; 
  760.   PHONEInit; 
  761.   _on _channel ChatACK [MyNick]; 
  762.   InitChatWindow; 
  763.   initvideo; 
  764.   _on _channel HaveVideo [quality vx vy nil 1]; 
  765.   _on _channel NewUser [MyNick 0 _hostIP]; 
  766.   0 
  767. };; 
  768.  
  769. fun __ChatACK (nick)=0;; 
  770.  
  771. fun _connected ()= 
  772.   _status "Connected.\n" 
  773. };; 
  774.  
  775. fun _closed ()= 
  776.   _status strcat strcat strcat strcat "Disconnected from " servernick " (" serverIP ").\n"; 
  777.   _delline _channel;  
  778.   stopvideo;
  779. };; 
  780.  
  781. fun __GetAudio (audio)= 
  782.   if (RedirectAudio<2) then 
  783.     if (force_record==0) then 
  784.       if (playing==0) then 
  785.       { 
  786.         if (sizelist Alist)<5 then nil 
  787.         else startplaysnd; 
  788.         set Alist=AddAudio Alist audio; 
  789.         0
  790.       } 
  791.       else 
  792.       { 
  793.         set Alist=AddAudio Alist audio; 
  794.         0 
  795.       } 
  796.       else if (playing==0) then 0 
  797.       else 
  798.       { 
  799.         set Alist=AddAudio Alist audio; 
  800.         0 
  801.       } 
  802.       else 0;
  803.       if (RedirectAudio>0) then 
  804.       { 
  805.         _on APIchn GetAudio [audio]; 
  806.         0 
  807.       } 
  808.       else 0;;
  809.  
  810.