home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Online / StrICQ / Src / STRICQRexx.c < prev    next >
C/C++ Source or Header  |  2000-02-16  |  15KB  |  657 lines

  1. /*
  2.  
  3. STRICQ - An Amiga, MUI Based, ICQ Clone.
  4. Copyright (C) 1998-2000 Douglas F. McLaughlin
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20. Douglas F. McLaughlin - stricq@owlnet.net
  21.  
  22. */
  23.  
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <time.h>
  27.  
  28. #include <libraries/icq.h>
  29.  
  30. #include <proto/asyncio.h>
  31. #include <proto/dos.h>
  32. #include <proto/exec.h>
  33. #include <proto/intuition.h>
  34. #include <proto/miami.h>
  35. #include <proto/utility.h>
  36.  
  37. #include <rexx/storage.h>
  38.  
  39. #include "STRICQMUI.h"
  40.  
  41. #include <proto/socket.h>
  42.  
  43. #define ICQRC "ICQRC"
  44.  
  45.  
  46. LONG __asm RxStatus(REG(a2) APTR, REG(a1) ULONG *);
  47. LONG __asm RxGetContact(REG(a2) APTR, REG(a1) ULONG *);
  48. LONG __asm RxSendMessage(REG(a2) APTR, REG(a1) ULONG *);
  49. LONG __asm RxWinControl(REG(a2) APTR, REG(a1) ULONG *);
  50. LONG __asm RxAddFile(REG(a2) APTR, REG(a1) ULONG *);
  51. LONG __asm RxFileDirect(REG(a2) APTR, REG(a1) ULONG *);
  52. LONG __asm RxGetVersion(REG(a2) APTR, REG(a1) ULONG *);
  53. LONG __asm RxDeleteUIN(REG(a2) APTR, REG(a1) ULONG *);
  54. LONG __asm RxGetFiles(REG(a2) APTR, REG(a1) ULONG *);
  55. LONG __asm RxAcceptChatFile(REG(a2) APTR, REG(a1) ULONG *);
  56.  
  57. extern BOOL CreateUserWin(ULONG);
  58. extern struct Contact *GetContact(ULONG);
  59. extern char *FindCountryName(UWORD);
  60. extern ULONG GetSize(struct FileList *);
  61. extern struct ColorText *GetStatus(ULONG);
  62. extern void SendAMessage(APTR, ULONG, char *, UWORD, UBYTE, int);
  63. extern void __asm SendFileSend(REG(a2) APTR);
  64. extern LONG __asm SetFileSendStats(REG(a2) APTR);
  65. extern BOOL StartChat(struct Contact *, BOOL);
  66. extern BOOL StartFileXFer(struct Contact *, BOOL);
  67. extern void DeleteUIN(ULONG);
  68. extern void __asm Accept(REG(a2) APTR);
  69. extern void __asm Refuse(REG(a2) APTR);
  70.  
  71.  
  72. extern BOOL Online, ARexx;
  73.  
  74. extern char version_string[], *Statii[];
  75.  
  76. extern ULONG AsyncBuf;
  77.  
  78. extern struct ObjApp *app;
  79.  
  80.  
  81. LONG __asm RxStatus(REG(a2) APTR obj, REG(a1) ULONG *array)
  82.  
  83. {
  84.  
  85. BOOL getstat, all;
  86.  
  87. char *c, *newstat, *newvar, var[20], val[10];
  88.  
  89. LONG index;
  90.  
  91. struct RexxMsg *rxmsg = NULL;
  92.  
  93. newstat = (char *)*array; array++;
  94. getstat = *array; array++;
  95. all     = *array; array++;
  96. newvar  = (char *)*array;
  97.  
  98. if (!newvar) newvar = ICQRC;
  99. else for(c = newvar; *c; c++) *c = ToUpper(*c);
  100.  
  101. get(obj,MUIA_Application_RexxMsg,&rxmsg);
  102.  
  103. if (all) {
  104.   sprintf(val,"%d",NUM_STATUS);
  105.   SetRexxVar((struct Message *)rxmsg,newvar,val,strlen(val));
  106.   for(index = 0; index < NUM_STATUS; index++) {
  107.     sprintf(var,"%s.%d",newvar,index);
  108.     SetRexxVar((struct Message *)rxmsg,var,Statii[index],strlen(Statii[index]));
  109.   }
  110.   return(0);
  111. }
  112.  
  113. if (getstat) {
  114.   get(app->CY_MyStatus,MUIA_Cycle_Active,&index);
  115.   if (index < NUM_STATUS-1 && !Online) index = NUM_STATUS-1;
  116.   SetRexxVar((struct Message *)rxmsg,newvar,Statii[index],strlen(Statii[index]));
  117. }
  118.  
  119. if (newstat) {
  120.   for(c = newstat; *c; c++) if (*c == '_') *c = ' ';
  121.   for(index = 0; index < NUM_STATUS; index++) {
  122.     if (!stricmp(newstat,Statii[index])) {
  123.       set(app->CY_MyStatus,MUIA_Cycle_Active,index);
  124.       break;
  125.     }
  126.   }
  127.   if (index == NUM_STATUS) return(5);
  128. }
  129.  
  130. return(0);
  131.  
  132. }
  133.  
  134.  
  135. LONG __asm RxGetContact(REG(a2) APTR obj, REG(a1) ULONG *array)
  136.  
  137. {
  138.  
  139. BOOL total, sel;
  140.  
  141. char *c, *uinstr, *entrystr, *newvar, var[50], val[512], *val2;
  142.  
  143. ULONG uin, entry, entries;
  144.  
  145. struct ColorText *ct;
  146. struct Contact   *user;
  147. struct RexxMsg   *rxmsg = NULL;
  148.  
  149. uinstr   = (char *)*array; array++;
  150. entrystr = (char *)*array; array++;
  151. sel      = *array; array++;
  152. total    = *array; array++;
  153. newvar   = (char *)*array;
  154.  
  155. if (uinstr)   StrToLong(uinstr,(LONG *)&uin);
  156. if (entrystr) StrToLong(entrystr,(LONG *)&entry);
  157.  
  158. get(obj,MUIA_Application_RexxMsg,&rxmsg);
  159.  
  160. if (!newvar) newvar = ICQRC;
  161. else for(c = newvar; *c; c++) *c = ToUpper(*c);
  162.  
  163. get(app->LV_OfflineList,MUIA_NList_Entries,&entries);
  164.  
  165. if (total) {
  166.   sprintf(val,"%ld",entries);
  167.   SetRexxVar((struct Message *)rxmsg,newvar,val,strlen(val));
  168.   return(0);
  169. }
  170.  
  171. if (uinstr) {
  172.   if (!(user = GetContact(uin))) return(5);
  173.   if (user->Status == STAT_NEWUIN) return(5);
  174. }
  175. else {
  176.   if (sel) get(app->LV_OfflineList,MUIA_NList_Active,&entry);
  177.   if (entry >= entries || entry < 0) return(5);
  178.   DoMethod(app->LV_OfflineList,MUIM_NList_GetEntry,entry,&user);
  179. }
  180.  
  181. sprintf(var,"%s.UIN",newvar);
  182. sprintf(val,"%ld",user->UIN);
  183. SetRexxVar((struct Message *)rxmsg,var,val,strlen(val));
  184.  
  185. sprintf(var,"%s.NICK",newvar);
  186. val2 = (user->Nick?user->Nick:LINE);
  187. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  188.  
  189. sprintf(var,"%s.FIRST",newvar);
  190. val2 = (user->First?user->First:LINE);
  191. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  192.  
  193. sprintf(var,"%s.LAST",newvar);
  194. val2 = (user->Last?user->Last:LINE);
  195. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  196.  
  197. sprintf(var,"%s.EMAIL",newvar);
  198. val2 = (user->EMail?user->EMail:LINE);
  199. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  200.  
  201. sprintf(var,"%s.EMAIL_SECONDARY",newvar);
  202. val2 = (user->EMail_Secondary?user->EMail_Secondary:LINE);
  203. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  204.  
  205. sprintf(var,"%s.EMAIL_OLD",newvar);
  206. val2 = (user->EMail_Old?user->EMail_Old:LINE);
  207. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  208.  
  209. sprintf(var,"%s.CITY",newvar);
  210. val2 = (user->City?user->City:LINE);
  211. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  212.  
  213. sprintf(var,"%s.STATE",newvar);
  214. val2 = (user->State?user->State:LINE);
  215. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  216.  
  217. sprintf(var,"%s.COUNTRY",newvar);
  218. if (user->Country == 0xffff) strcpy(val,"Unspecified");
  219. else sprintf(val,"%s",FindCountryName(user->Country));
  220. SetRexxVar((struct Message *)rxmsg,var,val,strlen(val));
  221.  
  222. sprintf(var,"%s.PHONE",newvar);
  223. val2 = (user->Phone?user->Phone:LINE);
  224. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  225.  
  226. sprintf(var,"%s.FAX",newvar);
  227. val2 = (user->FAX?user->FAX:LINE);
  228. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  229.  
  230. sprintf(var,"%s.CELLULAR",newvar);
  231. val2 = (user->Cellular?user->Cellular:LINE);
  232. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  233.  
  234. sprintf(var,"%s.HOMEPAGE",newvar);
  235. val2 = (user->HomePage?user->HomePage:LINE);
  236. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  237.  
  238. sprintf(var,"%s.AGE",newvar);
  239. if (user->Age == 0xffff) strcpy(val,"Unspecified");
  240. else sprintf(val,"%d",user->Age);
  241. SetRexxVar((struct Message *)rxmsg,var,val,strlen(val));
  242.  
  243. sprintf(var,"%s.SEX",newvar);
  244. switch(user->Sex) {
  245.   case 0x00:
  246.     strcpy(val,"Unspecified");
  247.     break;
  248.   case 0x01:
  249.     strcpy(val,"Female");
  250.     break;
  251.   case 0x02:
  252.     strcpy(val,"Male");
  253.     break;
  254. };
  255. SetRexxVar((struct Message *)rxmsg,var,val,strlen(val));
  256.  
  257. sprintf(var,"%s.ABOUT",newvar);
  258. val2 = (user->About?user->About:LINE);
  259. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  260.  
  261. sprintf(var,"%s.COMMENT",newvar);
  262. val2 = (user->Comment?user->Comment:LINE);
  263. SetRexxVar((struct Message *)rxmsg,var,val2,strlen(val2));
  264.  
  265. sprintf(var,"%s.IP",newvar);
  266. sprintf(val,"%s",Inet_NtoA(user->IP));
  267. SetRexxVar((struct Message *)rxmsg,var,val,strlen(val));
  268.  
  269. sprintf(var,"%s.PORT",newvar);
  270. sprintf(val,"%d",user->Port);
  271. SetRexxVar((struct Message *)rxmsg,var,val,strlen(val));
  272.  
  273. sprintf(var,"%s.NEWMSGS",newvar);
  274. sprintf(val,"%d",user->NewMsg);
  275. SetRexxVar((struct Message *)rxmsg,var,val,strlen(val));
  276.  
  277. sprintf(var,"%s.STATUS",newvar);
  278. ct = GetStatus(user->Status);
  279. SetRexxVar((struct Message *)rxmsg,var,ct->Status,strlen(ct->Status));
  280.  
  281. sprintf(var,"%s.LAST_ONLINE",newvar);
  282. sprintf(val,"%s",ctime(&user->LastOnline));
  283. LASTCHAR(val) = '\0';
  284. SetRexxVar((struct Message *)rxmsg,var,val,strlen(val));
  285.  
  286. sprintf(var,"%s.MESSAGE_TO",newvar);
  287. sprintf(val,"%s",ctime(&user->LastMessageTo));
  288. LASTCHAR(val) = '\0';
  289. SetRexxVar((struct Message *)rxmsg,var,val,strlen(val));
  290.  
  291. sprintf(var,"%s.MESSAGE_FROM",newvar);
  292. sprintf(val,"%s",ctime(&user->LastMessageFm));
  293. LASTCHAR(val) = '\0';
  294. SetRexxVar((struct Message *)rxmsg,var,val,strlen(val));
  295.  
  296. return(0);
  297.  
  298. }
  299.  
  300.  
  301. LONG __asm RxSendMessage(REG(a2) APTR obj, REG(a1) ULONG *array)
  302.  
  303. {
  304.  
  305. char *uinstr, *msgstr, *urlstr, *file, *dest, msg[2048];
  306.  
  307. UBYTE both = MSG_BOTH;
  308.  
  309. ULONG uin, len;
  310.  
  311. UWORD type;
  312.  
  313. struct AsyncFile *load_fh;
  314. struct FileList   File;
  315.  
  316. uinstr = (char *)*array; array++;
  317. msgstr = (char *)*array; array++;
  318. urlstr = (char *)*array; array++;
  319. file   = (char *)*array; array++;
  320. dest   = (char *)*array;
  321.  
  322. if (dest) {
  323.   if (!stricmp(dest,"BOTH"))   both = MSG_BOTH;
  324.   if (!stricmp(dest,"LOCAL"))  both = MSG_LOCAL;
  325.   if (!stricmp(dest,"REMOTE")) both = MSG_REMOTE;
  326. }
  327.  
  328. if (!Online && both != MSG_LOCAL) return(10);
  329.  
  330. if (!uinstr) return(5);
  331.  
  332. if (file) {
  333.   strcpy(File.Filename,file);
  334.   len = GetSize(&File);
  335.   if (!(load_fh = OpenAsync(file,MODE_READ,AsyncBuf))) return(15);
  336.   ReadAsync(load_fh,msg,len);
  337.   CloseAsync(load_fh);
  338.   *(msg+len) = '\0';
  339.   msgstr = msg;
  340. //printf("%s\n",msg);
  341. }
  342.  
  343. if (uinstr) StrToLong(uinstr,(LONG *)&uin);
  344.  
  345. if (urlstr) {
  346.   sprintf(msg,"%s\xFE%s",msgstr,urlstr);
  347.   type = 0x04;
  348. }
  349. else {
  350.   if (!file) strcpy(msg,msgstr);
  351.   type = 0x01;
  352. }
  353.  
  354. ARexx = TRUE;
  355.  
  356. SendAMessage(NULL,uin,msg,type,both,MSG_VIA_BEST);
  357.  
  358. ARexx = FALSE;
  359.  
  360. return(0);
  361.  
  362. }
  363.  
  364.  
  365. LONG __asm RxWinControl(REG(a2) APTR obj, REG(a1) ULONG *array)
  366.  
  367. {
  368.  
  369. BOOL open, close, state = TRUE, ret = TRUE;
  370.  
  371. char *win, *uinstr;
  372.  
  373. ULONG uin = 0, uin2 = 0;
  374.  
  375. struct Contact *user;
  376.  
  377. win    = (char *)*array; array++;
  378. open   = *array; array++;
  379. close  = *array; array++;
  380. uinstr = (char *)*array;
  381.  
  382. if (close) state = FALSE;
  383.  
  384. if (win) StrToLong(win,(LONG *)&uin);
  385.  
  386. if (uinstr) StrToLong(uinstr,(LONG *)&uin2);
  387.  
  388. if (uin) {
  389.   if (user = GetContact(uin)) {
  390.     if (!user->UWin) CreateUserWin(uin);
  391.     if (user->UWin) {
  392.       set(user->UWin->WI_UserWindow,MUIA_Window_Open,state);
  393.       return(0);
  394.     }
  395.     else return(5);
  396.   }
  397.   return(10);
  398. }
  399.  
  400. if (uin2) {
  401.   if (user = GetContact(uin2)) {
  402.     if (!user->UWin) CreateUserWin(uin2);
  403.     if (user->UWin) {
  404.       if (!stricmp(win,"TRANSFER") && (ret = StartFileXFer(user,FALSE))) set(user->FWin->WI_FileWin,MUIA_Window_Open,state);
  405. //    if (!stricmp(win,"CHAT") && (ret = StartChat(user,FALSE))) set(user->CWin->WI_ChatWin,MUIA_Window_Open,state);
  406.       if (ret) return(0);
  407.       else return(5);
  408.     }
  409.     else return(5);
  410.   }
  411.   return(10);
  412. }
  413.  
  414. if (!stricmp(win,"FILEDIRECT")) set(app->WI_FileSendOut,MUIA_Window_Open,state);
  415. if (!stricmp(win,"ACTIVITYLOG")) set(app->WI_Activities,MUIA_Window_Open,state);
  416. if (!stricmp(win,"ACTIVESOCKETS")) set(app->WI_Sockets,MUIA_Window_Open,state);
  417. if (!stricmp(win,"MESSAGEHISTORY")) set(app->WI_MessageHist,MUIA_Window_Open,state);
  418. if (!stricmp(win,"STRICQLOG")) set(app->WI_Log,MUIA_Window_Open,state);
  419. if (!stricmp(win,"INCOMINGMESSAGES")) set(app->WI_Message,MUIA_Window_Open,state);
  420. if (!stricmp(win,"SYSTEMMESSAGE")) set(app->WI_URLMessage,MUIA_Window_Open,state);
  421. if (!stricmp(win,"USERINFORMATION")) set(app->WI_Information,MUIA_Window_Open,state);
  422. if (!stricmp(win,"ICQPREFERENCES")) set(app->WI_ICQPrefs,MUIA_Window_Open,state);
  423. if (!stricmp(win,"STRICQ")) set(app->WI_Main,MUIA_Window_Open,state);
  424. if (!stricmp(win,"PAGERMESSAGES")) set(app->WI_WebPager,MUIA_Window_Open,state);
  425.  
  426. return(0);
  427.  
  428. }
  429.  
  430.  
  431. LONG __asm RxAddFile(REG(a2) APTR obj, REG(a1) ULONG *array)
  432.  
  433. {
  434.  
  435. BOOL rem, clr;
  436.  
  437. char *file;
  438.  
  439. int i;
  440.  
  441. ULONG total;
  442.  
  443. struct FileList Files, *files;
  444.  
  445. file = (char *)*array; array++;
  446. rem  = *array; array++;
  447. clr  = *array;
  448.  
  449. if (clr) {
  450.   DoMethod(app->LV_FileList,MUIM_NList_Clear);
  451.   return(0);
  452. }
  453.  
  454. if (rem) {
  455.   get(app->LV_FileList,MUIA_NList_Entries,&total);
  456.   if (total) {
  457.     for(i = 0; i < total; i++) {
  458.       DoMethod(app->LV_FileList,MUIM_NList_GetEntry,i,&files);
  459.       if (files) {
  460.         if (!stricmp(file,files->Filename)) {
  461.           DoMethod(app->LV_FileList,MUIM_NList_Remove,i);
  462.           SetFileSendStats(NULL);
  463.           return(0);
  464.         }
  465.       }
  466.     }
  467.   }
  468.   return(5);
  469. }
  470.  
  471. strcpy(Files.Filename,file);
  472.  
  473. if (!GetSize(&Files)) return(5);
  474.  
  475. DoMethod(app->LV_FileList,MUIM_NList_InsertSingle,&Files,MUIV_NList_Insert_Sorted);
  476.  
  477. SetFileSendStats(NULL);
  478.  
  479. return(0);
  480.  
  481. }
  482.  
  483.  
  484. LONG __asm RxFileDirect(REG(a2) APTR obj, REG(a1) ULONG *array)
  485.  
  486. {
  487.  
  488. char *uinstr, *desc, *speedstr;
  489.  
  490. ULONG uin, total, speed = 100;
  491.  
  492. struct Contact *user;
  493.  
  494. uinstr   = (char *)*array; array++;
  495. speedstr = (char *)*array; array++;
  496. desc     = (char *)*array;
  497.  
  498. if (uinstr) StrToLong(uinstr,(LONG *)&uin);
  499.  
  500. if (speedstr) {
  501.   StrToLong(speedstr,(LONG *)&speed);
  502.   if (speed > 100) speed = 100;
  503. }
  504.  
  505. get(app->LV_FileList,MUIA_NList_Entries,&total);
  506.  
  507. if (!uin || !total) return(5);
  508.  
  509. if (!desc) desc = "Here are some files.";
  510.  
  511. set(app->TI_FileReason,MUIA_Textinput_Contents,desc);
  512.  
  513. set(app->BT_SendFile,MUIA_UserData,uin);
  514.  
  515. if (user = GetContact(uin)) {
  516.   if (!user->UWin) CreateUserWin(uin);
  517.   if (user->UWin) {
  518.     if (StartFileXFer(user,FALSE)) set(user->FWin->NU_Speed,MUIA_Numeric_Value,speed);
  519.     SendFileSend(app->BT_SendFile);
  520.   }
  521.   else return(10);
  522. }
  523.  
  524. return(0);
  525.  
  526. }
  527.  
  528.  
  529. LONG __asm RxGetVersion(REG(a2) APTR obj, REG(a1) ULONG *array)
  530.  
  531. {
  532.  
  533. BOOL full;
  534.  
  535. char vers[12], *tmp;
  536.  
  537. DOUBLE version;
  538.  
  539. struct RexxMsg *rxmsg = NULL;
  540.  
  541. full = *array;
  542.  
  543. get(obj,MUIA_Application_RexxMsg,&rxmsg);
  544.  
  545. if (full) tmp = version_string;
  546. else {
  547.   version = strtod(version_string+13,NULL);
  548.   sprintf(vers,"%.4f",version);
  549.   tmp = vers;
  550. }
  551.  
  552. SetRexxVar((struct Message *)rxmsg,ICQRC,tmp,strlen(tmp));
  553.  
  554. return(0);
  555.  
  556. }
  557.  
  558.  
  559. LONG __asm RxDeleteUIN(REG(a2) APTR obj, REG(a1) ULONG *array)
  560.  
  561. {
  562.  
  563. char *uinstr;
  564.  
  565. ULONG uin;
  566.  
  567. uinstr = (char *)*array;
  568.  
  569. if (uinstr) StrToLong(uinstr,(LONG *)&uin);
  570.  
  571. if (uin) {
  572.   if (!GetContact(uin)) return(10);
  573.   DeleteUIN(uin);
  574. }
  575.  
  576. return(0);
  577.  
  578. }
  579.  
  580.  
  581. LONG __asm RxGetFiles(REG(a2) APTR obj, REG(a1) ULONG *array)
  582.  
  583. {
  584.  
  585. char *newvar, var[50], val[32], *c;
  586.  
  587. int i;
  588.  
  589. ULONG total;
  590.  
  591. struct FileList *file;
  592. struct RexxMsg *rxmsg = NULL;
  593.  
  594. newvar = (char *)*array;
  595.  
  596. get(obj,MUIA_Application_RexxMsg,&rxmsg);
  597.  
  598. if (!newvar) newvar = ICQRC;
  599. else for(c = newvar; *c; c++) *c = ToUpper(*c);
  600.  
  601. get(app->LV_FileList,MUIA_NList_Entries,&total);
  602.  
  603. if (total == 0) return(5);
  604.  
  605. sprintf(var,"%s.0",newvar);
  606. sprintf(val,"%ld",total);
  607. SetRexxVar((struct Message *)rxmsg,var,val,strlen(val));
  608.  
  609. for(i = 0; i < total; i++) {
  610.   DoMethod(app->LV_FileList,MUIM_NList_GetEntry,i,&file);
  611.   if (file) {
  612.     sprintf(var,"%s.NAME.%d",newvar,i);
  613.     SetRexxVar((struct Message *)rxmsg,var,file->Filename,strlen(file->Filename));
  614.     sprintf(var,"%s.SIZE.%d",newvar,i);
  615.     sprintf(val,"%ld",file->Filesize);
  616.     SetRexxVar((struct Message *)rxmsg,var,val,strlen(val));
  617.   }
  618. }
  619.  
  620. return(0);
  621.  
  622. }
  623.  
  624.  
  625. LONG __asm RxAcceptChatFile(REG(a2) APTR obj, REG(a1) ULONG *array)
  626.  
  627. {
  628.  
  629. BOOL accept = TRUE, acc, dec;
  630.  
  631. char *uinstr;
  632.  
  633. ULONG uin = 0;
  634.  
  635. struct Contact *user;
  636.  
  637. uinstr = (char *)*array; *array++;
  638. acc = *array; *array++;
  639. dec = *array;
  640.  
  641. if (dec) accept = FALSE;
  642.  
  643. if (uinstr) StrToLong(uinstr,(LONG *)&uin);
  644.  
  645. if (!uin) return(20);
  646.  
  647. if (!(user = GetContact(uin))) return(5);
  648.  
  649. if (!user->CFWin) return(10);
  650.  
  651. if (accept) Accept(user->CFWin->BT_Accept);
  652. else Refuse(user->CFWin->BT_Refuse);
  653.  
  654. return(0);
  655.  
  656. }
  657.