Show
Ignore:
Timestamp:
03/16/08 04:09:36 (9 months ago)
Author:
flynd
Message:

Ask protocol plugin which events are supported instead of just checking for ppid=msn.

Location:
trunk/qt4-gui/src/userevents
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/userevents/usereventcommon.cpp

    r6048 r6103  
    7474  } 
    7575 
     76  // Find out what's supported for this protocol 
     77  mySendFuncs = 0xFFFFFFFF; 
     78  if (ppid != LICQ_PPID) 
     79  { 
     80    FOR_EACH_PROTO_PLUGIN_START(gLicqDaemon) 
     81    { 
     82      if ((*_ppit)->PPID() == ppid) 
     83      { 
     84        mySendFuncs = (*_ppit)->SendFunctions(); 
     85        break; 
     86      } 
     87    } 
     88    FOR_EACH_PROTO_PLUGIN_END 
     89  } 
     90 
    7691  myCodec = QTextCodec::codecForLocale(); 
    7792  myIsOwner = (gUserManager.FindOwner(myUsers.front().c_str(), myPpid) != NULL); 
     
    131146  mySecure->setShortcut(Qt::ALT + Qt::Key_E); 
    132147  pushToolTip(mySecure, tr("Open / Close secure channel")); 
     148  if (!(mySendFuncs & PP_SEND_SECURE)) 
     149    mySecure->setEnabled(false); 
    133150 
    134151  tmrTime = NULL; 
  • trunk/qt4-gui/src/userevents/usereventcommon.h

    r6097 r6103  
    7171  time_t myRemoteTimeOffset; 
    7272  list<string> myUsers; 
     73  unsigned long mySendFuncs; 
    7374 
    7475  // ID of the higest event we've processed. Helps determine 
  • trunk/qt4-gui/src/userevents/usersendcommon.cpp

    r6101 r6103  
    4848#endif 
    4949 
     50#include <licq_icq.h> 
    5051#include <licq_icqd.h> 
    5152#include <licq_log.h> 
     
    129130 
    130131  QAction* action; 
    131  
    132   action = new QAction(tr("Message"), grpSendType); 
    133   action->setData(MessageEvent); 
    134   action->setCheckable(true); 
    135  
    136   action = new QAction(tr("URL"), grpSendType); 
    137   action->setData(UrlEvent); 
    138   action->setCheckable(true); 
    139  
    140   action = new QAction(tr("Chat Request"), grpSendType); 
    141   action->setData(ChatEvent); 
    142   action->setCheckable(true); 
    143  
    144   action = new QAction(tr("File Transfer"), grpSendType); 
    145   action->setData(FileEvent); 
    146   action->setCheckable(true); 
    147  
    148   action = new QAction(tr("Contact List"), grpSendType); 
    149   action->setData(ContactEvent); 
    150   action->setCheckable(true); 
    151  
    152   action = new QAction(tr("SMS"), grpSendType); 
    153   action->setData(SmsEvent); 
    154   action->setCheckable(true); 
     132  int eventTypesCount = 0; 
     133 
     134#define ADD_SENDTYPE(eventFlag, eventType, caption) \ 
     135    if (mySendFuncs & eventFlag) { \ 
     136      action = new QAction(caption, grpSendType); \ 
     137      action->setData(eventType); \ 
     138      action->setCheckable(true); \ 
     139      eventTypesCount++; \ 
     140    } 
     141 
     142  // Populated menu for switching event type 
     143  ADD_SENDTYPE(PP_SEND_MSG, MessageEvent, tr("Message")); 
     144  ADD_SENDTYPE(PP_SEND_URL, UrlEvent, tr("URL")); 
     145  ADD_SENDTYPE(PP_SEND_CHAT, ChatEvent, tr("Chat Request")); 
     146  ADD_SENDTYPE(PP_SEND_FILE, FileEvent, tr("File Transfer")); 
     147  ADD_SENDTYPE(PP_SEND_CONTACT, ContactEvent, tr("Contact List")); 
     148  ADD_SENDTYPE(PP_SEND_SMS, SmsEvent, tr("SMS")); 
     149 
     150#undef ADD_SENDTYPE 
    155151 
    156152  QMenu* mnuSendType = new QMenu(this); 
     
    161157  pushToolTip(cmbSendType, tr("Select type of message to send")); 
    162158  cmbSendType->setMenu(mnuSendType); 
    163   if (ppid == MSN_PPID) 
     159  if (eventTypesCount <= 1) 
    164160    cmbSendType->setEnabled(false); 
    165161 
     
    169165  chkSendServer->setCheckable(true); 
    170166 
     167  bool canSendDirect = (mySendFuncs & PP_SEND_DIRECT); 
     168 
    171169  ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    172170 
    173   if (u != 0) 
     171  if (u != NULL) 
    174172  { 
    175173    chkSendServer->setChecked(u->SendServer() || 
     
    177175 
    178176    if (u->GetInGroup(GROUPS_SYSTEM, GROUP_INVISIBLE_LIST) || 
    179         u->PPID() == MSN_PPID || 
    180177        (u->Port() == 0 && u->SocketDesc(ICQ_CHNxNONE) == -1)) 
    181     { 
    182       chkSendServer->setChecked(true); 
    183       chkSendServer->setEnabled(false); 
    184     } 
     178      canSendDirect = false; 
    185179 
    186180    gUserManager.DropUser(u); 
    187181  } 
    188   else 
     182  if (!canSendDirect) 
    189183  { 
    190184    chkSendServer->setChecked(true); 
     
    700694  { 
    701695    case MessageEvent: 
    702       e = new UserSendMsgEvent(myUsers.front().c_str(), myPpid, parent); 
     696      if (mySendFuncs & PP_SEND_MSG) 
     697        e = new UserSendMsgEvent(myUsers.front().c_str(), myPpid, parent); 
    703698      break; 
    704699    case UrlEvent: 
    705       e = new UserSendUrlEvent(myUsers.front().c_str(), myPpid, parent); 
     700      if (mySendFuncs & PP_SEND_URL) 
     701        e = new UserSendUrlEvent(myUsers.front().c_str(), myPpid, parent); 
    706702      break; 
    707703    case ChatEvent: 
    708       e = new UserSendChatEvent(myUsers.front().c_str(), myPpid, parent); 
     704      if (mySendFuncs & PP_SEND_CHAT) 
     705        e = new UserSendChatEvent(myUsers.front().c_str(), myPpid, parent); 
    709706      break; 
    710707    case FileEvent: 
    711       e = new UserSendFileEvent(myUsers.front().c_str(), myPpid, parent); 
     708      if (mySendFuncs & PP_SEND_FILE) 
     709        e = new UserSendFileEvent(myUsers.front().c_str(), myPpid, parent); 
    712710      break; 
    713711    case ContactEvent: 
    714       e = new UserSendContactEvent(myUsers.front().c_str(), myPpid, parent); 
     712      if (mySendFuncs & PP_SEND_CONTACT) 
     713        e = new UserSendContactEvent(myUsers.front().c_str(), myPpid, parent); 
    715714      break; 
    716715    case SmsEvent: 
    717       e = new UserSendSmsEvent(myUsers.front().c_str(), myPpid, parent); 
     716      if (mySendFuncs & PP_SEND_SMS) 
     717        e = new UserSendSmsEvent(myUsers.front().c_str(), myPpid, parent); 
    718718      break; 
    719719    default: 
     
    721721  } 
    722722 
    723   if (e != 0) 
     723  if (e != NULL) 
    724724  { 
    725725    if (e->mleSend != 0 && mleSend != 0)