Example #1
0
	void FotoBilderAccount::UploadImagesRequest (const QByteArray& albumId, const QList<UploadItem>& items)
	{
		auto guard = MakeRunnerGuard ();
		for (const auto& item : items)
		{
			CallsQueue_ << [this] (const QString&) { GetChallenge (); };
			CallsQueue_ << [albumId, item, this] (const QString& challenge)
			{
				UploadOneImage (albumId, item, challenge);
			};
		}
	}
Example #2
0
	void FotoBilderAccount::CreateCollection (const QModelIndex&)
	{
		AlbumSettingsDialog dia ({}, Login_, this);
		if (dia.exec () != QDialog::Accepted)
			return;

		const auto& name = dia.GetName ();
		int priv = dia.GetPrivacyLevel ();

		auto guard = MakeRunnerGuard ();
		CallsQueue_ << [this] (const QString&) { GetChallenge (); };
		CallsQueue_ << [this, name, priv] (const QString& challenge)
		{
			CreateGallery (name, priv, challenge);
		};
	}
Example #3
0
void CTrackDlg::ReportStats(DWORD time)
{
	char response[33];

	NewGame(1);
	BucketStringOp(NULL, "hostname", bo_set, (char *)(LPCSTR)m_loginDlg.m_nick, bl_server, 0);
	BucketIntOp(NULL, "event", bo_set, m_event, bl_server, 0);

	NewPlayer(NULL, 0, (char *)(LPCSTR)m_loginDlg.m_nick);
	BucketIntOp(NULL, "time", bo_set, time, bl_player, 0);
	BucketIntOp(NULL, "pid", bo_set, m_loginDlg.m_profile, bl_player, 0);
	GenerateAuth(GetChallenge(NULL), (char *)(LPCSTR)m_loginDlg.m_password, response);
	BucketStringOp(NULL, "auth", bo_set, response, bl_player, 0);

	SendGameSnapShot(NULL, NULL, SNAP_FINAL);
	FreeGame(NULL);
}
Example #4
0
int test_main(int argc, char **argv)
{
	int result;
	int authcount;
	int callbackct;
	char validate[33], cdkey_hash[33];
	int player1pid;
	GSIACResult ac_result;

	playerdata_t playerdata;

	/*********
	First step, set our game authentication info
	We could do:
		strcpy(gcd_gamename,"gmtest");
		strcpy(gcd_secret_key,"HA6zkS");
	...but this is more secure:
	**********/
	gcd_gamename[0]='g';gcd_gamename[1]='m';gcd_gamename[2]='t';gcd_gamename[3]='e';
	gcd_gamename[4]='s';gcd_gamename[5]='t';gcd_gamename[6]='\0';
	gcd_secret_key[0]='H';gcd_secret_key[1]='A';gcd_secret_key[2]='6';gcd_secret_key[3]='z';
	gcd_secret_key[4]='k';gcd_secret_key[5]='S';gcd_secret_key[6]='\0';

	/*********
	Before initializing the connection,
	check that the backend is available.
	*********/
	GSIStartAvailableCheck(_T("gmtest"));
	while((ac_result = GSIAvailableCheckThink()) == GSIACWaiting)
		msleep(5);
	if(ac_result != GSIACAvailable)
	{
		printf("The backend is not available\n");
		return 1;
	}

	/*********
	Next, open the stats connection. This may block for
	a 1-2 seconds, so it should be done before the actual game starts.
	**********/
	result = InitStatsConnection(MY_GAMEPORT);

	if (result != GE_NOERROR)
	{
		printf("InitStatsConnection returned %d\n",result);		
		return 1;
	}

	/********
	Now, lets authenticate two players, one using the a Presence & Messaging
	SDK profileid, and the other using a CDKey SDK CD Key.
	The profile/password and CD Key/nick to use are defined at the top.

	Generally you will only use one method or the other, depending on your game.
	*********/
	/*************
	The first step to authenticate a player is to generate their Authentication token.

	If you are retrieving/setting persistent data on the server, you should first send
	the challenge to the client, have them send back the validation, and then proceed
	with the authentication. In this manner the client never has to send their password
	or CD Key to the server -- only the validation hash.
	If you are retrieving/setting persistent data on the client, it can all be done
	locally, as shown below.
	*************/

	/************
	First, we will authenticate a player using the CD Key system. We pass in the
	plaintext CD Key to GenerateAuth to get the validation token (validate).
	*************/
	GenerateAuth(GetChallenge(NULL),VALIDCDKEY,validate);
	
	/************
	Next, we need to get the hash of the CD Key to along with the validation.
	This can be done easily using GenerateAuth with an empty challenge string
	************/
	GenerateAuth("",VALIDCDKEY,cdkey_hash);

	/***********
	Now, we call PreAuthenticatePlayerCD with the hash and the validation token.
	We pass in a callback that will be called when the operation is complete, along
	with a integer that we will check to know its done.
	We pass in the localid as 1, since we will be authenticating two players before
	checking the return values. By using different localids we can tell them apart.
	************/
	authcount = 0;
	PreAuthenticatePlayerCD(1,KEYNICK,cdkey_hash,validate,PersAuthCallback,&authcount);

	/***********
	While the first authentication is in progress, we'll go ahead and start the second
	one, using a Presence & Messaging SDK profileid / password.
	To generate the new validation token, we'll need to pass in the password for the
	profile we are authenticating.
	Again, if this is done in a client/server setting, with the Persistent Storage
	access being done on the server, and the P&M SDK is used on the client, the
	server will need to send the challenge (GetChallenge(NULL)) to the client, the
	client will create the validation token using GenerateAuth, and send it
	back to the server for use in PreAuthenticatePlayerPM
	***********/
	GenerateAuth(GetChallenge(NULL),VALIDPROFILEPASSWORD,validate);

	/************
	After we get the validation token, we pass it and the profileid of the user
	we are authenticating into PreAuthenticatePlayerPM.
	We pass the same authentication callback as for the first user, but a different
	localid this time.
	************/
	PreAuthenticatePlayerPM(2,PROFILEID,validate,PersAuthCallback,&authcount);

	/***********
	Now that both authentication requests are sent, we need to wait for the results to
	come back. If we were in a game we could continue with the main game loop at this
	point, but since we're not, we'll just loop until we are disconnected or both
	authentications come back
	************/
	while (authcount < 2 && IsStatsConnected())
	{
		PersistThink();
		msleep(10);
	}

	/**********
	Both of the players have now been authenticated.
	When the CD Key player (player 1) was authenticated, the profileid for him
	was returned in the callback, but we didn't save it off. Since we'll need it
	to get/set data for him, lets go ahead and retrieve it using the GetProfileIDFromCD
	function
	**********/
	player1pid = 0;
	GetProfileIDFromCD(1,KEYNICK,cdkey_hash,ProfileCallback,&player1pid);

	/**********
	Again we'll wait until the call completes. We check if player1pid is still 0, since
	it gets set to the profileid in the callback (or -1 if a failure)
	***********/
	while (player1pid == 0 && IsStatsConnected())
	{
		PersistThink();
		msleep(10);
	}

	/**********
	Now we have everything we need to start getting / setting data for the two
	users. First we'll clear both user's public data, to make sure it's empty
	before we continue
	***********/
	callbackct = 0;
	SetPersistData(1,player1pid,pd_public_rw,0,"",0,PersDataSaveCallback,&callbackct);
	SetPersistData(2,PROFILEID,pd_public_rw,0,"",0,PersDataSaveCallback,&callbackct);
	
	/**********
	We'll use the callbackct var (passed in to the callbacks) as a way to easily determine
	when the calls are complete
	***********/
	while (callbackct < 2 && IsStatsConnected())
	{
		PersistThink();
		msleep(10);
	}

	
	/***********
	Lets read the data back, just to prove it's cleared
	************/
	callbackct = 0;
	GetPersistData(1,player1pid,pd_public_rw,0,PersDataCallback,&callbackct);
	GetPersistData(2,PROFILEID,pd_public_rw,0,PersDataCallback,&callbackct);
	while (callbackct < 2 && IsStatsConnected())
	{
		PersistThink();
		msleep(10);
	}

	/************
	Now lets set some REAL data!
	For player1 we will use ascii key\value pairs, for player2 we will store
	binary structures. Note that if you store binary structures, YOU are responsible
	for making sure things like byte order, structure size, and contents do not change
	between versions or platforms of your game that may access the same data
	************/
	callbackct = 0;
	playerdata.hitpoints = 600;
	playerdata.modelnumber = 5;
	playerdata.totaltime = 5000;
	strcpy(playerdata.skin,"darkstar");
	SetPersistData(1,player1pid,pd_public_rw,0,(char *)&playerdata,sizeof(playerdata_t),PersDataSaveCallback,&callbackct);
	SetPersistDataValues(2,PROFILEID,pd_public_rw,0,_T("\\key1\\value1\\key2\\value2\\key3\\value3"),PersDataSaveCallback,&callbackct);
	while (callbackct < 2 && IsStatsConnected())
	{
		PersistThink();
		msleep(10);
	}

	/***********
	Lets read the data back, to see what's there!
	We'll use a custom callback for player1 to print out the playerdata struct that's read back.
	************/
	callbackct = 0;
	GetPersistData(1,player1pid,pd_public_rw,0,PlayerDataCallback,&callbackct);
	GetPersistData(2,PROFILEID,pd_public_rw,0,PersDataCallback,&callbackct);
	while (callbackct < 2 && IsStatsConnected())
	{
		PersistThink();
		msleep(10);
	}

	/***********
	Now, lets manipulate player2's data a bit using the SetPersistDataValues functions.
	We'll also print it at each stage, so you can see the changes as they occur

	First, we'll update the values of key1 and key3 (but not key2) and add keys 4 and 5.
	Your keys don't have to be numbered like this, this is just an example
	************/
	callbackct = 0;
	SetPersistDataValues(2,PROFILEID,pd_public_rw,0,_T("\\key1\\valueA\\key3\\valueB\\key4\\value400\\key5\\value500"),
		PersDataSaveCallback,&callbackct);
	GetPersistData(2,PROFILEID,pd_public_rw,0,PersDataCallback,&callbackct);

	/***********
	Now we'll clear key 2, and update keys 3 and 4, and add two other keys
	************/
	SetPersistDataValues(2,PROFILEID,pd_public_rw,0,_T("\\key2\\\\key3\\valueC\\key4\\value401\\mykeyname\\mykeyvalue\\otherkey\\othervalue"),
		PersDataSaveCallback,&callbackct);
	GetPersistData(2,PROFILEID,pd_public_rw,0,PersDataCallback,&callbackct);

	/***********
	Finally, lets see how we can use GetPersistDataValues to only return a subset
	of the keys that are stored. For example, we will only return keys 1,2,3,and 4
	The order you list them in does not matter
	************/
	GetPersistDataValues(2,PROFILEID,pd_public_rw,0,_T("\\key3\\key2\\key4\\key1"),PersDataCallback,&callbackct);

	/***********
	We've now sent off 5 requests without actually checking the results. The results are already coming in,
	we just need to think a while to get them all
	************/
	while (callbackct < 5 && IsStatsConnected())
	{
		PersistThink();
		msleep(100);
	}
	
	/**********
	When we're done we'll close off the connection
	***********/	
	CloseStatsConnection();

	GSI_UNUSED(argc);
	GSI_UNUSED(argv);

	return 0;
}
void CMasterTestDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	// Do something
	clock_t tCurTime;
	float fElapsed;
	static int nLastSend, nLastRecv;

	if (nIDEvent == TEST_TIMER)
	{
		tCurTime = clock();
		fElapsed = (float)(tCurTime - m_tStartTime)/CLOCKS_PER_SEC;
		if (fElapsed >= 1.0f/fRate && !m_bTestStopped)
		{
			UpdateData( TRUE );

			for (int i = 0; i < m_nMasterSockets; i++)
			{
				if (g_nTestType == 0)
				{
					if (!RequestServerList(m_pMasterSockets[i]))
					{
						delete m_pMasterSockets[i];
						m_pMasterSockets[i] = NULL;
					}
				}
				else if (g_nTestType == 1)
				{
					if (!GetChallenge(m_pMasterSockets[i]))
					{
						delete m_pMasterSockets[i];
						m_pMasterSockets[i] = NULL;
					}
				}
			}
			m_tStartTime = clock();
		}

		// Update Send/Receive
		char szStatus[64];
		if (m_nDataSent != nLastSend)
		{
			sprintf(szStatus, "%i / %i", m_nRequestsSent, m_nDataSent);
			nLastSend = m_nDataSent;
			if (m_statSent.GetSafeHwnd())
				m_statSent.SetWindowText(szStatus);
		}
		if (m_nDataReceived != nLastRecv)
		{
			sprintf(szStatus, "%i / %i", m_nResponsesReceived, m_nDataReceived);
			nLastRecv = m_nDataReceived;
			if (m_statRecv.GetSafeHwnd())
				m_statRecv.SetWindowText(szStatus);
		}

		fElapsed = (float)(tCurTime - m_tTestStartTime)/CLOCKS_PER_SEC;		
		sprintf(szStatus, "%.1f", m_fTestTime - fElapsed);
		if (fElapsed <= m_fTestTime)
		{
			if (m_statTimeLeft.GetSafeHwnd())
				m_statTimeLeft.SetWindowText(szStatus);
		}
		else
		{
			// Shut it down.
			float fDataTimeOut;
			fDataTimeOut = (float)(tCurTime - m_tLastDataReceived)/CLOCKS_PER_SEC;
			if (fDataTimeOut < 30.0f)
			{
				OnStoptest();
			}
			else
			{
				OnStop();
			}
		}
	}
	CDialog::OnTimer(nIDEvent);
}
Example #6
0
	void FotoBilderAccount::RequestPictures ()
	{
		auto guard = MakeRunnerGuard ();
		CallsQueue_ << [this] (const QString&) { GetChallenge (); };
		CallsQueue_ << [this] (const QString& challenge) { GetPicsRequest (challenge); };
	}