| | 355 | if (s->SubSignal() == USER_STATUS) |
| | 356 | { |
| | 357 | ICQUser *u = gUserManager.FetchUser(s->Id(), s->PPID(), LOCK_R); |
| | 358 | if (u) |
| | 359 | { |
| | 360 | ClientList::iterator iter; |
| | 361 | for (iter = clients.begin(); iter != clients.end(); iter++) |
| | 362 | { |
| | 363 | if ((*iter)->m_bNotify) |
| | 364 | { |
| | 365 | char format[128], *ubuf; |
| | 366 | strcpy(format, "%u %P %-20a %3m %s"); |
| | 367 | ubuf = u->usprintf(format); |
| | 368 | fprintf((*iter)->fs, "%d %s\n", CODE_NOTIFYxSTATUS, ubuf); |
| | 369 | free(ubuf); |
| | 370 | fflush((*iter)->fs); |
| | 371 | } |
| | 372 | } |
| | 373 | gUserManager.DropUser(u); |
| | 374 | } |
| | 375 | break; |
| | 376 | } |
| | 377 | else if (s->SubSignal() == USER_EVENTS) |
| | 378 | { |
| | 379 | ICQUser *u = gUserManager.FetchUser(s->Id(), s->PPID(), LOCK_R); |
| | 380 | if (u) |
| | 381 | { |
| | 382 | ClientList::iterator iter; |
| | 383 | for (iter = clients.begin(); iter != clients.end(); iter++) |
| | 384 | { |
| | 385 | if ((*iter)->m_bNotify) |
| | 386 | { |
| | 387 | char format[128], *ubuf; |
| | 388 | strcpy(format, "%u %P %3m"); |
| | 389 | ubuf = u->usprintf(format); |
| | 390 | fprintf((*iter)->fs, "%d %s\n", CODE_NOTIFYxMESSAGE, ubuf); |
| | 391 | free(ubuf); |
| | 392 | fflush((*iter)->fs); |
| | 393 | } |
| | 394 | } |
| | 395 | gUserManager.DropUser(u); |
| | 396 | } |
| | 397 | } |
| 769 | | unsigned long nStatus = StringToStatus(data_arg); |
| | 819 | string strData(data_arg); |
| | 820 | string::size_type nPos = strData.find_last_of("."); |
| | 821 | if (nPos == string::npos) |
| | 822 | { |
| | 823 | unsigned long nStatus = StringToStatus(data_arg); |
| | 824 | ProtoPluginsList l; |
| | 825 | ProtoPluginsListIter it; |
| | 826 | licqDaemon->ProtoPluginList(l); |
| | 827 | for (it = l.begin(); it != l.end(); it++) |
| | 828 | { |
| | 829 | ChangeStatus((*it)->PPID(), nStatus, data_arg); |
| | 830 | } |
| | 831 | } |
| | 832 | else |
| | 833 | { |
| | 834 | string strStatus(strData, 0, strData.find_last_of(".")); |
| | 835 | string strProtocol(strData, strData.find_last_of(".")+1, strData.size()); |
| | 836 | unsigned long nPPID = GetProtocol(strProtocol.c_str()); |
| | 837 | char *szStatus = strdup(strStatus.c_str()); |
| | 838 | unsigned long nStatus = StringToStatus(szStatus); |
| | 839 | ChangeStatus(nPPID, nStatus, szStatus); |
| | 840 | free(szStatus); |
| | 841 | } |
| | 842 | fprintf(fs, "%d Done setting status\n", CODE_STATUSxDONE); |
| | 843 | return fflush(fs); |
| | 844 | } |
| | 845 | |
| | 846 | int CRMSClient::ChangeStatus(unsigned long nPPID, unsigned long nStatus, const char *szStatus) |
| | 847 | { |
| 773 | | return fflush(fs); |
| 774 | | } |
| 775 | | |
| 776 | | ProtoPluginsList l; |
| 777 | | ProtoPluginsListIter it; |
| 778 | | licqDaemon->ProtoPluginList(l); |
| 779 | | for (it = l.begin(); it != l.end(); it++) |
| 780 | | { |
| 781 | | if (nStatus == ICQ_STATUS_OFFLINE) |
| 782 | | { |
| 783 | | fprintf(fs, "%d [0] Logging off %s.\n", CODE_COMMANDxSTART, |
| 784 | | (*it)->Name()); |
| 785 | | fflush(fs); |
| 786 | | licqDaemon->ProtoLogoff((*it)->PPID()); |
| 787 | | fprintf(fs, "%d [0] Event done.\n", CODE_RESULTxSUCCESS); |
| | 851 | return -1; |
| | 852 | } |
| | 853 | if (nStatus == ICQ_STATUS_OFFLINE) |
| | 854 | { |
| | 855 | fprintf(fs, "%d [0] Logging off %s.\n", CODE_COMMANDxSTART, szStatus); |
| | 856 | fflush(fs); |
| | 857 | licqDaemon->ProtoLogoff(nPPID); |
| | 858 | fprintf(fs, "%d [0] Event done.\n", CODE_STATUSxDONE); |
| | 859 | return 0; |
| | 860 | } |
| | 861 | else |
| | 862 | { |
| | 863 | ICQOwner *o = gUserManager.FetchOwner(nPPID, LOCK_R); |
| | 864 | bool b = o->StatusOffline(); |
| | 865 | gUserManager.DropOwner(nPPID); |
| | 866 | unsigned long tag = 0; |
| | 867 | if (b) |
| | 868 | { |
| | 869 | tag = licqDaemon->ProtoLogon(nPPID, nStatus); |
| | 870 | fprintf(fs, "%d [%ld] Logging on to %s.\n", CODE_COMMANDxSTART, tag, szStatus); |
| 791 | | ICQOwner *o = gUserManager.FetchOwner((*it)->PPID(), LOCK_R); |
| 792 | | bool b = o->StatusOffline(); |
| 793 | | gUserManager.DropOwner((*it)->PPID()); |
| 794 | | unsigned long tag = 0; |
| 795 | | if (b) |
| 796 | | { |
| 797 | | tag = licqDaemon->ProtoLogon((*it)->PPID(), nStatus); |
| 798 | | fprintf(fs, "%d [%ld] Logging on to %s.\n", CODE_COMMANDxSTART, tag, |
| 799 | | (*it)->Name()); |
| 800 | | } |
| 801 | | else |
| 802 | | { |
| 803 | | tag = licqDaemon->ProtoSetStatus((*it)->PPID(), nStatus); |
| 804 | | fprintf(fs, "%d [%ld] Setting status for %s.\n", CODE_COMMANDxSTART, |
| 805 | | tag, (*it)->Name()); |
| 806 | | } |
| 807 | | tags.push_back(tag); |
| 808 | | } |
| 809 | | } |
| 810 | | |
| 811 | | return fflush(fs); |
| 812 | | } |
| 813 | | |
| | 874 | tag = licqDaemon->ProtoSetStatus(nPPID, nStatus); |
| | 875 | fprintf(fs, "%d [%ld] Setting status for %s.\n", CODE_COMMANDxSTART, tag, szStatus); |
| | 876 | } |
| | 877 | tags.push_back(tag); |
| | 878 | } |
| | 879 | return 0; |
| | 880 | } |
| | 1281 | /*--------------------------------------------------------------------------- |
| | 1282 | * CRMSClient::Process_NOTIFY |
| | 1283 | * |
| | 1284 | * Command: |
| | 1285 | * NOTIFY |
| | 1286 | * |
| | 1287 | * Response: |
| | 1288 | * CODE_NOTIFYxON|CODE_NOTIFYxOFF |
| | 1289 | * ... |
| | 1290 | *-------------------------------------------------------------------------*/ |
| | 1291 | int CRMSClient::Process_NOTIFY() |
| | 1292 | { |
| | 1293 | m_bNotify = !m_bNotify; |
| | 1294 | |
| | 1295 | if (m_bNotify) |
| | 1296 | fprintf(fs, "%d Notify set ON.\n", CODE_NOTIFYxON); |
| | 1297 | else |
| | 1298 | fprintf(fs, "%d Notify set OFF.\n", CODE_NOTIFYxOFF); |
| | 1299 | |
| | 1300 | return fflush(fs); |
| | 1301 | } |