Пример #1
0
EXPORT void libqq_getbuddyname( qqclient* qq, uint uid, char* buf )
{
	qqbuddy* b = buddy_get( qq, uid, 0 );
	if( b ){
		strncpy( buf, b->nickname, 15 );
	}else{
		if( uid != 0 ){
			sprintf( buf, "%u" , uid );
		}
	}
}
Пример #2
0
/*
   static void signed_on(PurpleConnection *gc, gpointer null)
   {
   taim_session *pses;
//GSList *bs;
//PurpleBuddy *btry;
PurpleAccount *account = purple_connection_get_account(gc);
purple_blist_add_account(account);
purple_blist_show();

// The hash is only added here
pses = uid_find_account(account);

if(pses)
{
pses->pses->account->hash_have = 1;

SHA1
(	
pses->pses->account->password_try, 
strlen(pses->pses->account->password_try), 
pses->pses->account->hash
);

memset(pses->pses->account->password_try, 0, 64);
}
}
*/
void drecurse(PurpleBlistNode *pnode, char*uid)
{	
  PurpleBuddy *pbuddy;
  PurplePresence *ppresence;

  taim_session *pses;
  gboolean gb;

  while(pnode) {
    if(pnode->child) {
      drecurse(pnode->child, uid);
    }

    switch(pnode->type) {
      case PURPLE_BLIST_GROUP_NODE:
        break;

      case PURPLE_BLIST_CONTACT_NODE:
        break;

      case PURPLE_BLIST_BUDDY_NODE:
        pbuddy = (PurpleBuddy*)pnode;
        ppresence = purple_buddy_get_presence(pbuddy);	
        gb = purple_presence_is_online(ppresence);

        if(gb)
        {
          pses = uid_find(uid);

          if(pses->pses->account->account && pbuddy->account)
          {
            if(strlen(pbuddy->account->username) == strlen(pses->pses->account->account->username))
            {
              if(!strcmp(pbuddy->account->username, pses->pses->account->account->username))
              {
                buddy_get(pses, pbuddy->name);
              }
            }
          }
        }
        break;

      case PURPLE_BLIST_CHAT_NODE:
        break;

      case PURPLE_BLIST_OTHER_NODE:
        break;
    }

    pnode = pnode->next;
  }
  return;
}
Пример #3
0
void prot_login_get_list_reply( struct qqclient* qq, qqpacket* p )
{
    bytebuffer *buf = p->buf;
    ushort next_pos, len;
    len = get_word( buf );	//00 9C
    get_int( buf );	//00 00 00 00
    next_pos = get_word( buf );
    if( next_pos > 0x0000 ) {
        //Well, i don't know how to judge whether we have got the whole list, so I just
        //tested the length.
        DBG("next_pos = %d", next_pos );
        if( len == 0x038A ) {
            prot_login_get_list( qq, ++ qq->data.login_list_count );
        }
    } else {
        prot_login_send_info( qq );
    }
    while( buf->pos < buf->len-2 ) {	//2zeros in the end
        uint number = get_int( buf );
        uchar type = get_byte( buf );
        uchar gid = get_byte( buf );
        if( type == 0x04 )	//if it is a qun
        {
#ifndef NO_QUN_INFO
            qun_get( qq, number, 1 );
#endif
        } else if( type == 0x01 ) {
#ifndef NO_BUDDY_INFO
            qqbuddy* b = buddy_get( qq, number, 1 );
            if( b )
                b->gid = gid / 4;
#endif
        }
        number = type = gid = 0;
    }
}
Пример #4
0
static void process_buddy_im( struct qqclient* qq, qqpacket* p, qqmessage* msg )
{
	bytebuffer *buf = p->buf;
	get_word( buf );	//version
	msg->from = get_int( buf );
	if( get_int( buf ) != qq->number ){
		DBG("nothing but this is impossible!!");
		return;
	}
	//to check if this buddy is in our list, or we add it.
	buddy_get( qq, msg->from, 1 );
	//IM key
	uchar key[16];
	get_data( buf, key, 16 );
	ushort content_type = get_word( buf );
	switch( content_type ){
	case QQ_NORMAL_IM_TEXT:
	//	DBG("QQ_NORMAL_IM_TEXT");
		process_buddy_im_text( qq, p, msg );
		break;
	case QQ_NORMAL_IM_FILE_REQUEST_TCP:
		DBG("QQ_NORMAL_IM_FILE_REQUEST_TCP");
		break;
	case QQ_NORMAL_IM_FILE_APPROVE_TCP:
		DBG("QQ_NORMAL_IM_FILE_APPROVE_TCP");
		break;
	case QQ_NORMAL_IM_FILE_REJECT_TCP:
		DBG("QQ_NORMAL_IM_FILE_REJECT_TCP");
		break;
	case QQ_NORMAL_IM_FILE_REQUEST_UDP:
		DBG("QQ_NORMAL_IM_FILE_REQUEST_UDP");
		break;
	case QQ_NORMAL_IM_FILE_APPROVE_UDP:
		DBG("QQ_NORMAL_IM_FILE_APPROVE_UDP");
		break;
	case QQ_NORMAL_IM_FILE_REJECT_UDP:
		DBG("QQ_NORMAL_IM_FILE_REJECT_UDP");
		break;
	case QQ_NORMAL_IM_FILE_NOTIFY:
		DBG("QQ_NORMAL_IM_FILE_NOTIFY");
		break;
	case QQ_NORMAL_IM_FILE_PASV:
		DBG("QQ_NORMAL_IM_FILE_PASV");
		break;
	case QQ_NORMAL_IM_FILE_CANCEL:
		DBG("QQ_NORMAL_IM_FILE_CANCEL");
		break;
	case QQ_NORMAL_IM_FILE_EX_REQUEST_UDP:
//		DBG("QQ_NORMAL_IM_FILE_EX_REQUEST_UDP");
		break;
	case QQ_NORMAL_IM_FILE_EX_REQUEST_ACCEPT:
		DBG("QQ_NORMAL_IM_FILE_EX_REQUEST_ACCEPT");
		break;
	case QQ_NORMAL_IM_FILE_EX_REQUEST_CANCEL:
		DBG("QQ_NORMAL_IM_FILE_EX_REQUEST_CANCEL");
		break;
	case QQ_NORMAL_IM_FILE_EX_NOTIFY_IP:
		DBG("QQ_NORMAL_IM_FILE_EX_NOTIFY_IP");
		break;
	default:
		DBG("UNKNOWN type: %x", content_type );
		break;
	}
}
Пример #5
0
void prot_user_request_token_reply( struct qqclient* qq, qqpacket* p )
{
	bytebuffer *buf = p->buf;
	uchar cmd = get_byte( buf );
	get_word( buf );	//0006
	uchar verify = get_byte( buf );
	if( verify ){
		char *url, *data, *session;
		int datalen = KB(4);
		DBG("need verifying...");
		if( buf->pos == buf->len )	{
			puts("Verifying code is incorrect!");
			return;	//verify code wrong.
		}
		int len, ret;
		len = get_word( buf );
		if( len >= 128 ){
			DBG("url is too long.");	
			return;
		}
		NEW( data, datalen );
		NEW( url, 128 );
		NEW( session, 128 );
		get_data( buf, (uchar*)url, len );
		ret = http_request( &qq->http_sock, url, session, data, &datalen );
		if( ret == 0 ){
			char path[PATH_LEN];
			sprintf( path, "%s/%u.jpg", qq->verify_dir, qq->number );
			FILE *fp;
			fp = fopen( path, "wb" );
			DBG("got png at %s", path );
			if( fp ){
				fwrite( data, datalen, 1, fp );
				fclose( fp );
			}
			strncpy( qq->data.qqsession, session, 127 );
			qqclient_set_process( qq, P_VERIFYING );
			puts("You need to input the verifying code.");
		}else{
			DBG("http_request failed. ret=%d", ret );
		}
		DEL( data );
		DEL( url );
		DEL( session );
	}else{
		get_token( buf, &qq->data.user_token );
		qq->data.user_token_time = time(NULL);
		DBG("got token");
		qqbuddy *b = buddy_get( qq, qq->data.operating_number, 0 );
		if( b ){
			switch( qq->data.operation ){
			case OP_ADDBUDDY:
				if( b->verify_flag == VF_VERIFY ){
					prot_buddy_verify_addbuddy( qq, 02, qq->data.operating_number );
				}else if( b->verify_flag == VF_OK ){
					prot_buddy_verify_addbuddy( qq, 00, qq->data.operating_number );
				}
				break;
			case OP_DELBUDDY:
				prot_buddy_del_buddy( qq, qq->data.operating_number );
				break;
			}
		}
	}
	cmd = 0;
}
Пример #6
0
void *client_chat(void*in) {	
  int ret = 0;

  taim_buddy *tbuddy = 0;

  taim_session *pses = 0;
  taim_pipe *ptofree = 0;

  char buffer[BUFFER_SIZE] = {0},
       ret_buffer[BUFFER_SIZE] = {0},
       *uid;

  client_struct*pin = ((client_struct*)in);

  // End declaration

  // Raise the lock count
  atomic_increment();
  g_client_inuse[pin->thread] = 1;

  ret = read(pin->client, buffer, BUFFER_SIZE);

  // No data found, return
  if(ret <= 0) {
    atomic_decrement();
    return 0;
  }

  d(buffer);
  // Get the uid from the input string
  ret = parse(buffer, ret_buffer, &uid);
  if(ret == RET_ERROR) {
    atomic_decrement();
    return 0;
  }

  // Find the uid structure
  pses = uid_find(uid);
  if(pses != NULL) {

    if(ret == RET_DATA) {
      // clear the outgoing buffers
      buddy_ret_clear(pses);

      // lock the pipe mutex and fill the pipe
      pthread_mutex_lock(&pses->pses->pipe_mutex);
      for(;;) {

        if(pses->pses->cpipe->next == 0) {
          break;
        }

        // if a buddy was talking, set it as active
        tbuddy = buddy_get(pses, pses->pses->cpipe->user);
        if(tbuddy != NULL) {
          buddy_set_active(pses, tbuddy);

          buddy_ret_add(
              pses,
              tbuddy,
              pses->pses->cpipe->data,
              strlen(pses->pses->cpipe->data));
        }

        // clear this member of the linked list and move on
        ptofree = pses->pses->cpipe;
        pses->pses->cpipe = pses->pses->cpipe->next;
        free(ptofree);
      }

      // generate the list of buddies to return
      buddy_get_list(pses);

      // fill the buffer with this list
      buddy_ret_print(pses, ret_buffer);

      // unlock the pipes
      pthread_mutex_unlock(&pses->pses->pipe_mutex);
    }	
  }

  ret = write(pin->client, ret_buffer, strlen(ret_buffer));

  // drop the connection
  close(pin->client);
  g_client_inuse[pin->thread] = 0;

  free(uid);
  atomic_decrement();

  return 0;
}	
Пример #7
0
				fclose( fp );
			}
			strncpy( qq->data.qqsession, session, 127 );
			qqclient_set_process( qq, P_VERIFYING );
			puts("You need to input the verifying code.");
		}else{
			DBG (("http_request failed. ret=%d", ret ));
		}
		DEL( data );
		DEL( url );
		DEL( session );
	}else{
		get_token( buf, &qq->data.user_token );
		qq->data.user_token_time = time(NULL);
		DBG (("got token"));
		qqbuddy *b = buddy_get( qq, qq->data.operating_number, 0 );
		if( b ){
			switch( qq->data.operation ){
			case OP_ADDBUDDY:
				if( b->verify_flag == VF_VERIFY ){
					prot_buddy_verify_addbuddy( qq, 02, qq->data.operating_number );
				}else if( b->verify_flag == VF_OK ){
					prot_buddy_verify_addbuddy( qq, 00, qq->data.operating_number );
				}
				break;
			case OP_DELBUDDY:
				prot_buddy_del_buddy( qq, qq->data.operating_number );
				break;
			}
		}
	}