예제 #1
0
void
RegisterCommand::requestToken()
{
	kDebug( 14100 ) << "requestToken Initialisation";
	state = RegisterStateWaitingForToken;

	if ( !( session_ = gg_token( 1 ) ) ) {
		emit error( i18n( "Gadu-Gadu" ), i18n( "Unable to retrieve token." ) );
		state = RegisterStateNoToken;
		return;
	}

	connect( this, SIGNAL(socketReady()), SLOT(watcher()) );
	checkSocket( session_->fd, session_->check );

	return;
}
예제 #2
0
////////////////////////////////////////////////////////////////////////////////
// Gets GG token
int gg_gettoken(GGPROTO *gg, GGTOKEN *token)
{
	struct gg_http *h = NULL;
	struct gg_token *t = NULL;
	IMGSRVC_MEMIO memio = {0};
	GGTOKENDLGDATA dat = {0};

	// Zero tokens
	strcpy(token->id, "");
	strcpy(token->val, "");

	if(!(h = gg_token(0)) || gg_token_watch_fd(h) || h->state == GG_STATE_ERROR || h->state != GG_STATE_DONE)
	{
		char error[128];
		mir_snprintf(error, sizeof(error), Translate("Token retrieval failed because of error:\n\t%s"), http_error_string(h ? h->error : 0));
		MessageBox(
				NULL,
				error,
				GG_PROTONAME,
				MB_OK | MB_ICONSTOP
		);
		gg_free_pubdir(h);
		return FALSE;
	}

	if (!(t = (struct gg_token *)h->data) || (!h->body))
	{
		char error[128];
		mir_snprintf(error, sizeof(error), Translate("Token retrieval failed because of error:\n\t%s"), http_error_string(h ? h->error : 0));
		MessageBox(
				NULL,
				error,
				GG_PROTONAME,
				MB_OK | MB_ICONSTOP
		);
		gg_free_pubdir(h);
		return FALSE;
	}

	// Return token id
	strncpy(dat.id, t->tokenid, sizeof(dat.id));
	dat.width = t->width;
	dat.height = t->height;

	// Load bitmap
	memio.iLen = h->body_size;
	memio.pBuf = (void *)h->body;
	memio.fif = -1; /* detect */
	memio.flags = 0;
	dat.hBitmap = (HBITMAP) CallService(MS_IMG_LOADFROMMEM, (WPARAM) &memio, 0);
	if(dat.hBitmap == NULL)
	{
		MessageBox(
				NULL,
				Translate("Could not load token image."),
				GG_PROTONAME,
				MB_OK | MB_ICONSTOP
		);
		gg_free_pubdir(h);
		return FALSE;
	}

	// Load token dialog
	if(DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_TOKEN), NULL, gg_tokendlgproc, (LPARAM)&dat) == IDCANCEL)
		return FALSE;

	// Fillup patterns
	strncpy(token->id, dat.id, sizeof(token->id));
	strncpy(token->val, dat.val, sizeof(token->val));

	return TRUE;
}