Ejemplo n.º 1
0
void AlbumInfoWidget::openWnd(const QStringList &businesses)
{
    AlbumTaskWidget *task = m_container->getCurrTask();
    if (!task)
    {
        return;
    }

    if (isHidden())
    {
        show();
    }

    int index = 0;
    uchar atype;
    QString business;

    task->getRelevance(atype, business);

    ui->comboBox->clear();
    ui->comboBox->addItems(businesses);

    foreach (const QString &name, businesses)
    {
        if (business == name)
        {
            ui->comboBox->setCurrentIndex(index);
            break;
        }

        index++;
    }

    // 根据当前相册的类型来决定是否显示用户信息列表
    if (USER_ALBUM == atype)
    {
        ui->userRadioButton->setChecked(true);
        ui->usersListWidgets1->clear();
        showUsers();

        UserInfoItems items = task->getUsers();
        UserInfoItems::const_iterator iter = items.constBegin();
        while (iter != items.constEnd())
        {
            UserInfoWidget *widget = new UserInfoWidget(ui->usersListWidgets1->count(), iter.key(), iter.value(), *this);
            QListWidgetItem *item = new QListWidgetItem(ui->usersListWidgets1);
            item->setSizeHint(widget->sizeHint());
            ui->usersListWidgets1->setItemWidget(item, widget);
            ++iter;
        }
    }
    else
    {
        ui->sampleRadioButton->setChecked(true);
        showUsers(false);
    }

    ui->telnoLineEdit->clear();
}
/**
* scrollUp function
* Scroll the shown conten up on the basis of an int
* @param[in] i is the int for how much will be scrolled
*/
void SearchPageArea::scrollUp(int i) {
    selectContent("none");
    int size;
    if (currentcontisuser)
    {
        size = content.Size();
    }
    else {
        size = content["statuses"].Size();
    }
    if (index + 4 + i <size)
    {
        index += i;
    }
    else {
        index = size - 4;
    }
    if (currentcontisuser)
    {

        showUsers();
    }
    else {

        showTweets();
    }
}
/**
* Show function
* lets the instance show up in the interface, also registers the necessary buttons listeners
*/
void SearchPageArea::show() {
    if (!active)
    {

        Element::show();
        for (int i = 0; i <4; i++)
        {
            textFrames[i] = eyegui::addFloatingFrameWithBrick(pLayout, "bricks/SearchPageArea/floatingTweetBlock" + std::to_string(i + 1) + ".beyegui", 0.175f, 0.41f + 0.14125f*i, 0.65f, 0.1325f);
            buttonFrames[i] = eyegui::addFloatingFrameWithBrick(pLayout, "bricks/SearchPageArea/floatingButton" + std::to_string(i + 1) + ".beyegui", 0.175f, 0.41f + 0.14125f*i, 0.65f, 0.1325f);
            eyegui::registerButtonListener(pLayout, std::to_string(i), searchButtonListener);
        }
        textFrames[4] = eyegui::addFloatingFrameWithBrick(pLayout, "bricks/SearchPageArea/searchText.beyegui", 0.175f, 0.2875f, 0.65f, 0.11f);
        buttonFrames[4] = eyegui::addFloatingFrameWithBrick(pLayout, "bricks/SearchPageArea/searchButton.beyegui", 0.175f , 0.2875f , 0.65f, 0.11f);
        buttonFrames[5] = eyegui::addFloatingFrameWithBrick(pLayout, "bricks/SearchPageArea/tweetSearchButton.beyegui", 0.0f, 0.26f, 0.125f, 0.101f);
        buttonFrames[6] = eyegui::addFloatingFrameWithBrick(pLayout, "bricks/SearchPageArea/profileSearchButton.beyegui", 0.0f, 0.39f, 0.125f, 0.101f);
        eyegui::registerButtonListener(pLayout, "searchKeyboard", searchButtonListener);
        eyegui::registerButtonListener(pLayout, "tweetSearchButton", searchButtonListener);
        eyegui::registerButtonListener(pLayout, "profileSearchButton", searchButtonListener);
        eyegui::setContentOfTextBlock(pLayout, textboxes[0], searchWord);
        manageSearchButtons();
    }
    if (contentExists)
    {
        if (currentcontisuser)
        {
            showUsers();
        }
        else {
            showTweets();
        }
    }
}
Ejemplo n.º 4
0
void MsgEdit::forwardClick()
{
    if (msg == NULL) return;
    QString msgText;
    if (msg && msg->Received()){
        switch (msg->Type()){
        case ICQ_MSGxMSG:
            msgText = QString::fromLocal8Bit(static_cast<ICQMsg*>(msg)->Message.c_str());
            break;
        case ICQ_MSGxURL:
            msgText = QString::fromLocal8Bit(static_cast<ICQUrl*>(msg)->Message.c_str());
            break;
        }
    }else{
        if (view->hasSelectedText()){
            msgText = view->selectedText();
        }else{
            msgText = view->text();
        }
    }
    msgText = QString::fromLocal8Bit(pClient->clearHTML(msgText.local8Bit()).c_str());
    QStringList l = QStringList::split('\n', msgText);
    CUser u(msg->getUin());
    msgText = i18n("%1 (ICQ# %2) wrote:<br>\n")
              .arg(u.name(true)) .arg(msg->getUin());
    msgText += l.join("<br>\n");
    msgText += "\n";
    ICQMessage *newMsg = NULL;
    switch (msg->Type()){
    case ICQ_MSGxURL:{
            ICQUrl *nMsg = new ICQUrl;
            nMsg->Uin.push_back(Uin);
            nMsg->Message = msgText.local8Bit();
            nMsg->URL = static_cast<ICQUrl*>(msg)->URL;
            newMsg = nMsg;
            break;
        }
    case ICQ_MSGxCONTACTxLIST:{
            ICQContacts *nMsg = new ICQContacts;
            nMsg->Uin.push_back(Uin);
            nMsg->Contacts = static_cast<ICQContacts*>(msg)->Contacts;
            newMsg = nMsg;
            break;
        }
    default:
        ICQMsg *nMsg = new ICQMsg;
        nMsg->Uin.push_back(Uin);
        nMsg->Message = msgText.local8Bit();
        newMsg = nMsg;
    }
    setMessage(newMsg);
    edit->moveCursor(QTextEdit::MoveEnd, false);
    bMultiply = true;
    btnMultiply->setPixmap(Pict("1leftarrow"));
    emit showUsers(true, 0);
    textChanged();
}
Ejemplo n.º 5
0
void AlbumInfoWidget::openWnd()
{
    AlbumTaskWidget *task = m_container->getCurrTask();
    if (!task)
    {
        return;
    }

    if (isHidden())
    {
        show();
    }

    ui->nameLabel->setText(task->getName());
    ui->numLabel->setText(tr("本相册共 %1 页,入册照片 %2 张,剩余空位 %3 个。").arg(task->getPagesNum()).arg(task->getPhotosNum()).arg(task->getBlankNum()));

    uchar atype;
    QString business;

    task->getRelevance(atype, business);
    ui->typeLabel->setText(tr("相册类型:%1").arg(USER_ALBUM == atype ? tr("这是一本为用户制作的相册") : tr("这是一本影楼自己的样册")));
    ui->businessLabel->setText(tr("相关影楼:%1").arg(business));

    if (USER_ALBUM == atype)
    {
        showUsers();
        ui->usersListWidgets2->clear();
        //qDebug() << __FILE__ << __LINE__ << task << users;

        UserInfoItems items = task->getUsers();
        UserInfoItems::const_iterator iter = items.constBegin();
        while (iter != items.constEnd())
        {
            QListWidgetItem *item = new QListWidgetItem(iter.value(), ui->usersListWidgets2);
            item->setSizeHint(QSize(0, 41));
            ++iter;
        }
    }
    else
    {
        showUsers(false);
    }
}
Ejemplo n.º 6
0
void PluginView::onItemActivated(const QModelIndex &index) {
    QVariantMap type = index.data(PluginNavModel::ValueRole).toMap();

    if (type.isEmpty()) {
        showSearchDialog();
    }
    else if (type.value("type") == Resources::CATEGORY) {
        showCategories(index.data(PluginNavModel::NameRole).toString(), type.value("id").toString());
    }
    else if (type.value("type") == Resources::PLAYLIST) {
        showPlaylists(index.data(PluginNavModel::NameRole).toString(), type.value("id").toString());
    }
    else if (type.value("type") == Resources::USER) {
        showUsers(index.data(PluginNavModel::NameRole).toString(), type.value("id").toString());
    }
    else {
        showVideos(index.data(PluginNavModel::NameRole).toString(), type.value("id").toString());
    }
}
/**
* scrollDown function
* Scroll the shown conten down on the basis of an int
* @param[in] i is the int for how much will be scrolled
*/
void SearchPageArea::scrollDown(int i) {
    selectContent("none");
    if (index - i >0)
    {
        index -= i;
    }
    else {
        index = 0;
    }
    if (currentcontisuser)
    {

        showUsers();
    }
    else {

        showTweets();
    }
}
/**
* search function
* functions searches after content in twitter with a searchWord
*/
void SearchPageArea::search() {
    selectContent("none");
    index = 0;
    if (searchWord=="") return;
    if (TwitterApp::getInstance()->hasConnection()) {
        if (userSearch)
        {
            content = TwitterApp::getInstance()->getTwitter()->userSearch(searchWord, "80");
            contentExists = true;
            currentcontisuser = true;
            showUsers();
        }
        else {
            content = TwitterApp::getInstance()->getTwitter()->search(searchWord, "80");
            contentExists = true;
            currentcontisuser = false;
            showTweets();
        }
    }
}
Ejemplo n.º 9
0
void *thread_func(void *new_socket_ref)
{

  int new_socket = *(int*)new_socket_ref;
  //int* index = (int *) param;

     do{
       //printf("--------------\nHebra %i\n",*index);
	result = recv(new_socket,buffer,80,0);

	if(result==-1){
	  perror("Servidor:Recv");
	  exit(1);
	}
	/*	if(strcmp(buffer,"EOT")==0){  
	  printf("Se ha recibido EOT\n");
	  EOT=1;
	}else if(strcmp(buffer,"EOT")!=0){  
	printf("El mensaje recibido fue:\n%s\n",buffer);*/
	printf("%s\n",buffer);
	  split_request(buffer,&req);
	  
	  switch(req.req_type){
	  case GET_STATE:
	    printf("GET_STATE %s\n",req.req[0]);
	    //printf("Buscamos usuario...\n");
	    user_ptr = getUser(req.req[0],user_list);
	    if(user_ptr!=NULL){

	      sprintf(buffer,"%i %s %i",
		      STATE,user_ptr->name,user_ptr->state);
	      //printf("Encontrado\n Respuesta a enviar: %s\n",buffer);
	    }else{
	      printf("El usuario no existe\n");
	      sprintf(buffer,"%i",ERROR);
	    }
	    if(send(new_socket,buffer,80,0)==-1){
	      printf("Servidor:Send\n");
	      exit(1);
	    }
	    break;
	  case POST_NAME_LOCATION_STATE:
	    printf("POST_NAME_LOCATION_STATE %s %s %i\n",
		   req.req[0],req.req[1],atoi(req.req[2]));
	    
	    strcpy(user.name,req.req[0]);
	    strcpy(user.location,req.req[1]);
	    user.state = atoi(req.req[2]); 
	    user_list = addUser(&user,user_list);
	    showUsers(user_list);
	    sprintf(buffer,"%i",OK);	    
	    if(send(new_socket,buffer,80,0)==-1){
	      printf("Servidor:Send\n");
	      exit(1);
	    }
	    
	    break;
	  case AUTH:
	    printf("AUTH %s\n",req.req[0]);
	    //Comprobamos si existe el usuario
	    user_ptr = getUser(req.req[0],user_list);
	    if(user_ptr!=NULL){//Si Existe mandamos reto
	      challenge = random();
	      sprintf(buffer,"%i %i",CHALLENGE,challenge);
	      printf("Enviado reto: %s\n",buffer);
	      if(send(new_socket,buffer,80,0)==-1){
		printf("Servidor:Send\n");
		exit(1);
	      }
	      result = recv(new_socket,buffer,80,0);

	      if(result==-1){
		perror("Servidor:Recv");
		exit(1);
	      }
	      split_request(buffer,&req);
	      //printf("Recibimos %s\n",buffer);
	      strcpy(location,req.req[1]);
	      state = atoi(req.req[2]);
	      //Esperamos md5 name:reto:secreto
	      result = recv(new_socket,out,16,0);
	      for (i=0; i<16; i++) {
		printf("%02x", out[i]);
	      }
	      printf("\n");
	      //Comparamos md5 recibido con nuestro md5
	      sprintf(buffer,"%s%i%s",user_ptr->name,challenge,user_ptr->secret);
	      printf("OUR MD5 %s : ",buffer);
	      getMD5(buffer,strlen(buffer),md5);
	      for (i=0; i<16; i++) {
		printf("%02x", md5[i]);
	      }
	      printf("\n");
	      if(memcmp(md5,out,16)==0){
		printf("MATCH MD5\n");
		strcpy(user_ptr->location,location);
		user_ptr->state = state;
		sprintf(buffer,"%i",OK);
		if(send(new_socket,buffer,80,0)==-1){
		  printf("Servidor:Send\n");
		  exit(1);
		}	
	      }else{
		printf("MD5 incorrecto.\n");
		sprintf(buffer,"%i",ERROR);
		if(send(new_socket,buffer,80,0)==-1){
		  printf("Servidor:Send\n");
		  exit(1);
		}	
		
	      }
	      
	    }else{//Si no existe mandamos error
	      printf("No existe el usuario.\n");
	      sprintf(buffer,"%i",ERROR);
	      if(send(new_socket,buffer,80,0)==-1){
		printf("Servidor:Send\n");
		exit(1);
	      }
	    }


	    break;
	  case GET_LOCATION:
	    printf("GET_LOCATION %s\n",req.req[0]);
	    user_ptr = getUser(req.req[0],user_list);
	    if(user_ptr!=NULL){
	      sprintf(buffer,"%i %s %s",
		      LOCATION,user_ptr->name,user_ptr->location);
	    }else{
	      sprintf(buffer,"%i",ERROR);
	    }
	    if(send(new_socket,buffer,80,0)==-1){
	      printf("Servidor:Send\n");
	      exit(1);
	    }
	    break;
	  case EXIT:
            printf("EXIT\n");
	    printf("Fin de la conexion\n");
	    EOT=1;
	  }
	  freeRequest(&req);
	  //}
	  //printf("-----\n");
      }while(!EOT);

 
// the function must return something - NULL will do 
  return NULL;

}
Ejemplo n.º 10
0
int main()
{
  int new_socket;

user_list = NULL;
 EOT = 0;

     user_t user1 = {1,"asce","123.4.5.6","asce_secret"};
     user_list = addUser(&user1,user_list);
     //user_ptr = getUser("asce",user_list);

     user_t user2 = {1,"pepe","123.7.8.9","pepe_secret"};
     user_list = addUser(&user2,user_list);
     //user_ptr = getUser("pepe",user_list);

     user_t user3 = {1,"juan","123.10.11.12","juan_secret"};
     user_list = addUser(&user3,user_list);
     //user_ptr = getUser("juan",user_list);


     showUsers(user_list);
     //getchar();

     if((sd=socket(AF_INET,SOCK_STREAM,0))==-1){
       perror("Servidor:Socket");
       exit(1);
     }
      sockname.sin_family=AF_INET;
      sockname.sin_addr.s_addr=INADDR_ANY;
      sockname.sin_port=htons(5001);
                       /*     ^^^^   Sustituir por el puerto correspondiente */
      if(bind(sd,(struct sockaddr*) &sockname,sizeof(sockname))==-1){
	perror("Servidor:Bind");
	exit(1);
      }
      if(listen(sd,1)==-1){
	perror("Servidor1:Listen");
	exit(1);
      }
      from_len=sizeof(from);

      for(ci = 0;ci < MAX_NUM_CLIENTS;ci++){

	
	//Se bloquea esperando peticion de client
	if((new_socket=accept(sd,(struct sockaddr*) &from,&from_len))==-1){
	  perror("Servidor:Accept");
	  exit(1);
	}

	if(pthread_create(&threads[ci], NULL, thread_func, &new_socket)) {

	  fprintf(stderr, "Error creating thread\n");
	  return 1;

	}
	/*
      if ( (pid = fork()) == 0 ) {
	close(sd); // child closes listening socket 

      }//Fin codigo hijo
      */
      }//Fin Server for
}
Ejemplo n.º 11
0
int main(int argc, char *argv[]) {
	WORD wVersionRequested = MAKEWORD(2, 2);       // Stuff for WSA functions
	WSADATA wsaData;
   int sock, portno, n=0;
   int aut;
   struct sockaddr_in serv_addr;
   struct hostent *server;
   char quit[]="quit";
   char show[]="show users";
   char wallet[]="check wallet";
   char transf[]="transfer";
   char buffer[bufSize+1];
   char buf[bufSize];

   WSAStartup(wVersionRequested, &wsaData);
   //portno=12345;
   if (argc < 3) {
      fprintf(stderr,"usage %s hostname port\n", argv[0]);
      exit(0);
   }

   portno = atoi(argv[2]);

   /* Create a socket point */
   sock = socket(AF_INET, SOCK_DGRAM, 0);

   if (sock == SOCKET_ERROR) {
      perror("ERROR opening socket");
      exit(1);
   }

   server = gethostbyname(argv[1]);
   if (server == NULL) {
      fprintf(stderr,"ERROR, no such host\n");
      exit(0);
   }

   memset((char *) &serv_addr, 0, sizeof(serv_addr));
   serv_addr.sin_family = AF_INET;
   serv_addr.sin_addr.s_addr = inet_addr(argv[1]);
   //strncpy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length);
   serv_addr.sin_port = htons(portno);
   int len = sizeof(serv_addr);


	n = sendto(sock, "client", strlen("client"), 0, (struct sockaddr *) &serv_addr, len);
	if (n < 0) {
        perror("ERROR writing to socket");
        closesocket(sock);
        exit(1);
    }

	//recieve new port
	memset(buf, 0, bufSize);
	n = recvfrom(sock, buf, bufSize, 0, (struct sockaddr *) &serv_addr, &len);
	if (n < 0) {
      perror("ERROR reading from socket");
      closesocket(sock);
      exit(1);
    } 
	disconnect(sock, buf);
	//close old socket
	closesocket(sock);
	WSACleanup();

	int newport = atoi(buf);

	WSADATA wsa2;
	if (WSAStartup(MAKEWORD(2, 2), &wsa2) != 0) {
		exit(EXIT_FAILURE);
	}

	struct sockaddr_in new_addr;
	int sockfd, new_slen = sizeof(new_addr);

	//create socket
	if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == SOCKET_ERROR) {
		exit(EXIT_FAILURE);
	}

	//setup address structure
	memset((char *)&new_addr, 0, new_slen);
	new_addr.sin_family = AF_INET;
	new_addr.sin_port = htons(newport);
	new_addr.sin_addr.S_un.S_addr = inet_addr(argv[1]);
	
	n = sendto(sockfd, "newclient", strlen("newclient"), 0, (struct sockaddr *) &new_addr, new_slen);
	if (n < 0) {
      perror("ERROR reading from socket");
      closesocket(sockfd);
      exit(1);
    } 

	Uclient client;
	client.sockfd = sockfd;
	client.serv_addr = new_addr;
	client.clilen = sizeof(new_addr);

   do {
           aut = authentication(client); //процесс аутентификации клиента
       } while (aut < 0);
   while (1){
    printf("Enter the command: ");
    memset(buffer, 0, bufSize+1);
    fgets(buffer,bufSize+1,stdin);

    if(strncmp(buffer,quit,sizeof(quit)-1) == 0){
            n = sendto(client.sockfd, buffer, strlen(buffer),0, (struct sockaddr*)&client.serv_addr, client.clilen);
            if (n < 0) {
                perror("ERROR writing to socket");
                exit(1);
            }
            closesocket(client.sockfd);
            break;
    }
    else if(strncmp(buffer,show,sizeof(show)-1) == 0){
        showUsers(buffer, client);
    }
    else if(strncmp(buffer, wallet,sizeof(wallet)-1) == 0){
        checkWallet(client);
    }
    else if(strncmp(buffer, transf,sizeof(transf)-1) == 0){
        transfer(client);
    }
    else{
        printf("Undefined command\n");
    }
  }
    return 0;
}
Ejemplo n.º 12
0
int main(int argc, char **argv){
 
  List list = LLCreate();
  Stack stack = SCreate();
  Queue queue = QCreate();
  User *usr;

  setupUsers();
  MENU_CHOICE m_choice = MAIN_MENU;
  int choice, count;
  menu();

  choice = getChoice();
  
  while(choice){
    switch(m_choice){
    case MAIN_MENU:
      switch(choice){
      case 1:
	m_choice = LL_MENU; 
	llmenu();
	break;
      case 2:
	m_choice = QUEUE_MENU;
	qmenu();
	break;
      case 3:
	m_choice = STACK_MENU;
	smenu();
	break;
      case 4:
	showUsers();
        menu();
	break;
      case 0:
	exit(0);
	break;
      default:
	m_choice = MAIN_MENU;
	menu();
      }
      break;
    case LL_MENU:
      switch(choice){
      case 1:
	printf("\n%s\n", "adding head, choose a user");
        usr = chooseUser();
        printf("%s %s\n", "You chose ", usr -> name);
        LLAddHead(usr, list);
        llmenu();
	break;
      case 2:
	printf("\n%s\n", "adding tail, choose a user");
        usr = chooseUser();
        printf("%s %s\n", "You chose", usr -> name);
        LLAddTail(usr, list);
        llmenu();
	break;
      case 3:
	printf("\n%s\n", "removing head");
        LLRemoveHead(list);
        llmenu();
	break;
      case 4:
	printf("\n%s\n", "removing tail");
        LLRemoveTail(list);
        llmenu();
	break;
      case 5:
        print(list);
        llmenu();
	break;
      case 6:
        m_choice = MAIN_MENU;
	menu();
	break;
      case 0:
	exit(0);
	break;
      default:
	m_choice = LL_MENU;
      }
      break;
    case QUEUE_MENU:
      switch(choice){
      case 1:
        printf("\n%s\n", "enqueueing, choose a user");
        usr = chooseUser();
        printf("%s %s\n", "You chose ", usr -> name);
        Qenqueue(usr, queue);
        qmenu();
	break;
      case 2:
	printf("\n%s\n", "dequeueing");
        Qdequeue(queue);
        qmenu();
	break;
      case 3:
	print(queue);
        qmenu();
	break;
      case 4:
        m_choice = MAIN_MENU;
	menu();
	break;
      case 0:
	exit(0);
	break;
      default:
	m_choice = QUEUE_MENU;
      }
      break;
    case STACK_MENU:
      switch(choice){
      case 1:
	printf("%s\n", "push");
        smenu();
	break;
      case 2:
	printf("%s\n", "pop");
        smenu();
	break;
      case 3:
	printf("%s\n", "top");
        smenu();
	break;
      case 4:
	printf("%s\n", "print");
        smenu();
	break;
      case 5:
        m_choice = MAIN_MENU;
	menu();
	break;
      case 0:
	exit(0);
	break;
      default:
	m_choice = STACK_MENU;
      }
      break;
    } 
    choice = getChoice();
  }

  return 0;   
}
Ejemplo n.º 13
0
User *chooseUser(){
  int unumber;
  showUsers();
  unumber = getChoice();
  return &users[(unumber - 1)];
}
Ejemplo n.º 14
0
void MsgEdit::toggleMultiply()
{
    bMultiply = !bMultiply;
    btnMultiply->setPixmap(Pict(bMultiply ? "1leftarrow" : "1rightarrow"));
    emit showUsers(bMultiply, Uin);
}