G'day all,
I've been working on a web frontend much like and based on Jon's recent 
rms-web. It has some some cool features, and I think will one day possibly
turn out to be a full featured client.

Screenshot here:
http://whatsbeef.net/philip/licqweb/licqweb.png
Check it out at:
http://whatsbeef.net/philip/licqweb/

I've also attached the patch that is required for this to work for the RMS 
plugin (minus that md5 thing, stupidest thing I've done for a while :P). Jon, 
would it be possible for this to be put this into rms cvs? It adds that 
NOTIFY command, ability to change protocol status and also fixes an issue 
with % formatting in received messages which would crash rms/licq (thanks for 
JG on irc for pointing this one out).

Philip
? autom4te.cache
? rms.diff
? stamp-h1
Index: src/rms.cpp
===================================================================
RCS file: /cvsroot/licq/rms/src/rms.cpp,v
retrieving revision 1.18
diff -r1.18 rms.cpp
45a46
> const unsigned short CODE_STATUSxDONE = 212;
54a56,57
> const unsigned short CODE_NOTIFYxON = 229;
> const unsigned short CODE_NOTIFYxOFF = 230;
74a78,80
> const unsigned short CODE_NOTIFYxSTATUS = 600;
> const unsigned short CODE_NOTIFYxMESSAGE = 601;
> 
119c125
<     "Set or show status.  Argument is new status, or blank to display current." },
---
>     "Set or show status.  Argument is new status and protocol, or blank to display current. { [ <status>[.<protocol>] ] }." },
127a134,135
>   { "NOTIFY", &CRMSClient::Process_NOTIFY,
>     "Notify events" },
199,200d206
<       printf("Could not start server on port %u, "
<              "maybe this port is already in use?\n", nPort);
252d257
<                 delete *iter;
253a259
>                 delete *iter;
348a355,397
>     if (s->SubSignal() == USER_STATUS)
>     {
>       ICQUser *u = gUserManager.FetchUser(s->Id(), s->PPID(), LOCK_R);
>       if (u)
>       {
>         ClientList::iterator iter;
>         for (iter = clients.begin(); iter != clients.end(); iter++)
>         {
>           if ((*iter)->m_bNotify)
>           {
>             char format[128], *ubuf;
> 			strcpy(format, "%u %P %-20a %3m %s");
> 			ubuf = u->usprintf(format);
>             fprintf((*iter)->fs, "%d %s\n", CODE_NOTIFYxSTATUS, ubuf);
> 			free(ubuf);
>             fflush((*iter)->fs);
>           }
>         }
>         gUserManager.DropUser(u);
>       }
>       break;
>     }
>     else if (s->SubSignal() == USER_EVENTS)
>     {
>       ICQUser *u = gUserManager.FetchUser(s->Id(), s->PPID(), LOCK_R);
>       if (u)
>       {
>         ClientList::iterator iter;
>         for (iter = clients.begin(); iter != clients.end(); iter++)
>         {
>           if ((*iter)->m_bNotify)
>           {
>             char format[128], *ubuf;
> 			strcpy(format, "%u %P %3m");
> 			ubuf = u->usprintf(format);
>             fprintf((*iter)->fs, "%d %s\n", CODE_NOTIFYxMESSAGE, ubuf);
> 			free(ubuf);
>             fflush((*iter)->fs);
>           }
>         }
>         gUserManager.DropUser(u);
>       }
>     }
403d451
< 
413a462
>   m_bNotify = false;
595c644
<          strcmp(o->Password(), data_line) == 0);
---
>          (strcmp(o->Password(), data_line) == 0));
761c810
<         fprintf(fs, "%d %s %s\n", CODE_STATUS, (*it)->Name(), o->StatusStr());
---
>         fprintf(fs, "%d %s %s %s\n", CODE_STATUS, o->IdString(), (*it)->Name(), o->StatusStr());
764a814
>     fprintf(fs, "%d\n", CODE_STATUSxDONE);
769c819,847
<   unsigned long nStatus = StringToStatus(data_arg);
---
>   string strData(data_arg);
>   string::size_type nPos = strData.find_last_of(".");
>   if (nPos == string::npos)
>   {
>     unsigned long nStatus = StringToStatus(data_arg);
>     ProtoPluginsList l;
>     ProtoPluginsListIter it;
>     licqDaemon->ProtoPluginList(l);
>     for (it = l.begin(); it != l.end(); it++)
>     {
>       ChangeStatus((*it)->PPID(), nStatus, data_arg);
>     }
>   }
>   else
>   {
>     string strStatus(strData, 0, strData.find_last_of("."));
>     string strProtocol(strData, strData.find_last_of(".")+1, strData.size());
>     unsigned long nPPID = GetProtocol(strProtocol.c_str());
>     char *szStatus = strdup(strStatus.c_str());
>     unsigned long nStatus = StringToStatus(szStatus);
>     ChangeStatus(nPPID, nStatus, szStatus);
>     free(szStatus);
>   }
>   fprintf(fs, "%d Done setting status\n", CODE_STATUSxDONE);
>   return fflush(fs);
> }
> 
> int CRMSClient::ChangeStatus(unsigned long nPPID, unsigned long nStatus, const char *szStatus)
> {
773c851
<     return fflush(fs);
---
>     return -1;
775,779c853
< 
<   ProtoPluginsList l;
<   ProtoPluginsListIter it;
<   licqDaemon->ProtoPluginList(l);
<   for (it = l.begin(); it != l.end(); it++)
---
>   if (nStatus == ICQ_STATUS_OFFLINE)
781c855,867
<     if (nStatus == ICQ_STATUS_OFFLINE)
---
>     fprintf(fs, "%d [0] Logging off %s.\n", CODE_COMMANDxSTART, szStatus);
>     fflush(fs);
>     licqDaemon->ProtoLogoff(nPPID);
>     fprintf(fs, "%d [0] Event done.\n", CODE_STATUSxDONE);
>     return 0;
>   }
>   else
>   {
>     ICQOwner *o = gUserManager.FetchOwner(nPPID, LOCK_R);
>     bool b = o->StatusOffline();
>     gUserManager.DropOwner(nPPID);
>     unsigned long tag = 0;
>     if (b)
783,787c869,870
<       fprintf(fs, "%d [0] Logging off %s.\n", CODE_COMMANDxSTART,
<         (*it)->Name());
<       fflush(fs);
<       licqDaemon->ProtoLogoff((*it)->PPID());
<       fprintf(fs, "%d [0] Event done.\n", CODE_RESULTxSUCCESS);
---
>       tag = licqDaemon->ProtoLogon(nPPID, nStatus);
>       fprintf(fs, "%d [%ld] Logging on to %s.\n", CODE_COMMANDxSTART, tag, szStatus);
791,807c874,875
<       ICQOwner *o = gUserManager.FetchOwner((*it)->PPID(), LOCK_R);
<       bool b = o->StatusOffline();
<       gUserManager.DropOwner((*it)->PPID());
<       unsigned long tag = 0;
<       if (b)
<       {
<         tag = licqDaemon->ProtoLogon((*it)->PPID(), nStatus);
<         fprintf(fs, "%d [%ld] Logging on to %s.\n", CODE_COMMANDxSTART, tag,
<           (*it)->Name());
<       }
<       else
<       {
<         tag = licqDaemon->ProtoSetStatus((*it)->PPID(), nStatus);
<         fprintf(fs, "%d [%ld] Setting status for %s.\n", CODE_COMMANDxSTART,
<           tag, (*it)->Name());
<       }
<       tags.push_back(tag);
---
>       tag = licqDaemon->ProtoSetStatus(nPPID, nStatus);
>       fprintf(fs, "%d [%ld] Setting status for %s.\n", CODE_COMMANDxSTART, tag, szStatus);
808a877
>     tags.push_back(tag);
810,811c879
<   
<   return fflush(fs);
---
>   return 0;
814d881
< 
987a1055
>   m_szText[strlen(m_szText) - 1] = '\0';
1212a1281,1301
> /*---------------------------------------------------------------------------
>  * CRMSClient::Process_NOTIFY
>  *
>  * Command:
>  *   NOTIFY
>  *
>  * Response:
>  *   CODE_NOTIFYxON|CODE_NOTIFYxOFF
>  *   ...
>  *-------------------------------------------------------------------------*/
> int CRMSClient::Process_NOTIFY()
> {
>   m_bNotify = !m_bNotify;
> 
>   if (m_bNotify)
>     fprintf(fs, "%d Notify set ON.\n", CODE_NOTIFYxON);
>   else
>     fprintf(fs, "%d Notify set OFF.\n", CODE_NOTIFYxOFF);
> 
>   return fflush(fs);
> }
1307c1396
<     fprintf(fs, e->Text());
---
>     fprintf(fs, "%s", e->Text());
Index: src/rms.h
===================================================================
RCS file: /cvsroot/licq/rms/src/rms.h,v
retrieving revision 1.10
diff -r1.10 rms.h
9a10,11
> #include <openssl/md5.h>
> 
84a87
>   int Process_NOTIFY();
96a100
>   bool m_bNotify;
110a115
>   int ChangeStatus(unsigned long, unsigned long, const char *);

Reply via email to