Code Viewer

./ss_events.js File Size: 10.04 KB

  1. /*
  2. * -----
  3. * Screenshot Sender - ss_events.js
  4. * -----
  5. * Screenshot Sender Events
  6. * -----
  7. */
  8.  
  9. function LoadEventsSubclassWindow() {
  10.         _debug.getfuncname(arguments);
  11.         var oWindow = OpenWindow('ScreenshotSender_Subclass', WNDOPT_INVISIBLE | WNDOPT_NOACTIVATE, true);
  12.         RegisterWindowHooks(oWindow, [
  13.                 WM_CONTACTSIGNIN,
  14.                 WM_CONTACTSIGNOUT,
  15.                 WM_CONTACTSTATUSCHANGE,
  16.                 WM_CHATWNDOPEN,
  17.                 WM_CHATWNDCLOSED,
  18.                 WM_SCREENSHOTADDED,
  19.                 WM_IDLEUPLOAD
  20.         ]);
  21. }
  22.  
  23. function BroadcastEvent(nEvent, wParam, lParam) {
  24.         _debug.getfuncname(arguments);
  25.         if (typeof wParam === TYPE_UNDEFINED) wParam = 0;
  26.         if (typeof lParam === TYPE_UNDEFINED) lParam = 0;
  27.         _win32.PostMessageW(_win32._const._HWND_BROADCAST, nEvent, wParam, lParam);
  28. }
  29.  
  30. function OnEvent_MyStatusChange(nStatus) {
  31.         if (nStatus === STATUS_IDLE) {
  32.                 BroadcastEvent(WM_IDLEUPLOAD);
  33.         }
  34. }
  35.  
  36. function OnEvent_ContactStatusChange(sEmail, nStatus) {
  37.         BroadcastEvent(WM_CONTACTSTATUSCHANGE, sEmail, nStatus);
  38. }
  39.  
  40. function OnEvent_ContactSignIn(sEmail) {
  41.         BroadcastEvent(WM_CONTACTSIGNIN, sEmail);
  42. }
  43.  
  44. function OnEvent_ContactSignout(sEmail) {
  45.         BroadcastEvent(WM_CONTACTSIGNOUT, sEmail);
  46. }
  47.  
  48. function OnEvent_ContactBlocked(sEmail) {
  49.         BroadcastEvent(WM_CONTACTSIGNOUT, sEmail);
  50. }
  51.  
  52. function OnEvent_ContactUnblocked(sEmail) {
  53.         BroadcastEvent(WM_CONTACTSIGNIN, sEmail);
  54. }
  55.  
  56. function OnEvent_ChatWndCreated(oChatWnd) {
  57.         for (var o = new Enumerator(oChatWnd.Contacts); !o.atEnd(); o.moveNext()) {
  58.                 BroadcastEvent(WM_CHATWNDOPEN, o.item().Email);
  59.         }
  60. }
  61.  
  62. function OnEvent_ChatWndDestroyed(oChatWnd) {
  63.         for (var o = new Enumerator(oChatWnd.Contacts); !o.atEnd(); o.moveNext()) {
  64.                 BroadcastEvent(WM_CHATWNDCLOSED, o.item().Email);
  65.         }
  66. }
  67.  
  68. function OnScreenshotSender_SubclassEvent_MessageNotification(pPlusWnd, nMessage, wParam, lParam) {
  69.         _debug.getfuncname(arguments);
  70.         // Get the string from the wParam pointer
  71.         if (wParam !== 0) {
  72.                 var wParamPtr = Interop.Allocate(512);
  73.                 _win32.RtlMoveMemory(wParamPtr, wParam, 512);
  74.                 wParam = wParamPtr.ReadString(0);
  75.                 wParamPtr.Size = 0;
  76.         }
  77.        
  78.         var bAddContact = false;
  79.         switch (nMessage) {
  80.                 case WM_IDLEUPLOAD :
  81.                         Ftp_InitiateFileTransferOnIdle();
  82.                         break;
  83.                 case WM_SCREENSHOTADDED :
  84.                         RefreshScreenshotViewerList();
  85.                         break;
  86.                 case WM_CHATWNDOPEN :
  87.                         bAddContact = true;
  88.                 case WM_CHATWNDCLOSED :
  89.                        
  90.                         if (typeof objWindows['ContactSelector'] !== TYPE_UNDEFINED) {
  91.                                 var t = objWindows['ContactSelector'];
  92.                                 if (t.Button_IsChecked('chkShowConversationContacts')) {
  93.                                         var o = Messenger.MyContacts.GetContact(wParam);
  94.                                         var nIndex = ItemExistsInLstView(o.Email, t, 'LvContacts', 1);
  95.                                         if (bAddContact === true) {
  96.                                                 if (nIndex === false) {
  97.                                                         nIndex = t.LstView_AddItem('LvContacts', RemovePlusCodes(o.Name));
  98.                                                         t.LstView_SetItemText('LvContacts', nIndex, 1, o.Email);
  99.                                                         t.LstView_SetItemIcon('LvContacts', nIndex, oStatus[o.Status], true);
  100.                                                 }
  101.                                         } else {
  102.                                                 if (nIndex !== false) {
  103.                                                         t.LstView_RemoveItem('LvContacts', nIndex);
  104.                                                 }
  105.                                         }
  106.                                 }
  107.                         }
  108.                         break;
  109.                 case WM_CONTACTSIGNIN :
  110.                         if (typeof objWindows['ContactSelector'] !== TYPE_UNDEFINED) {
  111.                                 var t = objWindows['ContactSelector'];
  112.                                 if (t.Button_IsChecked('chkShowConversationContacts') === false) {
  113.                                         var oContact = Messenger.MyContacts.GetContact(wParam);
  114.                                         var nIndex = ItemExistsInLstView(oContact.Email, t, 'LvContacts', 1);
  115.                                         if (nIndex === false) {
  116.                                                 nIndex = t.LstView_AddItem('LvContacts', RemovePlusCodes(Contact.Name));
  117.                                         }
  118.                                         t.LstView_SetItemText('LvContacts', nIndex, 1, wParam);
  119.                                         t.LstView_SetItemIcon('LvContacts', nIndex, oStatus[oContact.Status], true);
  120.                                 } else OnContactSelectorEvent_CtrlClicked(t, 'chkShowConversationContacts');
  121.                         }
  122.                         break;
  123.                 case WM_CONTACTSTATUSCHANGE :
  124.                         var t = objWindows['ContactSelector'];
  125.                         var oContact = Messenger.MyContacts.GetContact(wParam);
  126.                         var nIndex = ItemExistsInLstView(oContact.Email, t, 'LvContacts', 1);
  127.                         if (nIndex !== false) {
  128.                                 t.LstView_SetItemText('LvContacts', nIndex, 1, wParam);
  129.                                 t.LstView_SetItemIcon('LvContacts', nIndex, oStatus[oContact.Status ], true);
  130.                         }
  131.                         break;
  132.                 case WM_CONTACTSIGNOUT :
  133.                         objWindows['ContactSelector'].LstView_RemoveItem('LvContacts', ItemExistsInLstView(wParam, objWindows['ContactSelector'], 'LvContacts', 1));
  134.                         break;
  135.         }
  136. }
  137.  
  138. function ItemExistsInLstView(sItem, pPlusWnd, sLstViewName, iColumn) {
  139.         _debug.getfuncname(arguments);
  140.         // Note: may want to use reverse loop here?
  141.         // Pro: faster, Con: matching will be done in reverse (first item tested last)
  142.         for (var i=0, len=pPlusWnd.LstView_GetCount(sLstViewName); i<len; ++i) {
  143.                 if (pPlusWnd.LstView_GetItemText(sLstViewName, i, iColumn) === sItem) {
  144.                         return i;
  145.                 }
  146.         }
  147.         return false;
  148. }
  149.  
  150. function LstViewColumnToArray(pPlusWnd, sLstViewName, iColumn) {
  151.         _debug.getfuncname(arguments);
  152.         var tArray = [], i = pPlusWnd.LstView_GetCount(sLstViewName);
  153.         // Super fast reverse array populating!
  154.         while (i--) {
  155.                 tArray[i] = pPlusWnd.LstView_GetItemText(sLstViewName, i, iColumn);
  156.         }
  157.         return tArray;
  158. }

Version

  • 5.0.0070_20100325_publicbeta1

Developers

Project Details

  • Folders8
  • Files122
  • Total Lines11,867
  • Repository Version70

User Count

  • 162