diff options
Diffstat (limited to 'plugins/MirFox/src/MirfoxMiranda.cpp')
-rw-r--r-- | plugins/MirFox/src/MirfoxMiranda.cpp | 156 |
1 files changed, 155 insertions, 1 deletions
diff --git a/plugins/MirFox/src/MirfoxMiranda.cpp b/plugins/MirFox/src/MirfoxMiranda.cpp index 5d5e851cc1..da140c8d17 100644 --- a/plugins/MirFox/src/MirfoxMiranda.cpp +++ b/plugins/MirFox/src/MirfoxMiranda.cpp @@ -21,6 +21,11 @@ MirfoxData& CMirfoxMiranda::getMirfoxData(){ return mirfoxData;
}
+SharedMemoryUtils& CMirfoxMiranda::getSharedMemoryUtils(){
+ return *sharedMemoryUtils;
+}
+
+
int CMirfoxMiranda::onMirandaInterfaceLoad()
{
@@ -53,6 +58,155 @@ int CMirfoxMiranda::onMirandaInterfaceLoad() }
+void CMirfoxMiranda::onAccListChanged(WPARAM wParam, LPARAM lParam)
+{
+ PROTOACCOUNT *acc = (PROTOACCOUNT*)lParam;
+
+ switch (wParam) {
+ case PRAC_ADDED:
+ if (acc != NULL) {
+ //checking account
+ if(acc->bIsEnabled == 0 || acc->bDynDisabled != 0){
+ return;
+ }
+ mirfoxData.refreshAccount_Add(getSharedMemoryUtils(), acc->szModuleName, acc->tszAccountName, acc->szProtoName);
+ }
+ break;
+
+ case PRAC_UPGRADED:
+ case PRAC_CHANGED:
+ if (acc != NULL) {
+ //checking account
+ if(acc->bIsEnabled == 0 || acc->bDynDisabled != 0){
+ return;
+ }
+ mirfoxData.refreshAccount_Edit(getSharedMemoryUtils(), acc->szModuleName, acc->tszAccountName);
+ }
+ break;
+
+ case PRAC_REMOVED:
+ mirfoxData.refreshAccount_Delete(getSharedMemoryUtils(), acc->szModuleName);
+ break;
+
+ case PRAC_CHECKED:
+ if (acc != NULL) {
+ if (acc->bIsEnabled) {
+ //checking account
+ if(acc->bDynDisabled != 0){
+ return;
+ }
+ mirfoxData.refreshAccount_Add(getSharedMemoryUtils(), acc->szModuleName, acc->tszAccountName, acc->szProtoName);
+ } else {
+ mirfoxData.refreshAccount_Delete(getSharedMemoryUtils(), acc->szModuleName);
+ }
+ }
+ break;
+ }
+
+ return;
+}
+
+
+void CMirfoxMiranda::onContactAdded_async(void* threadArg)
+{
+ Thread_Push(0);
+ OnContactAsyncThreadArgStruct* onContactAsyncThreadArgStruct = (OnContactAsyncThreadArgStruct*)threadArg;
+ CMirfoxMiranda* mirfoxMiranda = onContactAsyncThreadArgStruct->mirfoxMiranda;
+ MFLogger* logger = MFLogger::getInstance();
+
+ // ME_DB_CONTACT_ADDED is fired when only hContact is known, wait some time for finish creating contact
+ // wait some time for finish contact creation
+ SleepEx(300, TRUE);
+ logger->log_p(L"CMirfoxMiranda::onContactAdded_async AFTER wait [" SCNuPTR L"]", onContactAsyncThreadArgStruct->hContact);
+ bool canAdd = true;
+
+ // ceck miranda
+ if (Miranda_Terminated() || mirfoxMiranda->getMirfoxData().Plugin_Terminated)
+ canAdd = false;
+
+ // check if hContact still exist
+ if (canAdd && !CallService(MS_DB_CONTACT_IS, onContactAsyncThreadArgStruct->hContact, 0))
+ canAdd = false;
+
+ // execute
+ if (canAdd && db_get_b(onContactAsyncThreadArgStruct->hContact, "CList", "Hidden", 0) == 1)
+ canAdd = false;
+
+ // add
+ if (canAdd)
+ mirfoxMiranda->getMirfoxData().refreshContact_Add(mirfoxMiranda->getSharedMemoryUtils(), onContactAsyncThreadArgStruct->hContact);
+
+ // clean
+ delete onContactAsyncThreadArgStruct;
+ Thread_Pop();
+ return;
+}
+
+
+void CMirfoxMiranda::onContactDeleted(MCONTACT hContact)
+{
+
+ mirfoxData.refreshContact_Delete(getSharedMemoryUtils(), hContact);
+
+ return;
+}
+
+
+void CMirfoxMiranda::onContactSettingChanged(MCONTACT hContact, LPARAM lParam)
+{
+
+ DBCONTACTWRITESETTING* cws = (DBCONTACTWRITESETTING*)lParam;
+ logger->log_p(L"onContactSettingChanged CList Hidden hContact [" SCNuPTR L"]", hContact);
+
+ if (cws->value.bVal > 0){
+ mirfoxData.refreshContact_Delete(getSharedMemoryUtils(), hContact);
+ } else { //unset
+ mirfoxData.refreshContact_Add(getSharedMemoryUtils(), hContact);
+ }
+
+ return;
+}
+
+void CMirfoxMiranda::onContactSettingChanged_async(void* threadArg){
+
+ Thread_Push(0);
+ OnContactAsyncThreadArgStruct* onContactAsyncThreadArgStruct = (OnContactAsyncThreadArgStruct*)threadArg;
+ CMirfoxMiranda* mirfoxMiranda = onContactAsyncThreadArgStruct->mirfoxMiranda;
+ MFLogger* logger = MFLogger::getInstance();
+
+ // this ME_DB_CONTACT_SETTINGCHANGED hook can be added after ME_DB_CONTACT_ADDED
+ // if we delay ME_DB_CONTACT_ADDED routines, we must also delay this
+ // wait some time for finish contact creation
+ SleepEx(300+100, TRUE);
+ logger->log_p(L"CMirfoxMiranda::onContactSettingChanged_async AFTER wait [" SCNuPTR L"]", onContactAsyncThreadArgStruct->hContact);
+ bool canAdd = true;
+
+ // ceck miranda
+ if (Miranda_Terminated() || mirfoxMiranda->getMirfoxData().Plugin_Terminated)
+ canAdd = false;
+
+ // check if hContact still exist
+ if (canAdd && !CallService(MS_DB_CONTACT_IS, onContactAsyncThreadArgStruct->hContact, 0))
+ canAdd = false;
+
+ // edit
+ if (canAdd &&db_get_b(onContactAsyncThreadArgStruct->hContact, "CList", "Hidden", 0) == 1)
+ canAdd = false;
+
+
+ if (canAdd)
+ mirfoxMiranda->getMirfoxData().refreshContact_Edit(mirfoxMiranda->getSharedMemoryUtils(), onContactAsyncThreadArgStruct->hContact);
+
+ // clean
+ delete onContactAsyncThreadArgStruct;
+ Thread_Pop();
+ return;
+}
+
+
+
+
+
int CMirfoxMiranda::onMirandaInterfaceUnload()
{
@@ -403,4 +557,4 @@ void CMirfoxMiranda::msgQueueThread(void* threadArg) mirfoxDataPtr->workerThreadsCount--;
Thread_Pop();
return;
-}
\ No newline at end of file +}
|