Example #1
0
bool StressTest::GoToNextPage()
{
    double pageRenderTime = currPageRenderTime.GetTimeInMs();
    ScopedMem<TCHAR> s(str::Format(_T("Page %d rendered in %d milliseconds"), currPage, (int)pageRenderTime));
    ShowNotification(win, s, true, false, NG_STRESS_TEST_BENCHMARK);

    ++currPage;
    while (!IsInRange(pageRanges, currPage) && currPage <= win->dm->PageCount()) {
        currPage++;
    }

    if (currPage > win->dm->PageCount()) {
        if (GoToNextFile())
            return true;
        Finished(true);
        return false;
    }

    win->dm->GoToPage(currPage, 0);
    currPageRenderTime.Start();

    // start text search when we're in the middle of the document, so that
    // search thread touches both pages that were already rendered and not yet
    // rendered
    // TODO: it would be nice to also randomize search starting page but the
    // current API doesn't make it easy
    if (currPage == pageForSearchStart) {
        // use text that is unlikely to be found, so that we search all pages
        win::SetText(win->hwndFindBox, _T("!z_yt"));
        FindTextOnThread(win);
    }

    if (1 == rand() % 3) {
        ClientRect rect(win->hwndFrame);
        int deltaX = (rand() % 40) - 23;
        rect.dx += deltaX;
        if (rect.dx < 300)
            rect.dx += (abs(deltaX) * 3);
        int deltaY = (rand() % 40) - 23;
        rect.dy += deltaY;
        if (rect.dy < 300)
            rect.dy += (abs(deltaY) * 3);
        SendMessage(win->hwndFrame, WM_SIZE, 0, MAKELONG(rect.dx, rect.dy));
    }
    return true;
}
Example #2
0
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 = GetIcon(IDI_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;
	}
}
LONG32 SnarlInterface::ShowNotification(LPCWSTR Class, LPCWSTR Title, LPCWSTR Text, LONG32 Timeout, LPCWSTR Icon, HWND hWndReply, LONG32 uReplyMsg, LPCWSTR Sound)
{
	LPSTR szParam1 = WideToUTF8(Class);
	LPSTR szParam2 = WideToUTF8(Title);
	LPSTR szParam3 = WideToUTF8(Text);
	LPSTR szParam4 = WideToUTF8(Icon);
	LPSTR szParam5 = WideToUTF8(Sound);
	
	LONG32 result = ShowNotification(szParam1, szParam2, szParam3, Timeout, szParam4, hWndReply, uReplyMsg, szParam5);
	
	delete [] szParam1;
	delete [] szParam2;
	delete [] szParam3;
	delete [] szParam4;
	delete [] szParam5;
	
	return result;
}
Example #4
0
void Scene_Battle_Rpg2k3::Escape() {
	Game_BattleAlgorithm::Escape escape_alg = Game_BattleAlgorithm::Escape(active_actor);
	active_actor->SetGauge(0);

	bool escape_success = escape_alg.Execute();
	escape_alg.Apply();

	if (!escape_success) {
		std::vector<std::string> battle_result_messages;
		escape_alg.GetResultMessages(battle_result_messages);
		SetState(State_SelectActor);
		ShowNotification(battle_result_messages[0]);
	}
	else {
		Game_Temp::battle_result = Game_Temp::BattleEscape;

		// ToDo: Run away animation
		Scene::Pop();
	}
}
void CSkypeProto::OnGetTrouter(const NETLIBHTTPREQUEST *response)
{
	if (response == NULL || response->pData == NULL)
	{
		ShowNotification(m_tszUserName, TranslateT("Failed to establish a TRouter connection."), NULL, 1);
		return;
	}

	CMStringA data(response->pData);
	int iStart = 0;
	CMStringA szToken = data.Tokenize(":", iStart).Trim();
	TRouter.sessId = szToken.GetString();
	
	SetEvent(m_hTrouterEvent);
	SetEvent(m_hTrouterHealthEvent);

	if ((time(NULL) - TRouter.lastRegistrationTime) >= 3600)
	{
		SendRequest(new RegisterTrouterRequest(li, TRouter.url.c_str(), TRouter.sessId.c_str()));
		TRouter.lastRegistrationTime = time(NULL);
	}
}
Example #6
0
void StressTest::Start(const TCHAR *path, const TCHAR *filter, const TCHAR *ranges, int cycles)
{
    srand((unsigned int)time(NULL));
    GetSystemTime(&stressStartTime);

    // forbid entering sleep mode during tests
    SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);

    basePath.Set(str::Dup(path));
    fileFilter.Set(filter && !str::Eq(filter, _T("*")) ? str::Dup(filter) : NULL);
    if (file::Exists(basePath)) {
        filesToOpen.Append(str::Dup(basePath));
        ParsePageRanges(ranges, pageRanges);
    }
    else if (dir::Exists(basePath)) {
        OpenDir(basePath);
        ParsePageRanges(ranges, fileRanges);
    }
    else {
        // Note: dev only, don't translate
        ScopedMem<TCHAR> s(str::Format(_T("Path '%s' doesn't exist"), path));
        ShowNotification(win, s, false /* autoDismiss */, true, NG_STRESS_TEST_SUMMARY);
        Finished(false);
        return;
    }

    this->cycles = cycles;
    if (pageRanges.Count() == 0)
        pageRanges.Append(PageRange());
    if (fileRanges.Count() == 0)
        fileRanges.Append(PageRange());

    if (GoToNextFile())
        TickTimer();
    else
        Finished(true);
}
Example #7
0
void UnreadThreadNotification(LPCSTR acc, LPCTSTR jid, LPCTSTR url, LPCTSTR unreadCount, const MAIL_THREAD_NOTIFICATION *mtn)
{
	POPUPDATAT data = { 0 };
	FormatPseudocontactDisplayName(&data.lptzContactName[0], jid, unreadCount);

	CMString tszSenders;
	for (int i = 0; i < SENDER_COUNT; i++) {
		const SENDER &p = mtn->senders[i];
		if (p.addr == NULL)
			break;

		if (p.name)
			tszSenders.AppendFormat(_T("    %s <%s>\n"), p.name, p.addr);
		else
			tszSenders.AppendFormat(_T("    %s\n"), p.addr);
	}

	if (ReadCheckbox(0, IDC_ADDSNIP, (DWORD)TlsGetValue(itlsSettings)))
		mir_sntprintf(data.lptzText, TranslateTS(FULL_NOTIFICATION_FORMAT), mtn->subj, tszSenders.c_str(), mtn->snip);
	else
		mir_sntprintf(data.lptzText, TranslateTS(SHORT_NOTIFICATION_FORMAT), mtn->subj, tszSenders.c_str());

	ShowNotification(acc, &data, jid, url, unreadCount);
}
Example #8
0
void Reporting::Error(const char *text, const char *caption, const CWnd *parent)
//------------------------------------------------------------------------------
{
	ShowNotification(text, caption, MB_OK | MB_ICONERROR, parent);
}
Example #9
0
bool StressTest::OpenFile(const TCHAR *fileName)
{
    bool reuse = rand() % 3 != 1;
    _tprintf(_T("%s\n"), fileName);
    fflush(stdout);
    LoadArgs args(fileName, NULL, true /* show */, reuse);
    WindowInfo *w = LoadDocument(args);
    if (!w)
        return false;

    if (w == win) { // WindowInfo reused
        if (!win->dm)
            return false;
    } else if (!w->dm) { // new WindowInfo
        CloseWindow(w, false, true);
        return false;
    }

    // transfer ownership of stressTest object to a new window and close the
    // current one
    assert(this == win->stressTest);
    if (w != win) {
        if (win->IsDocLoaded()) {
            // try to provoke a crash in RenderCache cleanup code
            ClientRect rect(win->hwndFrame);
            rect.Inflate(rand() % 10, rand() % 10);
            SendMessage(win->hwndFrame, WM_SIZE, 0, MAKELONG(rect.dx, rect.dy));
            win->RenderPage(1);
            win->RepaintAsync();
        }

        WindowInfo *toClose = win;
        w->stressTest = win->stressTest;
        win->stressTest = NULL;
        win = w;
        CloseWindow(toClose, false, false);
    }
    if (!win->dm)
        return false;

    win->dm->ChangeDisplayMode(DM_CONTINUOUS);
    win->dm->ZoomTo(ZOOM_FIT_PAGE);
    win->dm->GoToFirstPage();
    if (win->tocVisible || gGlobalPrefs.favVisible)
        SetSidebarVisibility(win, win->tocVisible, gGlobalPrefs.favVisible);

    currPage = pageRanges.At(0).start;
    win->dm->GoToPage(currPage, 0);
    currPageRenderTime.Start();
    ++filesCount;

    pageForSearchStart = (rand() % win->dm->PageCount()) + 1;
    // search immediately in single page documents
    if (1 == pageForSearchStart) {
        // use text that is unlikely to be found, so that we search all pages
        win::SetText(win->hwndFindBox, _T("!z_yt"));
        FindTextOnThread(win);
    }

    int secs = SecsSinceSystemTime(stressStartTime);
    ScopedMem<TCHAR> tm(FormatTime(secs));
    ScopedMem<TCHAR> s(str::Format(_T("File %d: %s, time: %s"), filesCount, fileName, tm));
    ShowNotification(win, s, false, false, NG_STRESS_TEST_SUMMARY);

    return true;
}
Example #10
0
bool CToxProto::LoadToxProfile(Tox_Options *options)
{
	debugLogA(__FUNCTION__": loading tox profile");

	mir_cslock locker(profileLock);
	
	ptrT profilePath(GetToxProfilePath());
	if (!IsFileExists(profilePath))
		return false;

	FILE *profile = _tfopen(profilePath, _T("rb"));
	if (profile == NULL)
	{
		ShowNotification(TranslateT("Unable to open Tox profile"), MB_ICONERROR);
		debugLogA(__FUNCTION__": failed to open tox profile");
		return false;
	}

	fseek(profile, 0, SEEK_END);
	long size = ftell(profile);
	rewind(profile);
	if (size < 0)
	{
		fclose(profile);
		return false;
	}
	
	if (size == 0)
	{
		fclose(profile);
		return true;
	}

	uint8_t *data = (uint8_t*)mir_calloc(size);
	if (fread((char*)data, sizeof(char), size, profile) != (size_t)size)
	{
		fclose(profile);
		ShowNotification(TranslateT("Unable to read Tox profile"), MB_ICONERROR);
		debugLogA(__FUNCTION__": failed to read tox profile");
		mir_free(data);
		return false;
	}
	fclose(profile);

	if (tox_is_data_encrypted(data))
	{
		pass_ptrA password(mir_utf8encodeW(pass_ptrT(getTStringA("Password"))));
		if (password == NULL || mir_strlen(password) == 0)
		{
			CToxPasswordEditor passwordEditor(this);
			if (!passwordEditor.DoModal())
			{
				mir_free(data);
				return false;
			}
		}
		uint8_t *encryptedData = (uint8_t*)mir_calloc(size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
		TOX_ERR_DECRYPTION coreDecryptError;
		if (!tox_pass_decrypt(data, size, (uint8_t*)(char*)password, mir_strlen(password), encryptedData, &coreDecryptError))
		{
			ShowNotification(TranslateT("Unable to decrypt Tox profile"), MB_ICONERROR);
			debugLogA(__FUNCTION__": failed to decrypt tox profile (%d)", coreDecryptError);
			mir_free(data);
			return false;
		}
		mir_free(data);
		data = encryptedData;
		size -= TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
	}

	if (data)
	{
		options->savedata_data = data;
		options->savedata_length = size;
		options->savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE;
		return true;
	}

	return false;
}
Example #11
0
// returns true if the double-click was handled and false if it wasn't
bool OnInverseSearch(WindowInfo *win, int x, int y)
{
    if (!HasPermission(Perm_DiskAccess) || gPluginMode) return false;
    if (!win->IsDocLoaded() || win->dm->engineType != Engine_PDF) return false;

    // Clear the last forward-search result
    win->fwdSearchMark.rects.Reset();
    InvalidateRect(win->hwndCanvas, NULL, FALSE);

    // On double-clicking error message will be shown to the user
    // if the PDF does not have a synchronization file
    if (!win->pdfsync) {
        int err = Synchronizer::Create(win->loadedFilePath,
            static_cast<PdfEngine *>(win->dm->engine), &win->pdfsync);
        if (err == PDFSYNCERR_SYNCFILE_NOTFOUND) {
            // We used to warn that "No synchronization file found" at this
            // point if gGlobalPrefs->enableTeXEnhancements is set; we no longer
            // so do because a double-click has several other meanings
            // (selecting a word or an image, navigating quickly using links)
            // and showing an unrelated warning in all those cases seems wrong
            return false;
        }
        if (err != PDFSYNCERR_SUCCESS) {
            ShowNotification(win, _TR("Synchronization file cannot be opened"));
            return true;
        }
        gGlobalPrefs->enableTeXEnhancements = true;
    }

    int pageNo = win->dm->GetPageNoByPoint(PointI(x, y));
    if (!win->dm->ValidPageNo(pageNo))
        return false;

    PointI pt = win->dm->CvtFromScreen(PointI(x, y), pageNo).Convert<int>();
    ScopedMem<WCHAR> srcfilepath;
    UINT line, col;
    int err = win->pdfsync->DocToSource(pageNo, pt, srcfilepath, &line, &col);
    if (err != PDFSYNCERR_SUCCESS) {
        ShowNotification(win, _TR("No synchronization info at this position"));
        return true;
    }

    WCHAR *inverseSearch = gGlobalPrefs->inverseSearchCmdLine;
    if (!inverseSearch)
        // Detect a text editor and use it as the default inverse search handler for now
        inverseSearch = AutoDetectInverseSearchCommands();

    ScopedMem<WCHAR> cmdline;
    if (inverseSearch)
        cmdline.Set(win->pdfsync->PrepareCommandline(inverseSearch, srcfilepath, line, col));
    if (!str::IsEmpty(cmdline.Get())) {
        // resolve relative paths with relation to SumatraPDF.exe's directory
        ScopedMem<WCHAR> appDir(GetExePath());
        if (appDir)
            appDir.Set(path::GetDir(appDir));
        ScopedHandle process(LaunchProcess(cmdline, appDir));
        if (!process)
            ShowNotification(win, _TR("Cannot start inverse search command. Please check the command line in the settings."));
    }
    else if (gGlobalPrefs->enableTeXEnhancements)
        ShowNotification(win, _TR("Cannot start inverse search command. Please check the command line in the settings."));

    if (inverseSearch != gGlobalPrefs->inverseSearchCmdLine)
        free(inverseSearch);

    return true;
}
Example #12
0
void Reporting::Warning(const std::wstring &text, const std::wstring &caption, const CWnd *parent)
//------------------------------------------------------------------------------------------------
{
	ShowNotification(text, caption, MB_OK | MB_ICONWARNING, parent);
}
Example #13
0
void Reporting::Notification(const std::wstring &text, const std::wstring &caption, const CWnd *parent)
//-----------------------------------------------------------------------------------------------------
{
	ShowNotification(text, caption, MB_OK, parent);
}
Example #14
0
void Reporting::Error(const std::wstring &text, const std::wstring &caption, const CWnd *parent)
//----------------------------------------------------------------------------------------------
{
	ShowNotification(text, caption, MB_OK | MB_ICONERROR, parent);
}
Example #15
0
bool Scene_Battle_Rpg2k3::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase* action) {
	if (Game_Battle::IsBattleAnimationWaiting()) {
		return false;
	}

	Sprite_Battler* source_sprite;
	source_sprite = Game_Battle::GetSpriteset().FindBattler(action->GetSource());

	if (source_sprite && !source_sprite->IsIdling()) {
		return false;
	}

	std::vector<Game_Battler*>::const_iterator it;

	switch (battle_action_state) {
	case BattleActionState_Start:
		ShowNotification(action->GetStartMessage());

		if (!action->IsTargetValid()) {
			action->SetTarget(action->GetTarget()->GetParty().GetNextActiveBattler(action->GetTarget()));

			if (!action->IsTargetValid()) {
				// Nothing left to target, abort
				return true;
			}
		}

		//printf("Action: %s\n", action->GetSource()->GetName().c_str());

		action->Execute();

		if (action->GetTarget() && action->GetAnimation()) {
			Game_Battle::ShowBattleAnimation(
				action->GetAnimation()->ID,
				action->GetTarget());
		}

		if (source_sprite) {
			source_sprite->Flash(Color(255, 255, 255, 100), 15);
			source_sprite->SetAnimationState(
				action->GetSourceAnimationState(),
				Sprite_Battler::LoopState_DefaultAnimationAfterFinish);
		}

		if (action->IsFirstAttack() && action->GetStartSe()) {
			Game_System::SePlay(*action->GetStartSe());
		}

		battle_action_state = BattleActionState_Result;
		break;
	case BattleActionState_Result:
		do {
			if (!action->IsFirstAttack()) {
				action->Execute();
			}
			else {
				std::vector<int16_t> states = action->GetSource()->NextBattleTurn();
			}

			Sprite_Battler* target_sprite = Game_Battle::GetSpriteset().FindBattler(action->GetTarget());
			if (action->IsSuccess() && target_sprite) {
				target_sprite->SetAnimationState(Sprite_Battler::AnimationState_Damage, Sprite_Battler::LoopState_DefaultAnimationAfterFinish);
			}

			action->Apply();

			if (action->GetTarget()) {
				DrawFloatText(
					action->GetTarget()->GetBattleX(),
					action->GetTarget()->GetBattleY(),
					0,
					action->IsSuccess() && action->GetAffectedHp() != -1 ? boost::lexical_cast<std::string>(action->GetAffectedHp()) : Data::terms.miss,
					30);

				targets.push_back(action->GetTarget());
			}

			status_window->Refresh();
		} while (action->TargetNext());

		if (action->GetResultSe()) {
			Game_System::SePlay(*action->GetResultSe());
		}

		battle_action_wait = 30;

		battle_action_state = BattleActionState_Finished;

		break;
	case BattleActionState_Finished:
		if (battle_action_wait--) {
			return false;
		}
		battle_action_wait = 30;

		for (it = targets.begin(); it != targets.end(); it++) {
			if ((*it)->IsDead()) {
				if (action->GetDeathSe()) {
					Game_System::SePlay(*action->GetDeathSe());
				}

				Sprite_Battler* target_sprite = Game_Battle::GetSpriteset().FindBattler(*it);

				if (target_sprite) {
					target_sprite->SetAnimationState(Sprite_Battler::AnimationState_Dead);
				}
			}
		}

		// Reset variables
		battle_action_state = BattleActionState_Start;
		targets.clear();

		return true;
	}

	return false;
}
Example #16
0
void Reporting::Warning(const char *text, const char *caption, const CWnd *parent)
//--------------------------------------------------------------------------------
{
	ShowNotification(text, caption, MB_OK | MB_ICONWARNING, parent);
}
bool Scene_Battle_Rpg2k3::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase* action) {
	if (Main_Data::game_screen->IsBattleAnimationWaiting()) {
		return false;
	}

	Sprite_Battler* source_sprite;
	source_sprite = Game_Battle::GetSpriteset().FindBattler(action->GetSource());

	if (source_sprite && !source_sprite->IsIdling()) {
		return false;
	}

	switch (battle_action_state) {
	case BattleActionState_Start:
		ShowNotification(action->GetStartMessage());

		if (!action->IsTargetValid()) {
			action->SetTarget(action->GetTarget()->GetParty().GetNextActiveBattler(action->GetTarget()));
		}

		//printf("Action: %s\n", action->GetSource()->GetName().c_str());

		action->Execute();

		if (action->GetTarget() && action->GetAnimation()) {
			Main_Data::game_screen->ShowBattleAnimationBattle(
				action->GetAnimation()->ID,
				action->GetTarget());
		}

		if (source_sprite) {
			source_sprite->Flash(Color(255, 255, 255, 100), 15);
			source_sprite->SetAnimationState(
				action->GetSourceAnimationState(),
				Sprite_Battler::LoopState_IdleAnimationAfterFinish);
		}

		if (action->IsFirstAttack() && action->GetStartSe()) {
			Game_System::SePlay(*action->GetStartSe());
		}

		battle_action_state = BattleActionState_Result;
		break;
	case BattleActionState_Result:
		do {
			if (!action->IsFirstAttack()) {
				action->Execute();
			}

			Sprite_Battler* target_sprite = Game_Battle::GetSpriteset().FindBattler(action->GetTarget());
			if (action->IsSuccess() && target_sprite) {
				target_sprite->SetAnimationState(Sprite_Battler::AnimationState_Damage, Sprite_Battler::LoopState_IdleAnimationAfterFinish);
			}

			action->Apply();

			if (action->GetTarget()) {
				DrawFloatText(
					action->GetTarget()->GetBattleX(),
					action->GetTarget()->GetBattleY(),
					0,
					action->IsSuccess() && action->GetAffectedHp() != -1 ? boost::lexical_cast<std::string>(action->GetAffectedHp()) : Data::terms.miss,
					30);
			}

			status_window->Refresh();
		} while (action->TargetNext());

		if (action->GetResultSe()) {
			Game_System::SePlay(*action->GetResultSe());
		}

		battle_action_wait = 30;

		battle_action_state = BattleActionState_Finished;

		break;
	case BattleActionState_Finished:
		if (battle_action_wait--) {
			return false;
		}
		battle_action_wait = 30;

		if (action->GetTarget()) {
			Sprite_Battler* target_sprite = Game_Battle::GetSpriteset().FindBattler(action->GetTarget());

			if (action->GetTarget()->IsDead()) {
				if (action->GetDeathSe()) {
					Game_System::SePlay(*action->GetDeathSe());
				}

				if (target_sprite) {
					target_sprite->SetAnimationState(Sprite_Battler::AnimationState_Dead);
				}
			}
			else {
				if (target_sprite) {
					target_sprite->SetAnimationState(Sprite_Battler::AnimationState_Idle);
				}
			}
		}

		// Reset variables
		battle_action_state = BattleActionState_Start;

		return true;
	}

	return false;
}
Example #18
0
void CSteamProto::ShowNotification(const TCHAR *message, int flags, MCONTACT hContact)
{
	ShowNotification(TranslateT(MODULE), message, flags, hContact);
}
Example #19
0
void Reporting::Notification(const char *text, const char *caption, const CWnd *parent)
//-------------------------------------------------------------------------------------
{
	ShowNotification(text, caption, MB_OK, parent);
}
Example #20
0
void CYahooProto::ShowError(const char *title, const char *buff)
{
	if (GetByte( "ShowErrors", 1 )) 
		if (!ShowPopup(title, buff, NULL))
			ShowNotification(title, buff, NIIF_ERROR);
}
Example #21
0
void CToxProto::ShowNotification(const TCHAR *message, int flags, MCONTACT hContact)
{
	ShowNotification(_T(MODULE), message, flags, hContact);
}
Example #22
0
void Reporting::Information(const char *text, const char *caption, const CWnd *parent)
//------------------------------------------------------------------------------------
{
	ShowNotification(text, caption, MB_OK | MB_ICONINFORMATION, parent);
}
Example #23
0
			void KinotifyWidget::PrepareNotification ()
			{
				CreateWidget ();
				SetData ();
				ShowNotification ();
			}
Example #24
0
void CSkypeProto::OnLoginOAuth(const NETLIBHTTPREQUEST *response)
{
	if (!IsStatusConnecting(m_iStatus)) return;

	if (response == NULL || response->pData == NULL)
	{
		ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
		SetStatus(ID_STATUS_OFFLINE);
		return;
	}

	JSONNode json = JSONNode::parse(response->pData);
	if (!json)
	{
		ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
		SetStatus(ID_STATUS_OFFLINE);
		return;
	}

	if (response->resultCode != 200)
	{
		int error = 0;
		if (json["status"])
		{
			const JSONNode &status = json["status"];
			if (status["code"])
			{
				switch(status["code"].as_int())
				{
				case 40002:
					{
						ShowNotification(_T("Skype"), TranslateT("Authentication failed. Invalid username."), NULL, 1);
						error = LOGINERR_BADUSERID;
						break;
					}
				case 40120:
					{
						ShowNotification(_T("Skype"), TranslateT("Authentication failed. Bad username or password."), NULL, 1);
						error = LOGINERR_WRONGPASSWORD;
						break;
					}
				case 40121:
					{
						ShowNotification(_T("Skype"), TranslateT("Too many failed authentication attempts with given username or IP."), NULL, 1);
						error = LOGIN_ERROR_TOOMANY_REQUESTS;
						break;
					}
				default: 
					{
						ShowNotification(_T("Skype"), status["text"] ? status["text"].as_mstring() : TranslateT("Authentication failed. Unknown error."), NULL, 1);
						error = LOGIN_ERROR_UNKNOWN;
					}
				}
			}
		}

		ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, error);
		SetStatus(ID_STATUS_OFFLINE);
		return;
	}

	if (!json["skypetoken"] || !json["expiresIn"])
	{
		ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
		SetStatus(ID_STATUS_OFFLINE);
		return;
	}
	std::string token = json["skypetoken"].as_string();
	setString("TokenSecret", token.c_str());

	int expiresIn = json["expiresIn"].as_int();
	setDword("TokenExpiresIn", time(NULL) + expiresIn);

	OnLoginSuccess();
}