void TwitterPostsDatabase::addTwitterPost(const QString &identifier, const QString &name,
                                          const QString &body, const QDateTime &timestamp,
                                          const QString &icon,
                                          const QList<QPair<QString, SocialPostImage::ImageType> > &images,
                                          const QString &screenName, const QString &retweeter,
                                          const QString &consumerKey, const QString &consumerSecret,
                                          int account)
{
    QVariantMap extra;
    extra.insert(SCREEN_NAME_KEY, screenName);
    extra.insert(RETWEETER_KEY, retweeter);
    extra.insert(CONSUMER_KEY_KEY, consumerKey);
    extra.insert(CONSUMER_SECRET_KEY, consumerSecret);
    addPost(identifier, name, body, timestamp, icon, images, extra, account);
}
Ejemplo n.º 2
0
int main() {
	SetColorAndBackground(0xFFF,0);
	Postagens posts[100];
	Autor autores[100];
	char categorias[100][100];
	Numeros numeros;
	int opcao;
	addPrePosts(autores,categorias,&numeros);
	while(true) {
		opcao=0;
		system("cls");
		printf("Blog dojão\n");
		printf("1 - Adicionar Postagem\n");
		printf("2 - Visualizar Postagens\n");
		printf("3 - Adicionar Categoria\n");
		printf("4 - Adicionar Autor\n");
		printf("5 - Deletar Categoria\n");
		printf("6 - Deletar Autor\n");
		printf("7 - Deletar Postagem\n");
		
		printf("\n\n\nEscolha um menu:");
		scanf("%d",&opcao);
		switch (opcao) {
			case 1:
				addPost(posts,autores,categorias,&numeros);
				break;
			case 2:
				showPosts(posts,autores,categorias,&numeros);
				break;
			case 3:
				addCategory(categorias,&numeros);
				break;
			case 4:
				addAuthor(autores,&numeros);
				break;
			case 5:
				deleteCategory(categorias,&numeros);
				break;
			case 6:
				deleteAuthor(autores,&numeros);
				break;
			case 7:
				deletePost(posts,&numeros);
				break;
		}
	}
}
void FacebookPostsDatabase::addFacebookPost(const QString &identifier, const QString &name,
                                            const QString &body, const QDateTime &timestamp,
                                            const QString &icon,
                                            const QList<QPair<QString, SocialPostImage::ImageType> > &images,
                                            const QString &attachmentName,
                                            const QString &attachmentCaption,
                                            const QString &attachmentDescription,
                                            bool allowLike, bool allowComment,
                                            const QString &clientId, int account)
{
    QVariantMap extra;
    extra.insert(ATTACHMENT_NAME_KEY, attachmentName);
    extra.insert(ATTACHMENT_CAPTION_KEY, attachmentCaption);
    extra.insert(ATTACHMENT_DESCRIPTION_KEY, attachmentDescription);
    extra.insert(ALLOW_LIKE_KEY, allowLike);
    extra.insert(ALLOW_COMMENT_KEY, allowComment);
    extra.insert(CLIENT_ID_KEY, clientId);

    addPost(identifier, name, body, timestamp, icon, images, extra, account);
}
Ejemplo n.º 4
0
/**
   process http requests coming in
*/
void
RpcHttpTransport::processRequest()
{
    while ( true ) // ( status() == keRpcStarted )
    {
        // Accept a connection
        //    (this will block until client initiates request).
        RefCountedPtr<Socket> newSock( _listener.accept() );

        // if the process is stopped or shutting down
        if ( newSock == NULL )
        {
            if ( status() == keRpcStopPending )
            {
                // a hard close was performed on the listener socket
                // this is the signal for this thread to exit
                break;
            }
            else
            {
                // some other type of socket error, but not a hard close
                // in this case, we will just attempt to re-listen
                // probably the client connected and then immediately disconnected
                continue;
            }
        }

        CBLOGDBG(_logger, NTEXT("RpcHttpTransport::processRequest: received socket connection...") );

        RefCountedPtr<HttpSerPost> post(new HttpSerPost(newSock));
        RefCountedPtr<HttpContent> content(new HttpContent);
        if (	post->readRequest( *content ) &&
                ( content->getHttpMsgType() == HttpContent::HTTP_MSG_TYPE_REQUEST ) )
        {
            int errCode = HttpUtils::keCodeBadRequest;
            String payload;

            if ( content->getIsForm() )
            {
                payload = content->getQueryString( Rpc::PAYLOAD );
            }
            else
            {
                payload = content->getRequestBody();
            }

            // Now process the payload if it is not empty
            if ( !payload.empty() )
            {
                CBLOGDBG(_logger, NTEXT("RpcHttpTransport::processRequest: receiving request - ") + payload );

                // store post in pending list
                unsigned long sessionId = _sSessionId++;
                PendingPostReference postRef(post, content);
                addPost( sessionId, postRef );

//BUGBUG                handleContent( sessionId, content );
                _masterServer->queueMessage( sessionId, content->getHeaders(), payload, RPC_HTTP_NAME );

                errCode = HttpUtils::keCodeOk;
            }

            if ( errCode != HttpUtils::keCodeOk )
            {
                if ( !payload.empty() )
                {
                    CBLOGERR(_logger, NTEXT("HttpTransport::processRequest - Unable to Parse XML Data: ") + payload);
                }
                else
                {
                    CBLOGERR(_logger, NTEXT("HttpTransport::processRequest - Unable to Parse XML Data"));
                }

                /** Send an http reply in case of exception, back to client
                 **/
                if ( post != NULL )
                {
                    HttpContent errContent;
                    errContent.setHttpMsgType( HttpContent::HTTP_MSG_TYPE_RESPONSE );
                    errContent.setErrorCode( errCode );
                    post->sendResponse( errContent );
                }
            } // if ( errCode != HttpUtils::keCodeOk )
        }
        else
        {
            CBLOGERR(_logger, NTEXT("HttpTransport::processRequest - Unable to read request from client"));
        }
    }
}