Example #1
0
void PreviewSound(HWND hList)
{
    TCHAR buff[MAX_PATH], stzSoundPath[MAX_PATH];

    LVITEM lvi = {0};
    lvi.mask = LVIF_PARAM;
    lvi.iItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
    ListView_GetItem(hList, &lvi);

    int hlpStatus = lvi.lParam;

    ListView_GetItemText(hList, lvi.iItem, 1, buff, SIZEOF(buff));
    if (_tcscmp(buff, TranslateT(DEFAULT_SOUND)) == 0)
    {
        if (hlpStatus == ID_STATUS_FROMOFFLINE)
            SkinPlaySound("UserFromOffline");
        else
            SkinPlaySound(StatusList[Index(hlpStatus)].lpzSkinSoundName);
    }
    else
    {
        CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)buff, (LPARAM)stzSoundPath);
        PlaySound(stzSoundPath, NULL, SND_ASYNC | SND_FILENAME);
    }
}
Example #2
0
int SoundNotifyBirthday(int dtb)
{
	if (dtb == 0)
		SkinPlaySound(BIRTHDAY_TODAY_SOUND);
	else if (dtb <= commonData.cSoundNearDays)
		SkinPlaySound(BIRTHDAY_NEAR_SOUND);

	return 0;
}
Example #3
0
void PlayXStatusSound(int action)
{
	switch (action) {
	case NOTIFY_NEW_XSTATUS:
		SkinPlaySound(XSTATUS_SOUND_CHANGED); break;
	case NOTIFY_NEW_MESSAGE:
		SkinPlaySound(XSTATUS_SOUND_MSGCHANGED); break;
	case NOTIFY_REMOVE:
		SkinPlaySound(XSTATUS_SOUND_REMOVED); break;
	}
}
Example #4
0
static int MessageEventAdded(WPARAM hContact, LPARAM lParam)
{
	DBEVENTINFO dbei = { sizeof(dbei) };
	db_event_get(lParam, &dbei);

	if (dbei.flags & (DBEF_SENT | DBEF_READ) || !(dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei)))
		return 0;

	CallServiceSync(MS_CLIST_REMOVEEVENT, hContact, 1);
	/* does a window for the contact exist? */
	HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact);
	if (hwnd) {
		if (!db_get_b(NULL, SRMMMOD, SRMSGSET_DONOTSTEALFOCUS, SRMSGDEFSET_DONOTSTEALFOCUS)) {
			ShowWindow(hwnd, SW_RESTORE);
			SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
			SetForegroundWindow(hwnd);
			SkinPlaySound("RecvMsgActive");
		}
		else {
			if (GetForegroundWindow() == hwnd)
				SkinPlaySound("RecvMsgActive");
			else
				SkinPlaySound("RecvMsgInactive");
		}
		return 0;
	}
	/* new message */
	SkinPlaySound("AlertMsg");

	char *szProto = GetContactProto(hContact);
	if (szProto && (g_dat.openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0)))) {
		NewMessageWindowLParam newData = { 0 };
		newData.hContact = hContact;
		newData.noActivate = db_get_b(NULL, SRMMMOD, SRMSGSET_DONOTSTEALFOCUS, SRMSGDEFSET_DONOTSTEALFOCUS);
		CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), NULL, DlgProcMessage, (LPARAM)&newData);
		return 0;
	}

	CLISTEVENT cle = { sizeof(cle) };
	cle.hContact = hContact;
	cle.hDbEvent = lParam;
	cle.flags = CLEF_TCHAR;
	cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE);
	cle.pszService = "SRMsg/ReadMessage";
	TCHAR toolTip[256];
	mir_sntprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
	cle.ptszTooltip = toolTip;
	CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
	return 0;
}
Example #5
0
static int HookDBEventAdded(WPARAM hContact, LPARAM hDbEvent)
{
	//process the event
	DBEVENTINFO dbe = { sizeof(dbe) };
	db_event_get(hDbEvent, &dbe);
	//check if we should process the event
	if (dbe.flags & (DBEF_SENT | DBEF_READ) || dbe.eventType != EVENTTYPE_CONTACTS) return 0;
	//get event contents
	dbe.cbBlob = db_event_getBlobSize(hDbEvent);
	if (dbe.cbBlob != -1)
		dbe.pBlob = (PBYTE)_alloca(dbe.cbBlob);
	db_event_get(hDbEvent, &dbe);
	//play received sound
	SkinPlaySound("RecvContacts");
	{
		//add event to the contact list
		TCHAR caToolTip[128];
		mir_sntprintf(caToolTip, _T("%s %s"), TranslateT("Contacts received from"), pcli->pfnGetContactDisplayName(hContact, 0));

		CLISTEVENT cle = { sizeof(cle) };
		cle.hContact = hContact;
		cle.hDbEvent = hDbEvent;
		cle.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_CONTACTS));
		cle.pszService = MS_CONTACTS_RECEIVE;
		cle.ptszTooltip = caToolTip;
		cle.flags |= CLEF_UNICODE;
		CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
	}
	return 0; //continue processing by other hooks
}
Example #6
0
void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
	for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
		char *proto = GetContactProto(hContact);
		if (proto && (db_get_b(hContact, proto, "ChatRoom", 0) == 0) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) && isContactGoneFor(hContact, options.iAbsencePeriod2) && (db_get_b(hContact, MODULE_NAME, "StillAbsentNotified", 0) == 0))
		{
			db_set_b(hContact, MODULE_NAME, "StillAbsentNotified", 1);
			SkinPlaySound("buddyExpectatorStillAbsent");

			TCHAR* message = TranslateT("has not returned after a long absence.");
			time_t tmpTime;
			TCHAR tmpBuf[251] = { 0 };
			tmpTime = getLastSeen(hContact);
			if (tmpTime != -1)
			{
				_tcsftime(tmpBuf, 250, TranslateT("has not returned after being absent since %#x"), gmtime(&tmpTime));
				message = tmpBuf;
			}
			else
			{
				tmpTime = getLastInputMsg(hContact);
				if (tmpTime != -1)
				{
					_tcsftime(tmpBuf, 250, TranslateT("has not returned after being absent since %#x"), gmtime(&tmpTime));
					message = tmpBuf;
				}
			}

			GoneNotify(hContact, message);
		}
	}
}
Example #7
0
/**
 * Play a sound for the nearest upcomming anniversary
 *
 * @param	evt				- structure specifying the next anniversary
 *
 * @retval	0 if sound was played
 * @retval	1 otherwise
 **/
static BYTE NotifyWithSound(const CEvent &evt)
{
    if (evt._wDaysLeft <= min(DB::Setting::GetByte(SET_REMIND_SOUNDOFFSET, DEFVAL_REMIND_SOUNDOFFSET), gRemindOpts.wDaysEarlier))
    {
        switch (evt._eType)
        {
        case CEvent::BIRTHDAY:
            SkinPlaySound(evt._wDaysLeft == 0 ? SOUND_BIRTHDAY_TODAY : SOUND_BIRTHDAY_SOON);
            return 0;

        case CEvent::ANNIVERSARY:
            SkinPlaySound(SOUND_ANNIVERSARY);
            return 0;
        }
    }
    return 1;
}
void CSkypeProto::OnTrouterEvent(const JSONNode &body, const JSONNode &)
{
	//std::string displayname = body["displayName"].as_string();
	//std::string cuid = body["callerId"].as_string();
	std::string uid = body["conversationId"].as_string();
	std::string gp = body["gp"].as_string();
	int evt = body["evt"].as_int();

	switch (evt)
	{
	case 100: //incoming call
		{
			std::string callId = body["convoCallId"].as_string();
			if (!uid.empty())
			{
				MCONTACT hContact = AddContact(uid.c_str(), true);

				MEVENT hEvent = AddDbEvent(SKYPE_DB_EVENT_TYPE_INCOMING_CALL, hContact, time(NULL), DBEF_READ, gp.c_str(), callId.c_str());
				SkinPlaySound("skype_inc_call");

				CLISTEVENT cle = { sizeof(cle) };
				cle.flags |= CLEF_TCHAR;
				cle.hContact = hContact;
				cle.hDbEvent = hEvent;
				cle.lParam = SKYPE_DB_EVENT_TYPE_INCOMING_CALL;
				cle.hIcon = IcoLib_GetIconByHandle(GetIconHandle("inc_call"));

				CMStringA service(FORMAT, "%s/IncomingCallCLE", GetContactProto(hContact));
				cle.pszService = service.GetBuffer();

				CMString tooltip(FORMAT, TranslateT("Incoming call from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
				cle.ptszTooltip = tooltip.GetBuffer();

				CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);

				ShowNotification(pcli->pfnGetContactDisplayName(hContact, 0), TranslateT("Incoming call"), hContact, SKYPE_DB_EVENT_TYPE_INCOMING_CALL);
			}
		}
		break;

	case 104: //call canceled: callerId=""; conversationId=NULL; callId=call id
		// std::string callId = body["callId"].as_string();
		SkinPlaySound("skype_call_canceled");
		break;
	}
}
Example #9
0
//---------------------------------------------------------------------------
void CSend::Exit(unsigned int Result)
{
	if (!m_bSilent) {
		bool err = true;
		switch (Result) {
		case CSEND_DIALOG:
			SkinPlaySound("FileDone");
			DialogBoxParam(g_hSendSS, MAKEINTRESOURCE(IDD_UResultForm), 0, ResultDialogProc, (LPARAM)this);
			err = false;
			break;
		case ACKRESULT_SUCCESS:
		case GC_RESULT_SUCCESS:
			SkinPlaySound("FileDone");
			err = false;
			break;
		case ACKRESULT_DENIED:
			SkinPlaySound("FileDenied");
			Error(_T("%s (%i):\nFile transfer denied."), TranslateTS(m_pszSendTyp), Result);
			MsgBoxService(NULL, (LPARAM)&m_box);
			err = false;
			break;
		case GC_RESULT_WRONGVER:	//.You appear to be using the wrong version of GC API.
			Error(_T("%s (%i):\nYou appear to be using the wrong version of GC API"), TranslateT("GCHAT error"), Result);
			break;
		case GC_RESULT_ERROR:		// An internal GC error occurred.
			Error(_T("%s (%i):\nAn internal GC error occurred."), TranslateT("GCHAT error"), Result);
			break;
		case GC_RESULT_NOSESSION:	// contact has no open GC session
			Error(_T("%s (%i):\nContact has no open GC session."), TranslateT("GCHAT error"), Result);
			break;
		case ACKRESULT_FAILED:
		default:
			break;
		}
		if (err) {
			SkinPlaySound("FileFailed");
			if (m_ErrorMsg) MsgBoxService(NULL, (LPARAM)&m_box);
			else MsgErr(NULL, LPGENT("An unknown error has occurred."));
		}
	}
	if (m_pszFile && *m_pszFile && m_bDeleteAfterSend && m_EnableItem&SS_DLG_DELETEAFTERSSEND) {
		DeleteFile(m_pszFile), m_pszFile = NULL;
	}
	if (m_bAsync)
		delete this;/// deletes derived class since destructor is virtual (which also auto-calls base dtor)
}
Example #10
0
static int ackevent(WPARAM wParam, LPARAM lParam)
{
	ACKDATA *pAck = (ACKDATA *)lParam;
	if (pAck && pAck->type == ACKTYPE_MESSAGE) {
		msgQueue_processack(pAck->hContact, (int)pAck->hProcess, pAck->result == ACKRESULT_SUCCESS, (char*)pAck->lParam);

		if (pAck->result == ACKRESULT_SUCCESS)
			SkinPlaySound("SendMsg");
	}
	return 0;
}
Example #11
0
static int MessageEventAdded(WPARAM wParam, LPARAM lParam)
{
	CLISTEVENT cle;
	DBEVENTINFO dbei;
	char *contactName;
	char toolTip[256];
	HWND hwnd;

	ZeroMemory(&dbei, sizeof(dbei));
	dbei.cbSize = sizeof(dbei);
	dbei.cbBlob = 0;
	CallService(MS_DB_EVENT_GET, lParam, (LPARAM) & dbei);
	hwnd = WindowList_Find(g_dat->hMessageWindowList, (HANDLE) wParam);
	if (hwnd) {
		SendMessage(hwnd, HM_DBEVENTADDED, wParam, lParam);
	}
	if (dbei.flags & DBEF_SENT || dbei.eventType != EVENTTYPE_MESSAGE)
		return 0;

	if (dbei.eventType == EVENTTYPE_MESSAGE && (dbei.flags & DBEF_READ))
		return 0;

	CallServiceSync(MS_CLIST_REMOVEEVENT, wParam, (LPARAM) 1);
	/* does a window for the contact exist? */
	if (hwnd) {
		return 0;
	}
	/* new message */
	SkinPlaySound("AlertMsg");
	if (DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_AUTOPOPUP, SRMSGDEFSET_AUTOPOPUP)) {
		char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) wParam, 0);
		if (szProto && (g_dat->openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0)))) {
			struct NewMessageWindowLParam newData = { 0 };
			newData.hContact = (HANDLE) wParam;
			if (g_dat->hParent == NULL || !(g_dat->flags & SMF_USETABS)) {
				g_dat->hParent = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM) & newData);
			}
			newData.flags = NMWLP_INCOMING;
			CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), g_dat->hParent, DlgProcMessage, (LPARAM) & newData);
			return 0;
		}
	}
	ZeroMemory(&cle, sizeof(cle));
	cle.cbSize = sizeof(cle);
	cle.hContact = (HANDLE) wParam;
	cle.hDbEvent = (HANDLE) lParam;
	cle.hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE);
	cle.pszService = "SRMsg/ReadMessage";
	contactName = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, 0);
	mir_snprintf(toolTip, sizeof(toolTip), Translate("Message from %s"), contactName);
	cle.pszTooltip = toolTip;
	CallService(MS_CLIST_ADDEVENT, 0, (LPARAM) & cle);
	return 0;
}
Example #12
0
void myPlaySound(MCONTACT hcontact, WORD newStatus, WORD oldStatus)
{
	if (CallService(MS_IGNORE_ISIGNORED, (WPARAM)hcontact, IGNOREEVENT_USERONLINE)) return;
	//oldStatus and hcontact are not used yet
	char *soundname = NULL;
	if ((newStatus == ID_STATUS_ONLINE) || (newStatus == ID_STATUS_FREECHAT)) soundname = "LastSeenTrackedStatusOnline";
	else if (newStatus == ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusOffline";
	else if (oldStatus == ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusFromOffline";
	else soundname = "LastSeenTrackedStatusChange";
	if (soundname != NULL)
		SkinPlaySound(soundname);
}
Example #13
0
int Preview()
{
	MCONTACT hContact = db_find_first();
	if (GlobalNudge.useByProtocol) {
		for (int i = 0; i < arNudges.getCount(); i++) {
			CNudgeElement &p = arNudges[i];
			if (p.enabled) {
				SkinPlaySound(p.NudgeSoundname);
				if (p.showPopup)
					Nudge_ShowPopup(&p, hContact, p.recText);
				if (p.openContactList)
					OpenContactList();
				if (p.shakeClist)
					ShakeClist(0, 0);
				if (p.openMessageWindow)
					CallService(MS_MSG_SENDMESSAGET, hContact, NULL);
				if (p.shakeChat)
					ShakeChat(hContact, (LPARAM)time(NULL));
			}
		}
	}
	else {
		if (DefaultNudge.enabled) {
			SkinPlaySound(DefaultNudge.NudgeSoundname);
			if (DefaultNudge.showPopup)
				Nudge_ShowPopup(&DefaultNudge, hContact, DefaultNudge.recText);
			if (DefaultNudge.openContactList)
				OpenContactList();
			if (DefaultNudge.shakeClist)
				ShakeClist(0, 0);
			if (DefaultNudge.openMessageWindow)
				CallService(MS_MSG_SENDMESSAGET, hContact, NULL);
			if (DefaultNudge.shakeChat)
				ShakeChat(hContact, (LPARAM)time(NULL));
		}
	}
	return 0;
}
Example #14
0
void MessageFailureProcess(TMsgQueue *item, const char* err)
{
	HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, item->hContact);
	if (hwnd == NULL) {
		SendMessageCmd(item->hContact, NULL, 0);
		hwnd = WindowList_Find(g_dat.hMessageWindowList, item->hContact);
	}
	else SendMessage(hwnd, DM_REMAKELOG, 0, 0);

	SkinPlaySound("SendError");

	ErrorDlgParam param = { err, item };
	CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGSENDERROR), hwnd, ErrorDlgProc, (LPARAM)&param);
}
//thread function with connections check loop
static unsigned __stdcall checkthread(void *dummy)
{

#ifdef _DEBUG
	_OutputDebugString(_T("check thread started"));
#endif
	while(1)
	{
		struct CONNECTION* conn=NULL,*connOld=first,*cur=NULL;
#ifdef _DEBUG
		_OutputDebugString(_T("checking connections table..."));
#endif
		if (WAIT_OBJECT_0 == WaitForSingleObject(killCheckThreadEvent,100))
		{
			hConnectionCheckThread=NULL;
			return 0;
		}

		conn=GetConnectionsTable();
		cur=conn;
		while(cur!=NULL) {	
			if (searchConnection(first,cur->strIntIp,cur->strExtIp,cur->intIntPort,cur->intExtPort,cur->state)==NULL && (settingStatusMask & (1 << (cur->state-1)))) {				

#ifdef _DEBUG
				TCHAR msg[1024];
				mir_sntprintf(msg,_countof(msg),_T("%s:%d\n%s:%d"),cur->strIntIp,cur->intIntPort,cur->strExtIp,cur->intExtPort);
				_OutputDebugString(_T("New connection: %s"),msg);
#endif
				pid2name(cur->Pid, cur->PName, SIZEOF(cur->PName));
				if ( WAIT_OBJECT_0 == WaitForSingleObject( hExceptionsMutex, 100 ))
				{
					if (checkFilter(connExceptions,cur))
					{
						showMsg(cur->PName,cur->Pid,cur->strIntIp,cur->strExtIp,cur->intIntPort,cur->intExtPort,cur->state);
						SkinPlaySound(PLUGINNAME_NEWSOUND);
					}
					ReleaseMutex(hExceptionsMutex);
				}
			}
			cur=cur->next;
		}

		first=conn;
		deleteConnectionsTable(connOld);
		Sleep(settingInterval);
	}
	hConnectionCheckThread=NULL;
	return 1;
}
Example #16
0
static int ProtoAck(WPARAM, LPARAM lParam)
{
	ACKDATA *ack = (ACKDATA*)lParam;
	if (ack != 0 && ack->szModule && ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS) {
		for (int i = 0; i < _countof(selfSounds); i++) {
			if (selfSounds[i].iStatus == ack->lParam) {
				char buf[128];
				mir_snprintf(buf, "%s%s", ack->szModule, selfSounds[i].szName);
				SkinPlaySound(buf);
				break;
			}
		}
	}
	return 0;
}
Example #17
0
static int MessageEventAdded(WPARAM hContact, LPARAM lParam)
{
	MEVENT hDbEvent = (MEVENT)lParam;
	DBEVENTINFO dbei = { sizeof(dbei) };
	db_event_get(hDbEvent, &dbei);
	if (dbei.eventType == EVENTTYPE_MESSAGE && (dbei.flags & DBEF_READ))
		return 0;

	HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact);
	if (hwnd == NULL)
		hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact = db_event_getContact(hDbEvent));
	if (hwnd)
		SendMessage(hwnd, HM_DBEVENTADDED, hContact, lParam);

	if (dbei.flags & DBEF_SENT || !DbEventIsMessageOrCustom(&dbei))
		return 0;

	pcli->pfnRemoveEvent(hContact, 1);
	/* does a window for the contact exist? */
	if (hwnd == NULL) {
		/* new message */
		SkinPlaySound("AlertMsg");
		if (IsAutoPopup(hContact)) {
			NewMessageWindowLParam newData = { 0 };
			newData.hContact = hContact;
			HWND hParent = GetParentWindow(newData.hContact, FALSE);
			newData.flags = NMWLP_INCOMING;
			CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM)&newData);
			return 0;
		}
	}
	if (hwnd == NULL || !IsWindowVisible(GetParent(hwnd))) {
		TCHAR *contactName = (TCHAR*)pcli->pfnGetContactDisplayName(hContact, 0);
		TCHAR toolTip[256];

		CLISTEVENT cle = {};
		cle.flags = CLEF_TCHAR;
		cle.hContact = hContact;
		cle.hDbEvent = hDbEvent;
		cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE);
		cle.pszService = "SRMsg/ReadMessage";
		mir_sntprintf(toolTip, TranslateT("Message from %s"), contactName);
		cle.ptszTooltip = toolTip;
		pcli->pfnAddEvent(&cle);
	}
	return 0;
}
Example #18
0
void ShowHistory(MCONTACT hContact, BYTE isAlert)
{
	HWND hHistoryDlg = WindowList_Find(hWindowList, hContact);
	if (hHistoryDlg == NULL) {
		hHistoryDlg = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_HISTORY), NULL, HistoryDlgProc, hContact);
		LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST);
		WindowList_Add(hWindowList, hHistoryDlg, hContact);
	}
	else {
		SetForegroundWindow(hHistoryDlg);
		LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST);
		SetFocus(hHistoryDlg);
	}

	if (isAlert)
		SkinPlaySound("LastSeenTrackedStatusChange");
}
Example #19
0
void VoiceCall::Notify(bool history, bool popup, bool sound, bool clist)
{
	if (history)
	{
		TCHAR *variables[] = {
			_T("number"), displayName
		};
		HistoryEvents_AddToHistoryVars(hContact, EVENTTYPE_VOICE_CALL, state, variables, MAX_REGS(variables),
			DBEF_READ | (incoming ? 0 : DBEF_SENT));
	}

	if (popup)
	{
		TCHAR text[512];
		mir_sntprintf(text, MAX_REGS(text), TranslateTS(stateTexts[state]), displayName);

		ShowPopup(NULL, TranslateTS(popupTitles[state]), text);
	}

	if (sound)
		SkinPlaySound(sounds[state].name);

	if (clist && state == VOICE_STATE_RINGING)
	{
		HICON hIcon = IcoLib_LoadIcon(stateIcons[VOICE_STATE_RINGING]);

		CLISTEVENT ce = {0};
		ce.cbSize = sizeof(ce);
		ce.hContact = hContact;
		ce.hIcon = hIcon;
		ce.hDbEvent = (HANDLE) this;
		ce.pszService = MS_VOICESERVICE_CLIST_DBLCLK;
		ce.lParam = (LPARAM) this;
		CallService(MS_CLIST_ADDEVENT, 0, (LPARAM) &ce);

		IcoLib_ReleaseIcon(hIcon);

		clistBlinking = true;
	}
	
	if (hwnd_frame != NULL)
		PostMessage(hwnd_frame, WMU_REFRESH, 0, 0);
}
Example #20
0
void CVkProto::AddCListEvent(bool bNews)
{
    SkinPlaySound("VKNewsFeed");

    if (!m_bUseNonStandardNotifications)
        return;

    MCONTACT hContact = FindUser(VK_FEED_USER, true);

    CLISTEVENT cle = {};
    cle.hIcon = IcoLib_GetIconByHandle(GetIconHandle(IDI_NOTIFICATION));
    cle.pszService = "SRMsg/ReadMessage";
    cle.flags = CLEF_URGENT | CLEF_TCHAR;
    cle.hContact = hContact;
    cle.hDbEvent = NULL;
    TCHAR toolTip[255];
    mir_sntprintf(toolTip, bNews ? TranslateT("New news") : TranslateT("New notifications"));
    cle.ptszTooltip = toolTip;
    pcli->pfnAddEvent(&cle);
}
Example #21
0
static int TypingMessage(WPARAM hContact, LPARAM lParam)
{
	if (!(g_dat.flags2 & SMF2_SHOWTYPING))
		return 0;

	hContact = db_mc_tryMeta(hContact);

	SkinPlaySound((lParam) ? "TNStart" : "TNStop");

	HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact);
	if (hwnd)
		SendMessage(hwnd, DM_TYPING, 0, lParam);
	else if (lParam && (g_dat.flags2 & SMF2_SHOWTYPINGTRAY)) {
		TCHAR szTip[256];

		mir_sntprintf(szTip, TranslateT("%s is typing a message"), pcli->pfnGetContactDisplayName(hContact, 0));
		if ( ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat.flags2 & SMF2_SHOWTYPINGCLIST)) {
			MIRANDASYSTRAYNOTIFY tn;
			tn.szProto = NULL;
			tn.cbSize = sizeof(tn);
			tn.tszInfoTitle = TranslateT("Typing notification");
			tn.tszInfo = szTip;
			tn.dwInfoFlags = NIIF_INFO | NIIF_INTERN_UNICODE;
			tn.uTimeout = 1000 * 4;
			CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&tn);
		}
		else {
			pcli->pfnRemoveEvent(hContact, 1);

			CLISTEVENT cle = {};
			cle.hContact = hContact;
			cle.hDbEvent = 1;
			cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR;
			cle.hIcon = GetCachedIcon("scriver_TYPING");
			cle.pszService = "SRMsg/TypingMessage";
			cle.ptszTooltip = szTip;
			pcli->pfnAddEvent(&cle);
		}
	}
	return 0;
}
Example #22
0
/**
 * Checks - whether user has been gone for specified number of days
 */
bool isContactGoneFor(MCONTACT hContact, int days)
{
	time_t lastSeen = getLastSeen(hContact);
	time_t lastInputMsg = getLastInputMsg(hContact);
	time_t currentTime = time(NULL);

	int daysSinceOnline = -1;
	if (lastSeen != -1) daysSinceOnline = (int)((currentTime - lastSeen) / (60 * 60 * 24));

	int daysSinceMessage = -1;
	if (lastInputMsg != -1) daysSinceMessage = (int)((currentTime - lastInputMsg) / (60 * 60 * 24));

	if (options.hideInactive)
		if (daysSinceMessage >= options.iSilencePeriod)
			if (!db_get_b(hContact, "CList", "Hidden", 0) && !db_get_b(hContact, MODULE_NAME, "NeverHide", 0)) {
				POPUPDATAT_V2 ppd = { 0 };
				ppd.cbSize = sizeof(ppd);
				ppd.lchContact = hContact;
				ppd.lchIcon = IcoLib_GetIcon("enabled_icon");

				mir_sntprintf(ppd.lptzContactName, TranslateT("Hiding %s (%S)"), pcli->pfnGetContactDisplayName(hContact, 0), GetContactProto(hContact));
				mir_sntprintf(ppd.lptzText, TranslateT("%d days since last message"), daysSinceMessage);

				if (!options.iUsePopupColors) {
					ppd.colorBack = options.iPopupColorBack;
					ppd.colorText = options.iPopupColorFore;
				}
				ppd.PluginWindowProc = HidePopupDlgProc;
				ppd.iSeconds = -1;

				hideactions[0].flags = hideactions[1].flags = PAF_ENABLED;
				ppd.lpActions = hideactions;
				ppd.actionCount = 2;

				CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&ppd, APF_NEWDATA);

				SkinPlaySound("buddyExpectatorHide");
			}

	return (daysSinceOnline >= days && (daysSinceMessage == -1 || daysSinceMessage >= days));
}
Example #23
0
static int TypingMessage(WPARAM hContact, LPARAM lParam)
{
	if (!(g_dat.flags & SMF_SHOWTYPING))
		return 0;

	hContact = db_mc_tryMeta(hContact);

	SkinPlaySound((lParam) ? "TNStart" : "TNStop");

	HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact);
	if (hwnd)
		SendMessage(hwnd, DM_TYPING, 0, lParam);
	else if (lParam && (g_dat.flags & SMF_SHOWTYPINGTRAY)) {
		TCHAR szTip[256];
		mir_sntprintf(szTip, TranslateT("%s is typing a message"), pcli->pfnGetContactDisplayName(hContact, 0));

		if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat.flags & SMF_SHOWTYPINGCLIST)) {
			MIRANDASYSTRAYNOTIFY tn = { sizeof(tn) };
			tn.tszInfoTitle = TranslateT("Typing notification");
			tn.tszInfo = szTip;
			tn.dwInfoFlags = NIIF_INFO;
			tn.dwInfoFlags |= NIIF_INTERN_UNICODE;
			tn.uTimeout = 1000 * 4;
			CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)& tn);
		}
		else {
			CLISTEVENT cle = { sizeof(cle) };
			cle.hContact = hContact;
			cle.hDbEvent = 1;
			cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR;
			cle.hIcon = Skin_LoadIcon(SKINICON_OTHER_TYPING);
			cle.pszService = "SRMsg/ReadMessage";
			cle.ptszTooltip = szTip;
			CallServiceSync(MS_CLIST_REMOVEEVENT, hContact, 1);
			CallServiceSync(MS_CLIST_ADDEVENT, hContact, (LPARAM)&cle);
			IcoLib_ReleaseIcon(cle.hIcon);
		}
	}
	return 0;
}
Example #24
0
static int UrlEventAdded(WPARAM hContact, LPARAM lParam)
{
	DBEVENTINFO dbei = { sizeof(dbei) };
	db_event_get(lParam, &dbei);
	if (dbei.flags & (DBEF_SENT|DBEF_READ) || dbei.eventType != EVENTTYPE_URL)
		return 0;

	SkinPlaySound("RecvUrl");

	TCHAR szTooltip[256];
	mir_sntprintf(szTooltip, _countof(szTooltip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName(hContact, 0));

	CLISTEVENT cle = { sizeof(cle) };
	cle.flags = CLEF_TCHAR;
	cle.hContact = hContact;
	cle.hDbEvent = lParam;
	cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_URL);
	cle.pszService = "SRUrl/ReadUrl";
	cle.ptszTooltip = szTooltip;
	CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
	return 0;
}
Example #25
0
void ReturnNotify(MCONTACT hContact, TCHAR *message)
{
	if (db_get_b(hContact, "CList", "NotOnList", 0) == 1 || db_get_b(hContact, "CList", "Hidden", 0) == 1)
		return;

	SkinPlaySound("buddyExpectatorReturn");

	if (options.iShowPopup > 0) {
		// Display Popup
		POPUPDATAT ppd = { 0 };
		ppd.lchContact = hContact;
		ppd.lchIcon = hIcon;
		_tcsncpy(ppd.lptzContactName, (TCHAR*)pcli->pfnGetContactDisplayName(hContact, 0), MAX_CONTACTNAME);
		_tcsncpy(ppd.lptzText, message, MAX_SECONDLINE);
		if (!options.iUsePopupColors) {
			ppd.colorBack = options.iPopupColorBack;
			ppd.colorText = options.iPopupColorFore;
		}
		ppd.PluginWindowProc = PopupDlgProc;
		ppd.PluginData = NULL;
		ppd.iSeconds = options.iPopupDelay;
		PUAddPopupT(&ppd);
	}

	if (options.iShowEvent > 0) {
		CLISTEVENT cle = { sizeof(cle) };
		cle.hContact = hContact;
		cle.hIcon = hIcon;
		cle.pszService = "BuddyExpectator/actionReturned";
		cle.flags = CLEF_TCHAR;

		TCHAR* nick = (TCHAR*)pcli->pfnGetContactDisplayName(hContact, 0);
		TCHAR tmpMsg[512];
		mir_sntprintf(tmpMsg, _T("%s %s"), nick, message);
		cle.ptszTooltip = tmpMsg;

		CallServiceSync(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
	}
}
Example #26
0
void showPopupRM(HANDLE hContact)
{
	if (db_get_b(0, MODULENAME, "sr", 0))
		showPopup(sim010, hContact, g_hPOP[POP_PU_MSR], 2);
	SkinPlaySound("IncomingSecureMessage");
}
Example #27
0
void showPopupSM(HANDLE hContact)
{
	if (db_get_b(0, MODULENAME, "ss", 0))
		showPopup(sim009, hContact, g_hPOP[POP_PU_MSS], 2);
	SkinPlaySound("OutgoingSecureMessage");
}
Example #28
0
//Handles new SMS messages added to the database
int handleNewMessage(WPARAM hContact, LPARAM hDbEvent)
{
	char szServiceFunction[MAX_PATH], *pszServiceFunctionName;
	TCHAR szToolTip[MAX_PATH];
	DBEVENTINFO dbei = { sizeof(dbei) };

	if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == -1)
		return 0;

	dbei.pBlob = (PBYTE)MEMALLOC(dbei.cbBlob);
	if (!dbei.pBlob)
		return 0;
	memcpy(szServiceFunction, PROTOCOL_NAMEA, PROTOCOL_NAME_SIZE);
	pszServiceFunctionName = szServiceFunction + PROTOCOL_NAME_LEN;

	if (db_event_get(hDbEvent, &dbei) == 0)
	if ((dbei.flags & DBEF_SENT) == 0)
	if (dbei.eventType == ICQEVENTTYPE_SMS) {
		if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN) {
			SkinPlaySound("RecvSMSMsg");
			if (DB_SMS_GetByte(NULL, "AutoPopup", 0)) {
				if (RecvSMSWindowAdd(hContact, ICQEVENTTYPE_SMS, NULL, 0, (LPSTR)dbei.pBlob, dbei.cbBlob))
					db_event_markRead(hContact, hDbEvent);
			}
			else {
				memcpy(pszServiceFunctionName, SMS_READ, sizeof(SMS_READ));
				mir_sntprintf(szToolTip, TranslateT("SMS Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0));

				CLISTEVENT cle = {};
				cle.flags = CLEF_TCHAR;
				cle.hContact = hContact;
				cle.hDbEvent = hDbEvent;
				cle.hIcon = Skin_LoadIcon(SKINICON_OTHER_SMS);
				cle.pszService = szServiceFunction;
				cle.ptszTooltip = szToolTip;
				pcli->pfnAddEvent(&cle);
			}
		}
	}
	else if (dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION) {
		SkinPlaySound("RecvSMSConfirmation");
		if (DB_SMS_GetByte(NULL, "AutoPopup", 0)) {
			if (RecvSMSWindowAdd(hContact, ICQEVENTTYPE_SMSCONFIRMATION, NULL, 0, (LPSTR)dbei.pBlob, dbei.cbBlob))
				db_event_delete(hContact, hDbEvent);
		}
		else {
			UINT iIcon;
			if (GetDataFromMessage((LPSTR)dbei.pBlob, dbei.cbBlob, NULL, NULL, 0, NULL, &iIcon)) {
				memcpy(pszServiceFunctionName, SMS_READ_ACK, sizeof(SMS_READ_ACK));
				mir_sntprintf(szToolTip, TranslateT("SMS Confirmation from %s"), pcli->pfnGetContactDisplayName(hContact, 0));

				CLISTEVENT cle = {};
				cle.flags = CLEF_TCHAR;
				cle.hContact = hContact;
				cle.hDbEvent = hDbEvent;
				cle.hIcon = (HICON)LoadImage(ssSMSSettings.hInstance, MAKEINTRESOURCE(iIcon), IMAGE_ICON, 0, 0, LR_SHARED);
				cle.pszService = szServiceFunction;
				cle.ptszTooltip = szToolTip;
				pcli->pfnAddEvent(&cle);
			}
		}
	}
	MEMFREE(dbei.pBlob);
	return 0;
}
Example #29
0
// This function handles the ACK received from that hooked.
int handleAckSMS(WPARAM wParam, LPARAM lParam)
{
	if (!lParam)
		return 0;
	if (((ACKDATA*)lParam)->type != ICQACKTYPE_SMS)
		return 0;

	char szPhone[MAX_PHONE_LEN] = { 0 };
	TCHAR tszPhone[MAX_PHONE_LEN] = { 0 };
	LPSTR lpszXML = (LPSTR)((ACKDATA*)lParam)->lParam, lpszData, lpszPhone;
	size_t dwXMLSize = 0, dwDataSize, dwPhoneSize;
	ACKDATA *ack = ((ACKDATA*)lParam);

	if (lpszXML)
		dwXMLSize = mir_strlen(lpszXML);

	if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_message", "text", NULL)) {
		if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszPhone, &dwPhoneSize, "sms_message", "sender", NULL)) {
			LPSTR lpszMessageUTF;
			size_t dwBuffLen, dwMessageXMLEncodedSize, dwMessageXMLDecodedSize;
			DBEVENTINFO dbei = { sizeof(dbei) };

			dwBuffLen = (dwDataSize + MAX_PATH);
			dbei.pBlob = (LPBYTE)MEMALLOC((dwBuffLen + dwPhoneSize));
			LPWSTR lpwszMessageXMLEncoded = (LPWSTR)MEMALLOC((dwBuffLen*sizeof(WCHAR)));
			LPWSTR lpwszMessageXMLDecoded = (LPWSTR)MEMALLOC((dwBuffLen*sizeof(WCHAR)));
			if (dbei.pBlob && lpwszMessageXMLEncoded && lpwszMessageXMLDecoded) {
				dwMessageXMLEncodedSize = MultiByteToWideChar(CP_UTF8, 0, lpszData, (int)dwDataSize, lpwszMessageXMLEncoded, (int)dwBuffLen);
				DecodeXML(lpwszMessageXMLEncoded, dwMessageXMLEncodedSize, lpwszMessageXMLDecoded, dwBuffLen, &dwMessageXMLDecodedSize);
				lpszMessageUTF = (LPSTR)lpwszMessageXMLEncoded;
				WideCharToMultiByte(CP_UTF8, 0, lpwszMessageXMLDecoded, (int)dwMessageXMLDecodedSize, lpszMessageUTF, (int)dwBuffLen, NULL, NULL);

				dwPhoneSize = CopyNumberA(szPhone, lpszPhone, dwPhoneSize);
				dwPhoneSize = MultiByteToWideChar(CP_UTF8, 0, szPhone, (int)dwPhoneSize, tszPhone, MAX_PHONE_LEN);
				MCONTACT hContact = HContactFromPhone(tszPhone, dwPhoneSize);

				dbei.szModule = GetModuleName(hContact);
				dbei.timestamp = time(NULL);
				dbei.flags = DBEF_UTF;
				dbei.eventType = ICQEVENTTYPE_SMS;
				dbei.cbBlob = (mir_snprintf((LPSTR)dbei.pBlob, ((dwBuffLen + dwPhoneSize)), "SMS From: +%s\r\n%s", szPhone, lpszMessageUTF) + sizeof(DWORD));
				//dbei.pBlob=(LPBYTE)lpszBuff;
				(*((DWORD*)(dbei.pBlob + (dbei.cbBlob - sizeof(DWORD))))) = 0;
				MEVENT hResult = db_event_add(hContact, &dbei);
				if (hContact == NULL) {
					if (RecvSMSWindowAdd(NULL, ICQEVENTTYPE_SMS, tszPhone, dwPhoneSize, (LPSTR)dbei.pBlob, dbei.cbBlob)) {
						db_event_markRead(hContact, hResult);
						SkinPlaySound("RecvSMSMsg");
					}
				}
			}
			MEMFREE(lpwszMessageXMLDecoded);
			MEMFREE(lpwszMessageXMLEncoded);
			MEMFREE(dbei.pBlob);
		}
	}
	else
		if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_delivery_receipt", "delivered", NULL)) {
			if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszPhone, &dwPhoneSize, "sms_delivery_receipt", "destination", NULL)) {
				dwPhoneSize = CopyNumberA(szPhone, lpszPhone, dwPhoneSize);
				dwPhoneSize = MultiByteToWideChar(CP_UTF8, 0, szPhone, (int)dwPhoneSize, tszPhone, MAX_PHONE_LEN);
				MCONTACT hContact = HContactFromPhone(tszPhone, dwPhoneSize);

				DBEVENTINFO dbei = { 0 };
				dbei.cbSize = sizeof(dbei);
				dbei.szModule = GetModuleName(hContact);
				dbei.timestamp = time(NULL);
				dbei.flags = DBEF_UTF;
				dbei.eventType = ICQEVENTTYPE_SMSCONFIRMATION;
				if (CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "yes", 3) == CSTR_EQUAL) {
					dbei.cbBlob = (MAX_PHONE_LEN + MAX_PATH);
					dbei.pBlob = (PBYTE)MEMALLOC(dbei.cbBlob);
					if (dbei.pBlob) dbei.cbBlob = (mir_snprintf((LPSTR)dbei.pBlob, dbei.cbBlob, "SMS Confirmation From: +%s\r\nSMS was sent succesfully", szPhone) + 4);
				}
				else {
					if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_delivery_receipt", "error", "params", "param", NULL) == FALSE) {
						lpszData = "";
						dwDataSize = 0;
					}
					dbei.cbBlob = (int)(MAX_PHONE_LEN + MAX_PATH + dwDataSize);
					dbei.pBlob = (PBYTE)MEMALLOC(dbei.cbBlob);
					if (dbei.pBlob) {
						dbei.cbBlob = mir_snprintf((LPSTR)dbei.pBlob, dbei.cbBlob, "SMS Confirmation From: +%s\r\nSMS was not sent succesfully: ", szPhone);
						memcpy((dbei.pBlob + dbei.cbBlob), lpszData, dwDataSize);
						dbei.cbBlob += (int)(dwDataSize + sizeof(DWORD));
						(*((DWORD*)(dbei.pBlob + (dbei.cbBlob - sizeof(DWORD))))) = 0;
					}
				}

				if (dbei.pBlob) {
					if (hContact)
						db_event_add(hContact, &dbei);
					else
						RecvSMSWindowAdd(NULL, ICQEVENTTYPE_SMSCONFIRMATION, tszPhone, dwPhoneSize, (LPSTR)dbei.pBlob, dbei.cbBlob);

					MEMFREE(dbei.pBlob);
				}
			}
		}
		else
			if ((ack->result == ACKRESULT_FAILED) || GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_response", "deliverable", NULL)) {
				HWND hWndDlg = SendSMSWindowHwndByHProcessGet(ack->hProcess);
				if (hWndDlg) {
					char szNetwork[MAX_PATH];

					KillTimer(hWndDlg, wParam);
					GetXMLFieldExBuff(lpszXML, dwXMLSize, szNetwork, sizeof(szNetwork), NULL, "sms_response", "network", NULL);

					if (ack->result == ACKRESULT_FAILED || CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "no", 2) == CSTR_EQUAL) {
						char szBuff[1024];
						TCHAR tszErrorMessage[1028];
						LPSTR lpszErrorDescription;

						if (SendSMSWindowMultipleGet(hWndDlg)) {
							TVITEM tvi;
							tvi.mask = TVIF_TEXT;
							tvi.hItem = SendSMSWindowHItemSendGet(hWndDlg);
							tvi.pszText = tszPhone;
							tvi.cchTextMax = _countof(tszPhone);
							TreeView_GetItem(GetDlgItem(hWndDlg, IDC_NUMBERSLIST), &tvi);
						}
						else GetDlgItemText(hWndDlg, IDC_ADDRESS, tszPhone, _countof(szPhone));

						if (ack->result == ACKRESULT_FAILED)
							lpszErrorDescription = lpszXML;
						else {
							lpszErrorDescription = szBuff;
							GetXMLFieldExBuff(lpszXML, dwXMLSize, szBuff, sizeof(szBuff), NULL, "sms_response", "error", "params", "param", NULL);
						}

						mir_sntprintf(tszErrorMessage, TranslateT("SMS message didn't send by %S to %s because: %S"), szNetwork, tszPhone, lpszErrorDescription);
						ShowWindow(hWndDlg, SW_SHOWNORMAL);
						EnableWindow(hWndDlg, FALSE);
						HWND hwndTimeOut = CreateDialog(ssSMSSettings.hInstance, MAKEINTRESOURCE(IDD_SENDSMSTIMEDOUT), hWndDlg, SMSTimedOutDlgProc);
						SetDlgItemText(hwndTimeOut, IDC_STATUS, tszErrorMessage);
					}
					else {
						SendSMSWindowDBAdd(hWndDlg);
						if (SendSMSWindowMultipleGet(hWndDlg)) {
							if (SendSMSWindowNextHItemGet(hWndDlg, SendSMSWindowHItemSendGet(hWndDlg))) {
								SendSMSWindowAsSentSet(hWndDlg);
								SendSMSWindowHItemSendSet(hWndDlg, SendSMSWindowNextHItemGet(hWndDlg, SendSMSWindowHItemSendGet(hWndDlg)));
								SendSMSWindowNext(hWndDlg);
							}
							else SendSMSWindowRemove(hWndDlg);
						}
						else {
							if (CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "yes", 3) == CSTR_EQUAL ||
								CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "smtp", 4) == CSTR_EQUAL) {
								char szSource[MAX_PATH], szMessageID[MAX_PATH];

								if (DB_SMS_GetByte(NULL, "ShowACK", SMS_DEFAULT_SHOWACK)) {
									HWND hwndAccepted = CreateDialog(ssSMSSettings.hInstance, MAKEINTRESOURCE(IDD_SENDSMSACCEPT), hWndDlg, SMSAcceptedDlgProc);
									if (CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "yes", 3) == CSTR_EQUAL) {
										GetXMLFieldExBuff(lpszXML, dwXMLSize, szSource, sizeof(szSource), NULL, "sms_response", "source", NULL);
										GetXMLFieldExBuff(lpszXML, dwXMLSize, szMessageID, sizeof(szMessageID), NULL, "sms_response", "message_id", NULL);
									}
									else {
										SetDlgItemText(hwndAccepted, IDC_ST_SOURCE, TranslateT("From:"));
										SetDlgItemText(hwndAccepted, IDC_ST_MESSAGEID, TranslateT("To:"));
										GetXMLFieldExBuff(lpszXML, dwXMLSize, szSource, sizeof(szSource), NULL, "sms_response", "from", NULL);
										GetXMLFieldExBuff(lpszXML, dwXMLSize, szMessageID, sizeof(szMessageID), NULL, "sms_response", "to", NULL);
									}
									SetDlgItemTextA(hwndAccepted, IDC_NETWORK, szNetwork);
									SetDlgItemTextA(hwndAccepted, IDC_SOURCE, szSource);
									SetDlgItemTextA(hwndAccepted, IDC_MESSAGEID, szMessageID);
								}
								else SendSMSWindowRemove(hWndDlg);
							}
							else SendSMSWindowRemove(hWndDlg);
						}
					}
				}
			}
	return 0;
}
Example #30
0
static INT_PTR CALLBACK ShutdownDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	BYTE shutdownType = (BYTE)GetWindowLongPtr(hwndDlg, DWLP_USER);
	WORD countdown = (WORD)GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA);

	switch (msg) {
	case WM_INITDIALOG:
		hwndShutdownDlg = hwndDlg;
		SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam);
		TranslateDialogDefault(hwndDlg);

		if (lParam == SDSDT_SHUTDOWN || lParam == SDSDT_REBOOT || lParam == SDSDT_LOGOFF)
			ShowWindow(GetDlgItem(hwndDlg, IDC_TEXT_UNSAVEDWARNING), SW_SHOW);
		SendDlgItemMessage(hwndDlg, IDC_ICON_HEADER, STM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon("AutoShutdown_Header"));
		{
			HFONT hBoldFont;
			LOGFONT lf;
			if (GetObject((HFONT)SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_GETFONT, 0, 0), sizeof(lf), &lf)) {
				lf.lfWeight = FW_BOLD;
				hBoldFont = CreateFontIndirect(&lf);
			}
			else hBoldFont = NULL;
			SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_SETFONT, (WPARAM)hBoldFont, FALSE);
			SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, (LONG_PTR)hBoldFont);
		}
		{
			countdown = db_get_w(NULL, "AutoShutdown", "ConfirmDlgCountdown", SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT);
			if (countdown < 3)
				countdown = SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT;
			SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, countdown);
			SendMessage(hwndDlg, M_UPDATE_COUNTDOWN, 0, countdown);
		}
		SkinPlaySound("AutoShutdown_Countdown");
		if (!SetTimer(hwndDlg, 1, 1000, NULL))
			PostMessage(hwndDlg, M_START_SHUTDOWN, 0, 0);

		Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "AutoShutdown", "ConfirmDlg_");

		/* disallow foreground window changes (WinMe/2000+) */
		SetForegroundWindow(hwndDlg);
		LockSetForegroundWindow(LSFW_LOCK);

		SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hwndDlg, IDCANCEL), TRUE);
		return FALSE; /* focus set on cancel */

	case WM_DESTROY:
		{
			hwndShutdownDlg = NULL;
			ShowWindow(hwndDlg, SW_HIDE);
			/* reallow foreground window changes (WinMe/2000+) */
			LockSetForegroundWindow(LSFW_UNLOCK);
			Utils_SaveWindowPosition(hwndDlg, NULL, "AutoShutdown", "ConfirmDlg_");
			HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_GETFONT, 0, 0);
			SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_SETFONT, 0, FALSE); /* no return value */
			if (hFont != NULL) DeleteObject(hFont);
		}
		return TRUE;

	case M_START_SHUTDOWN:
		if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BUTTON_SHUTDOWNNOW))) {
			EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_SHUTDOWNNOW), FALSE);
			ShowWindow(hwndDlg, SW_HIDE);  /* get rid of the dialog immediately */
			DWORD dwErrCode = ShutdownNow(shutdownType);
			if (dwErrCode != ERROR_SUCCESS) {
				char *pszErr = GetWinErrorDescription(dwErrCode);
				ShowInfoMessage(NIIF_ERROR, Translate("Automatic Shutdown Error"), Translate("The shutdown process failed!\nReason: %s"), (pszErr != NULL) ? pszErr : Translate("Unknown"));
				if (pszErr != NULL) LocalFree(pszErr);
			}
			DestroyWindow(hwndDlg);
		}
		return TRUE;

	case WM_TIMER:
		if (countdown) {
			--countdown;
			SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, countdown);
			if (countdown == 27 || countdown == 24 || countdown == 21 || countdown == 19 ||
				countdown == 17 || countdown == 15 || countdown == 13 || countdown == 11 ||
				countdown <= 10)
				SkinPlaySound("AutoShutdown_Countdown");
		}
		else KillTimer(hwndDlg, wParam);  /* countdown finished */
		PostMessage(hwndDlg, M_UPDATE_COUNTDOWN, 0, countdown);
		return TRUE;

	case M_UPDATE_COUNTDOWN:  /* lParam=(WORD)countdown */
		{
			TCHAR szText[256];
			mir_sntprintf(szText, TranslateTS(desc[shutdownType - 1]), lParam);
			SetDlgItemText(hwndDlg, IDC_TEXT_HEADER, szText);
			/* countdown finished */
			if (!lParam)
				PostMessage(hwndDlg, M_START_SHUTDOWN, 0, 0);
		}
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_BUTTON_SHUTDOWNNOW:
			KillTimer(hwndDlg, 1);
			SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, 0);
			SendMessage(hwndDlg, M_UPDATE_COUNTDOWN, 0, (LONG)0);
			PostMessage(hwndDlg, M_START_SHUTDOWN, 0, 0);
			return TRUE;
		case IDCANCEL: /* WM_CLOSE */
			if (countdown) {
				KillTimer(hwndDlg, 1);
				DestroyWindow(hwndDlg);
			}
			return TRUE;
		}
		break;
	}
	return FALSE;
}