Ejemplo n.º 1
0
void ChangeProtoMessages(char* szProto, int iMode, TCString &Msg)
{
	TCString CurMsg(Msg);
	if (szProto)
	{
		if (Msg == NULL)
		{
			CurMsg = GetDynamicStatMsg(INVALID_HANDLE_VALUE, szProto);
		}
		CallAllowedPS_SETAWAYMSG(szProto, iMode, (char*)TCHAR2ANSI(CurMsg));
		g_ProtoStates[szProto].CurStatusMsg = CurMsg;
	} else // change message of all protocols
	{
		int ProtoCount;
		PROTOCOLDESCRIPTOR **proto;
		CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&ProtoCount, (LPARAM)&proto);
		int I;
		for (I = 0; I < ProtoCount; I++)
		{
			if (proto[I]->type == PROTOTYPE_PROTOCOL && !DBGetContactSettingByte(NULL, proto[I]->szName, "LockMainStatus", 0))
			{
				if (Msg == NULL)
				{
					CurMsg = GetDynamicStatMsg(INVALID_HANDLE_VALUE, proto[I]->szName);
				}
				CallAllowedPS_SETAWAYMSG(proto[I]->szName, iMode, (char*)TCHAR2ANSI(CurMsg));
				g_ProtoStates[proto[I]->szName].CurStatusMsg = CurMsg;
			}
		}
	}
	static struct
	{
		int Status;
		char *Setting;
	} StatusSettings[] = {
		ID_STATUS_OFFLINE, "Off",
		ID_STATUS_ONLINE, "On",
		ID_STATUS_AWAY, "Away",
		ID_STATUS_NA, "Na",
		ID_STATUS_DND, "Dnd",
		ID_STATUS_OCCUPIED, "Occupied",
		ID_STATUS_FREECHAT, "FreeChat",
		ID_STATUS_INVISIBLE, "Inv",
		ID_STATUS_ONTHEPHONE, "Otp",
		ID_STATUS_OUTTOLUNCH, "Otl",
		ID_STATUS_IDLE, "Idl"
	};
	int I;
	for (I = 0; I < lengthof(StatusSettings); I++)
	{
		if (iMode == StatusSettings[I].Status)
		{
			DBWriteContactSettingTString(NULL, "SRAway", CString(StatusSettings[I].Setting) + "Msg", CurMsg);
			DBWriteContactSettingTString(NULL, "SRAway", CString(StatusSettings[I].Setting) + "Default", CurMsg); // TODO: make it more accurate, and change not only here, but when changing status messages through UpdateMsgsTimerFunc too; and when changing messages through AutoAway() ?
			break;
		}
	}
//	InitUpdateMsgs();
}
Ejemplo n.º 2
0
void ChangeProtoMessages(char* szProto, int iMode, TCString &Msg)
{
	TCString CurMsg(Msg);
	if (szProto) {
		if (Msg == NULL)
			CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, szProto);

		CallAllowedPS_SETAWAYMSG(szProto, iMode, (char*)_T2A(CurMsg));
		g_ProtoStates[szProto].CurStatusMsg = CurMsg;
	}
	else { // change message of all protocols
		int numAccs;
		PROTOACCOUNT **accs;
		ProtoEnumAccounts(&numAccs, &accs);
		for (int i = 0; i < numAccs; i++) {
			PROTOACCOUNT *p = accs[i];
			if (!db_get_b(NULL, p->szModuleName, "LockMainStatus", 0)) {
				if (Msg == NULL)
					CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, p->szModuleName);

				CallAllowedPS_SETAWAYMSG(p->szModuleName, iMode, (char*)_T2A(CurMsg));
				g_ProtoStates[p->szModuleName].CurStatusMsg = CurMsg;
			}
		}
	}

	static struct
	{
		int Status;
		char *Setting;
	} StatusSettings[] = {
		ID_STATUS_OFFLINE, "Off",
		ID_STATUS_ONLINE, "On",
		ID_STATUS_AWAY, "Away",
		ID_STATUS_NA, "Na",
		ID_STATUS_DND, "Dnd",
		ID_STATUS_OCCUPIED, "Occupied",
		ID_STATUS_FREECHAT, "FreeChat",
		ID_STATUS_INVISIBLE, "Inv",
		ID_STATUS_ONTHEPHONE, "Otp",
		ID_STATUS_OUTTOLUNCH, "Otl",
		ID_STATUS_IDLE, "Idl"
	};

	for (int i = 0; i < SIZEOF(StatusSettings); i++) {
		if (iMode == StatusSettings[i].Status) {
			db_set_ts(NULL, "SRAway", CString(StatusSettings[i].Setting) + "Msg", CurMsg);
			db_set_ts(NULL, "SRAway", CString(StatusSettings[i].Setting) + "Default", CurMsg); // TODO: make it more accurate, and change not only here, but when changing status messages through UpdateMsgsTimerFunc too; and when changing messages through AutoAway() ?
			break;
		}
	}
	//	InitUpdateMsgs();
}
Ejemplo n.º 3
0
int StatusMsgReq(WPARAM wParam, LPARAM lParam, CString &szProto)
{
    _ASSERT(szProto != NULL);
    LogMessage("ME_ICQ_STATUSMSGREQ called. szProto=%s, Status=%d, UIN=%d", (char*)szProto, wParam, lParam);
    // find the contact
    char *szFoundProto;
    MCONTACT hFoundContact = NULL; // if we'll find the contact only on some other protocol, but not on szProto, then we'll use that hContact.
    for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
        char *szCurProto = GetContactProto(hContact);
        if (db_get_dw(hContact, szCurProto, "UIN", 0) == lParam) {
            szFoundProto = szCurProto;
            hFoundContact = hContact;
            if (!mir_strcmp(szCurProto, szProto))
                break;
        }
    }

    int iMode = ICQStatusToGeneralStatus(wParam);
    if (!hFoundContact)
        hFoundContact = INVALID_CONTACT_ID;
    else if (iMode >= ID_STATUS_ONLINE && iMode <= ID_STATUS_OUTTOLUNCH)
        // don't count xstatus requests
        db_set_w(hFoundContact, MOD_NAME, DB_REQUESTCOUNT, db_get_w(hFoundContact, MOD_NAME, DB_REQUESTCOUNT, 0) + 1);

    MCONTACT hContactForSettings = hFoundContact; // used to take into account not-on-list contacts when getting contact settings, but at the same time allows to get correct contact info for contacts that are in the DB
    if (hContactForSettings != INVALID_CONTACT_ID && db_get_b(hContactForSettings, "CList", "NotOnList", 0))
        hContactForSettings = INVALID_CONTACT_ID; // INVALID_HANDLE_VALUE means the contact is not-on-list

    if (g_SetAwayMsgPage.GetWnd()) {
        CallAllowedPS_SETAWAYMSG(szProto, iMode, NULL); // we can set status messages to NULL here, as they'll be changed again when the SAM dialog closes.
        return 0;
    }
    if (CContactSettings(iMode, hContactForSettings).Ignore) {
        CallAllowedPS_SETAWAYMSG(szProto, iMode, _T("")); // currently NULL makes ICQ to ignore _any_ further status message requests until the next PS_SETAWAYMSG, so i can't use it here..
        return 0; // move along, sir
    }

    if (iMode) // if it's not an xstatus message request
        CallAllowedPS_SETAWAYMSG(szProto, iMode, GetDynamicStatMsg(hFoundContact, szProto, lParam));

    //	COptPage PopupNotifyData(g_PopupOptPage);
    //	PopupNotifyData.DBToMem();
    VarParseData.szProto = szProto;
    VarParseData.UIN = lParam;
    VarParseData.Flags = 0;
    if (!iMode)
        VarParseData.Flags |= VPF_XSTATUS;

    return 0;
}
Ejemplo n.º 4
0
void __cdecl UpdateMsgsThreadProc(void *)
{
	int ProtoCount;
	PROTOCOLDESCRIPTOR **proto;
	CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&ProtoCount, (LPARAM)&proto);
	int I;
	while (WaitForSingleObject(g_hTerminateUpdateMsgsThread, 0) == WAIT_TIMEOUT && !Miranda_Terminated())
	{
		DWORD MinUpdateTimeDifference = g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_UPDATEMSGSPERIOD) * 1000; // in milliseconds
		for (I = 0; I < ProtoCount; I++)
		{
			if (proto[I]->type == PROTOTYPE_PROTOCOL && CallProtoService(proto[I]->szName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND && !IsAnICQProto(proto[I]->szName))
			{
				int Status = CallProtoService(proto[I]->szName, PS_GETSTATUS, 0, 0);
				if (Status < ID_STATUS_OFFLINE || Status > ID_STATUS_OUTTOLUNCH)
				{
					Status = g_ProtoStates[proto[I]->szName].Status;
				}
				if (CallProtoService(proto[I]->szName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(Status) && g_ProtoStates[proto[I]->szName].CurStatusMsg.GetUpdateTimeDifference() >= MinUpdateTimeDifference)
				{
					TCString CurMsg(GetDynamicStatMsg(INVALID_HANDLE_VALUE, proto[I]->szName));
					if ((TCString)g_ProtoStates[proto[I]->szName].CurStatusMsg != (const TCHAR*)CurMsg) // if the message has changed
					{
						g_ProtoStates[proto[I]->szName].CurStatusMsg = CurMsg;
						CallAllowedPS_SETAWAYMSG(proto[I]->szName, Status, (char*)TCHAR2ANSI(CurMsg));
					}
				}
			}
		}
		SleepEx(PARSE_INTERVAL, true);
	}
}
Ejemplo n.º 5
0
void __cdecl UpdateMsgsThreadProc(void *)
{
	int numAccs;
	PROTOACCOUNT **accs;
	ProtoEnumAccounts(&numAccs, &accs);

	while (WaitForSingleObject(g_hTerminateUpdateMsgsThread, 0) == WAIT_TIMEOUT && !Miranda_Terminated()) {
		DWORD MinUpdateTimeDifference = g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_UPDATEMSGSPERIOD) * 1000; // in milliseconds
		for (int i = 0; i < numAccs; i++) {
			PROTOACCOUNT *p = accs[i];
			if (CallProtoService(p->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND && !IsAnICQProto(p->szModuleName)) {
				int Status = CallProtoService(p->szModuleName, PS_GETSTATUS, 0, 0);
				if (Status < ID_STATUS_OFFLINE || Status > ID_STATUS_OUTTOLUNCH) {
					Status = g_ProtoStates[p->szModuleName].Status;
				}
				if (CallProtoService(p->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(Status) && g_ProtoStates[p->szModuleName].CurStatusMsg.GetUpdateTimeDifference() >= MinUpdateTimeDifference) {
					TCString CurMsg(GetDynamicStatMsg(INVALID_CONTACT_ID, p->szModuleName));
					if ((TCString)g_ProtoStates[p->szModuleName].CurStatusMsg != (const TCHAR*)CurMsg) { // if the message has changed
						g_ProtoStates[p->szModuleName].CurStatusMsg = CurMsg;
						CallAllowedPS_SETAWAYMSG(p->szModuleName, Status, (char*)_T2A(CurMsg));
					}
				}
			}
		}
		SleepEx(PARSE_INTERVAL, true);
	}
}