Beispiel #1
0
void
bonjour_dns_sd_set_jid(PurpleAccount *account, const char *hostname)
{
	PurpleConnection *conn = purple_account_get_connection(account);
	BonjourData *bd = purple_connection_get_protocol_data(conn);
	const char *tmp, *account_name = purple_account_get_username(account);

	/* Previously we allowed the hostname part of the jid to be set
	 * explicitly when it should always be the current hostname.
	 * That is what this is intended to deal with.
	 */
	if ((tmp = strchr(account_name, '@'))
	    && strstr(tmp, hostname) == (tmp + 1)
	    && *((tmp + 1) + strlen(hostname)) == '\0')
		bd->jid = g_strdup(account_name);
	else {
		const char *tmp2;
		GString *str = g_string_new("");
		/* Escape an '@' in the account name */
		tmp = account_name;
		while ((tmp2 = strchr(tmp, '@')) != NULL) {
			g_string_append_len(str, tmp, tmp2 - tmp);
			g_string_append(str, "\\40");
			tmp = tmp2 + 1;
		}
		g_string_append(str, tmp);
		g_string_append_c(str, '@');
		g_string_append(str, hostname);

		bd->jid = g_string_free(str, FALSE);
	}
}
Beispiel #2
0
void qq_send_file(PurpleConnection* gc,const char* who,const char* filename)
{
    qq_account* ac = purple_connection_get_protocol_data(gc);
    if(!ac->debug_file_send) {
        //purple_notify_warning(gc,NULL,"难题尚未攻破,曙光遥遥无期","请先用离线文件传输");
        PurpleXfer* xfer = purple_xfer_new(ac->account,PURPLE_XFER_SEND,who);
        purple_xfer_set_init_fnc(xfer,upload_offline_file_init);
        purple_xfer_set_request_denied_fnc(xfer,recv_file_request_denied);
        purple_xfer_set_cancel_send_fnc(xfer,recv_file_cancel);
        if(filename)
            purple_xfer_request_accepted(xfer, filename);
        else
            purple_xfer_request(xfer);
        return;
    }
    PurpleAccount* account = ac->account;
    PurpleXfer* xfer = purple_xfer_new(account,PURPLE_XFER_SEND,who);
    purple_xfer_set_init_fnc(xfer,upload_file_init);
    //purple_xfer_set_init_fnc(xfer,upload_offline_file_init);
    //purple_xfer_set_request_denied_fnc(xfer,file_trans_request_denied);
    //purple_xfer_set_cancel_send_fnc(xfer,file_trans_cancel);
    void** data = s_malloc(sizeof(void*)*3);
    data[0] = ac;
    xfer->data = data;
    purple_xfer_request(xfer);
}
Beispiel #3
0
static void ggp_ggdrive_auth(PurpleConnection *gc, ggp_ggdrive_auth_cb cb,
	gpointer user_data)
{
	GGPInfo *accdata = purple_connection_get_protocol_data(gc);
	ggp_edisc_session_data *sdata = ggp_edisc_get_sdata(gc);
	ggp_edisc_auth_data *auth;
	const gchar *imtoken;
	gchar *metadata;
	PurpleHttpRequest *req;

	g_return_if_fail(sdata != NULL);

	imtoken = ggp_get_imtoken(gc);
	if (!imtoken) {
		cb(gc, FALSE, user_data);
		return;
	}

	if (sdata->auth_done) {
		cb(gc, sdata->security_token != NULL, user_data);
		return;
	}

	auth = g_new0(ggp_edisc_auth_data, 1);
	auth->cb = cb;
	auth->user_data = user_data;
	sdata->auth_pending = g_list_prepend(sdata->auth_pending, auth);

	if (sdata->auth_request)
		return;

	purple_debug_info("gg", "ggp_ggdrive_auth(gc=%p)\n", gc);

	req = purple_http_request_new("https://drive.mpa.gg.pl/signin");
	purple_http_request_set_method(req, "PUT");

	ggp_edisc_set_defaults(req);
	purple_http_request_set_cookie_jar(req, sdata->cookies);

	metadata = g_strdup_printf("{"
		"\"id\": \"%032x\", "
		"\"name\": \"%s\", "
		"\"os_version\": \"" GGP_EDISC_OS "\", "
		"\"client_version\": \"%s\", "
		"\"type\": \"" GGP_EDISC_TYPE "\"}",
		g_random_int_range(1, 1 << 16),
		purple_get_host_name(),
		ggp_libgaduw_version(gc));

	purple_http_request_header_set_printf(req, "Authorization",
		"IMToken %s", imtoken);
	purple_http_request_header_set_printf(req, "X-gged-user",
		"gg/pl:%u", accdata->session->uin);
	purple_http_request_header_set(req, "X-gged-client-metadata", metadata);
	g_free(metadata);

	sdata->auth_request = purple_http_request(gc, req,
		ggp_ggdrive_auth_done, NULL);
	purple_http_request_unref(req);
}
Beispiel #4
0
void jabber_set_status(PurpleAccount *account, PurpleStatus *status)
{
	PurpleConnection *gc;
	JabberStream *js;

	if (!purple_account_is_connected(account))
		return;

	if (purple_status_is_exclusive(status) && !purple_status_is_active(status)) {
		/* An exclusive status can't be deactivated. You should just
		 * activate some other exclusive status. */
		return;
	}

	gc = purple_account_get_connection(account);
	js = purple_connection_get_protocol_data(gc);

	/* it's a mood update */
	if (purple_status_type_get_primitive(purple_status_get_type(status)) == PURPLE_STATUS_MOOD) {
		const char *mood =
			purple_status_get_attr_string(status, PURPLE_MOOD_NAME);
		const char *mood_text =
			purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT);
		jabber_mood_set(js, mood, mood_text);
		return;
	}

	jabber_presence_send(js, FALSE);
}
Beispiel #5
0
static void upload_offline_file_init(PurpleXfer* xfer)
{
    qq_account* ac = purple_connection_get_protocol_data(purple_account_get_connection(xfer->account));
    LwqqClient* lc = ac->qq;

    const char* serv_id;
    if(ac->qq_use_qqnum) {
        const char* qqnum = purple_xfer_get_remote_user(xfer);
        LwqqBuddy* b = find_buddy_by_qqnumber(ac->qq, qqnum);
        if(b == NULL) return;
        serv_id = b->uin;
    } else {
        serv_id = purple_xfer_get_remote_user(xfer);
    }

    LwqqMsgOffFile* file = lwqq_msg_fill_upload_offline_file(
                               xfer->local_filename, lc->myself->uin, serv_id);
    xfer->start_time = time(NULL);
    xfer->data = file;
    int flags = 0;
    if(ac->dont_expected_100_continue) flags |= DONT_EXPECTED_100_CONTINUE;
    LwqqAsyncEvent* ev = lwqq_msg_upload_offline_file(lc,file,flags);
    lwqq_async_add_event_listener(ev,_C_(2p,send_file,ev,xfer));
    LwqqHttpRequest* req = lwqq_async_event_get_conn(ev);
    lwqq_http_on_progress(req, file_trans_on_progress, xfer);
    lwqq_http_set_option(req, LWQQ_HTTP_CANCELABLE,1L);
}
int yahoo_c_send(PurpleConnection *gc, int id, PurpleMessage *msg)
{
	PurpleChatConversation *c;
	int ret;
	YahooData *yd;
	const gchar *what = purple_message_get_contents(msg);
	PurpleMessageFlags flags = purple_message_get_flags(msg);

	yd = purple_connection_get_protocol_data(gc);
	if (!yd)
		return -1;

	c = purple_conversations_find_chat(gc, id);
	if (!c)
		return -1;

	if (id != YAHOO_CHAT_ID) {
		GList *users;
		users = purple_chat_conversation_get_users(c);
		ret = yahoo_conf_send(gc,
			purple_connection_get_display_name(gc),
			purple_conversation_get_name(PURPLE_CONVERSATION(c)),
			users, what);
		g_list_free(users);
	} else {
		ret = yahoo_chat_send(gc, purple_connection_get_display_name(gc),
						purple_conversation_get_name(PURPLE_CONVERSATION(c)), what, flags);
		if (!ret)
			purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(c),
					purple_connection_get_display_name(gc), flags, what, time(NULL));
	}
	return ret;
}
Beispiel #7
0
static void waprpl_set_buddy_icon(PurpleConnection * gc, PurpleStoredImage * img)
{
	/* Send the picture the user has selected! */
	whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
	size_t size = purple_imgstore_get_size(img);
	const void *data = purple_imgstore_get_data(img);

	if (data) {
		// First of all make the picture a square
		char * sqbuffer; int sqsize;
		imgProfile(data, size, (void**)&sqbuffer, &sqsize, 640);

		char * pbuffer; int osize;
		imgProfile(data, size, (void**)&pbuffer, &osize, 96);

		waAPI_setavatar(wconn->waAPI, sqbuffer, sqsize, pbuffer, osize);

		free(sqbuffer); free(pbuffer);
	}
	else {
		waAPI_setavatar(wconn->waAPI, 0,0,0,0);
	}

	waprpl_check_output(gc);
}
Beispiel #8
0
static void waprpl_output_cb(gpointer data, gint source, PurpleInputCondition cond)
{
	PurpleConnection *gc = data;
	whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);

	char tempbuff[16*1024];
	int ret;
	do {
		int datatosend = waAPI_sendcb(wconn->waAPI, tempbuff, sizeof(tempbuff));
		if (datatosend == 0)
			break;

		ret = sys_write(wconn->fd, tempbuff, datatosend);

		if (ret > 0) {
			waAPI_senddone(wconn->waAPI, ret);
		} else if (ret == 0 || (ret < 0 && errno == EAGAIN)) {
			/* Check later */
		} else {
			gchar *tmp = g_strdup_printf("Lost connection with server (out cb): %s", g_strerror(errno));
			purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
			g_free(tmp);
			break;
		}
	} while (ret > 0);

	/* Check if we need to callback again or not */
	waprpl_check_output(gc);
}
Beispiel #9
0
/* Try to read some data and push it to the WhatsApp API */
static void waprpl_input_cb(gpointer data, gint source, PurpleInputCondition cond)
{
	PurpleConnection *gc = data;
	whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);

	char tempbuff[16*1024];
	int ret;
	do {
		ret = sys_read(wconn->fd, tempbuff, sizeof(tempbuff));
		if (ret > 0)
			waAPI_input(wconn->waAPI, tempbuff, ret);
		else if (ret < 0 && errno == EAGAIN)
			break;
		else if (ret < 0) {
			gchar *tmp = g_strdup_printf("Lost connection with server (in cb): %s", g_strerror(errno));
			purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
			g_free(tmp);
			break;
		} else {
			purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, "Server closed the connection");
		}
	} while (ret > 0);

	waprpl_process_incoming_events(gc);
	waprpl_check_output(gc);	/* The input data may generate responses! */
}
Beispiel #10
0
/* Try to read some data and push it to the WhatsApp API */
void waprpl_ssl_input_cb(gpointer data, gint source, PurpleInputCondition cond)
{
	PurpleConnection *gc = data;
	whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);

	/* End point closed the connection */
	if (!g_list_find(purple_connections_get_all(), gc)) {
		waprpl_ssl_cerr_cb(0, 0, gc);
		return;
	}

	char tempbuff[16*1024];
	int ret;
	do {
		ret = purple_ssl_read(wconn->gsc, tempbuff, sizeof(tempbuff));
		purple_debug_info(WHATSAPP_ID, "Input data read %d %d\n", ret, errno);

		if (ret > 0) {
			waAPI_sslinput(wconn->waAPI, tempbuff, ret);
		} else if (ret < 0 && errno == EAGAIN)
			break;
		else if (ret < 0) {
			waprpl_ssl_cerr_cb(0, 0, gc);
			break;
		} else {
			waprpl_ssl_cerr_cb(0, 0, gc);
		}
	} while (ret > 0);

	waprpl_check_ssl_output(gc);	/* The input data may generate responses! */
	waprpl_check_output(gc);
}
Beispiel #11
0
/* Show privacy settings */
static void waprpl_show_privacy(PurplePluginAction * action)
{
	PurpleConnection *gc = (PurpleConnection *) action->context;
	whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
	if (!wconn)
		return;

	char priv[3][30];
	waAPI_queryprivacy(wconn->waAPI, priv[0], priv[1], priv[2]);

	PurpleRequestField *field;

	PurpleRequestFields *fields = purple_request_fields_new();
	PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL);
	purple_request_fields_add_group(fields, group);

	int i,j;
	for (j = 0; j < 3; j++) {
		field = purple_request_field_list_new(priv_type[j], priv_type_nice[j]);
		for (i = 0; i < 3; i++) {
			purple_request_field_list_add(field, priv_opt_nice[i], g_strdup(priv_opt[i]));
			if (strcmp(priv_opt[i], priv[j]) == 0)
				purple_request_field_list_add_selected(field, priv_opt_nice[i]);
		}
		purple_request_field_group_add_field(group, field);
	}

	purple_request_fields(gc, "Edit privacy settings", "Edit privacy settings",
						NULL, fields, 
						"Save", G_CALLBACK(waprpl_update_privacy),
						"Cancel", NULL,
						purple_connection_get_account(gc), NULL, NULL,
						gc);
}
Beispiel #12
0
void waprpl_ssl_output_cb(gpointer data, gint source, PurpleInputCondition cond)
{
	PurpleConnection *gc = data;
	whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);

	char tempbuff[16*1024];
	int ret;
	do {
		int datatosend = waAPI_sslsendcb(wconn->waAPI, tempbuff, sizeof(tempbuff));
		purple_debug_info(WHATSAPP_ID, "Output data to send %d\n", datatosend);

		if (datatosend == 0)
			break;

		ret = purple_ssl_write(wconn->gsc, tempbuff, datatosend);

		if (ret > 0) {
			waAPI_sslsenddone(wconn->waAPI, ret);
		} else if (ret == 0 || (ret < 0 && errno == EAGAIN)) {
			/* Check later */
		} else {
			waprpl_ssl_cerr_cb(0, 0, gc);
		}
	} while (ret > 0);

	/* Check if we need to callback again or not */
	waprpl_check_ssl_output(gc);
	waprpl_check_output(gc);
}
Beispiel #13
0
static void waprpl_chat_join(PurpleConnection * gc, GHashTable * data)
{
	whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
	const char *groupname = g_hash_table_lookup(data, "subject");
	char *id = g_hash_table_lookup(data, "id");

	if (!id) {
		gchar *tmp = g_strdup_printf("Joining %s requires an invitation.", groupname);
		purple_notify_error(gc, "Invitation only", "Invitation only", tmp);
		g_free(tmp);
		return;
	}

	int prplid = chatid_to_convo(id);
	purple_debug_info(WHATSAPP_ID, "joining group %s\n", groupname);

	if (!purple_find_chat(gc, prplid)) {
		char *subject, *owner, *part;
		if (!waAPI_getgroupinfo(wconn->waAPI, id, &subject, &owner, &part)) {
			subject = g_strdup("Unknown");
			owner   = g_strdup("000000");
			part    = g_strdup("");
		}

		/* Notify chat add */
		PurpleConversation *conv = serv_got_joined_chat(gc, prplid, groupname);

		/* Add people in the chat */
		purple_debug_info(WHATSAPP_ID, "group info ID(%s) SUBJECT(%s) OWNER(%s)\n", id, subject, owner);
		conv_add_participants(conv, part, owner);
		g_free(subject); g_free(part);
	}
}
Beispiel #14
0
static void waprpl_get_info(PurpleConnection * gc, const char *username)
{
	PurpleNotifyUserInfo *info = purple_notify_user_info_new();
	purple_debug_info(WHATSAPP_ID, "Fetching %s's user info for %s\n", username, gc->account->username);

	/* Get user status */
	whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
	const char *status_string = waAPI_getuserstatusstring(wconn->waAPI, username);
	/* Get user picture (big one) */
	char *profile_image = "";
	char *icon;
	int len;
	int res = waAPI_queryavatar(wconn->waAPI, username, &icon, &len);
	if (res) {
		int iid = purple_imgstore_add_with_id(g_memdup(icon, len), len, NULL);
		profile_image = g_strdup_printf("<img id=\"%u\">", iid);
	}

	purple_notify_user_info_add_pair(info, "Status", status_string);
	purple_notify_user_info_add_pair(info, "Profile image", profile_image);

	if (res)
		g_free(profile_image);

	purple_notify_userinfo(gc, username, info, NULL, NULL);
	
	waprpl_check_output(gc);
}
void yahoo_chat_goto(PurpleConnection *gc, const char *name)
{
	YahooData *yd;
	struct yahoo_packet *pkt;

	yd = purple_connection_get_protocol_data(gc);

	if (yd->wm) {
		g_return_if_fail(yd->ycht != NULL);
		ycht_chat_goto_user(yd->ycht, name);
		return;
	}

	if (!yd->chat_online) {
		yahoo_chat_online(gc);
		g_free(yd->pending_chat_room);
		yd->pending_chat_room = NULL;
		g_free(yd->pending_chat_id);
		yd->pending_chat_id = NULL;
		g_free(yd->pending_chat_topic);
		yd->pending_chat_topic = NULL;
		g_free(yd->pending_chat_goto);
		yd->pending_chat_goto = g_strdup(name);
		return;
	}

	pkt = yahoo_packet_new(YAHOO_SERVICE_CHATGOTO, YAHOO_STATUS_AVAILABLE, yd->session_id);
	yahoo_packet_hash(pkt, "sss", 109, name, 1, purple_connection_get_display_name(gc), 62, "2");
	yahoo_packet_send_and_free(pkt, yd);
}
Beispiel #16
0
static int waprpl_send_chat(PurpleConnection * gc, int id, const char *message, PurpleMessageFlags flags)
{
	whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
	PurpleAccount *account = purple_connection_get_account(gc);
	PurpleConversation *convo = purple_find_chat(gc, id);
	PurpleChat *ch = blist_find_chat_by_convo(gc, id);
	GHashTable *hasht = purple_chat_get_components(ch);
	char *chat_id = g_hash_table_lookup(hasht, "id");
	char *plain;

	purple_markup_html_to_xhtml(message, NULL, &plain);

	char msgid[128];
	waAPI_getmsgid(wconn->waAPI, msgid);

	purple_signal_emit(purple_connection_get_prpl(gc), "whatsapp-sending-message", gc, msgid, chat_id, message);

	waAPI_sendchat(wconn->waAPI, msgid, chat_id, plain);
	g_free(plain);

	waprpl_check_output(gc);

	const char *me = purple_account_get_string(account, "nick", "");
	purple_conv_chat_write(PURPLE_CONV_CHAT(convo), me, message, PURPLE_MESSAGE_SEND, time(NULL));

	return 1;
}
void yahoo_c_leave(PurpleConnection *gc, int id)
{
	YahooData *yd = purple_connection_get_protocol_data(gc);
	PurpleChatConversation *c;

	if (!yd)
		return;

	c = purple_conversations_find_chat(gc, id);
	if (!c)
		return;

	if (id != YAHOO_CHAT_ID) {
		GList *users;
		users = purple_chat_conversation_get_users(c);
		yahoo_conf_leave(yd,
			purple_conversation_get_name(PURPLE_CONVERSATION(c)),
			purple_connection_get_display_name(gc), users);
		g_list_free(users);
		yd->confs = g_slist_remove(yd->confs, c);
	} else {
		yahoo_chat_leave(gc, purple_conversation_get_name(PURPLE_CONVERSATION(c)),
				purple_connection_get_display_name(gc), TRUE);
	}

	purple_serv_got_chat_left(gc, id);
}
Beispiel #18
0
/* we can show tiny icons on the four corners of buddy icon, */
static const char *qq_list_emblem(PurpleBuddy *b)
{
	PurpleAccount *account;
	PurpleConnection *gc;
	qq_data *qd;
	qq_buddy_data *buddy;

	if (!b || !(account = purple_buddy_get_account(b)) ||
		!(gc = purple_account_get_connection(account)) ||
		!(qd = purple_connection_get_protocol_data(gc)))
		return NULL;

	buddy = purple_buddy_get_protocol_data(b);
	if (!buddy) {
		return "not-authorized";
	}

	if (buddy->comm_flag & QQ_COMM_FLAG_MOBILE)
		return "mobile";
	if (buddy->comm_flag & QQ_COMM_FLAG_VIDEO)
		return "video";
	if (buddy->comm_flag & QQ_COMM_FLAG_QQ_MEMBER)
		return "qq_member";

	return NULL;
}
Beispiel #19
0
void tgprpl_recv_file (PurpleConnection *gc, const char *who, struct tgl_message *M) {
  debug ("tgprpl_recv_file()");
  g_return_if_fail (who);
  
  PurpleXfer *X = tgprpl_new_xfer_recv (gc, who);
  const char *mime_type, *caption;
  long long access_hash;
  int flags, size;
  
  if (M->media.type == tgl_message_media_document_encr) {
    mime_type = M->media.encr_document->mime_type;
    caption = M->media.encr_document->caption;
    access_hash = M->media.encr_document->access_hash;
    flags = M->media.encr_document->flags;
    size = M->media.encr_document->size;
  } else {
    mime_type = M->media.document->mime_type;
    caption = M->media.document->caption;
    access_hash = M->media.document->access_hash;
    flags = M->media.document->flags;
    size = M->media.document->size;
  }

  char *filename = tgp_strdup_determine_filename (mime_type, caption, flags, access_hash);
  purple_xfer_set_filename (X, filename);
  g_free (filename);
  
  purple_xfer_set_size (X, size);
  tgprpl_xfer_init_data (X, purple_connection_get_protocol_data (gc), M);
  purple_xfer_request (X);
}
Beispiel #20
0
/*------------------------------------------------------------------------
 * Send a message to a contact
 *
 *  @param gc		The connection object
 *  @param who		The username of the recipient
 *  @param message	The message text
 *  @param flags	Message flags (defined in conversation.h)
 *  @return			Positive value (success, and echo to conversation window)
					Zero (success, no echo)
					Negative value (error)
 */
static int mxit_send_im( PurpleConnection* gc, const char* who, const char* message, PurpleMessageFlags flags )
{
	purple_debug_info( MXIT_PLUGIN_ID, "Sending message '%s' to buddy '%s'\n", message, who );

	mxit_send_message( purple_connection_get_protocol_data( gc ), who, message, TRUE, FALSE );

	return 1;		/* echo to conversation window */
}
Beispiel #21
0
static void waprpl_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {
  whatsapp_connection * wconn = purple_connection_get_protocol_data(gc);
  const char * name = purple_buddy_get_name(buddy);
  
  waAPI_delcontact(wconn->waAPI,name);
  
  waprpl_check_output(gc);
}
Beispiel #22
0
static void ycht_process_logout(YchtConn *ycht, YchtPkt *pkt)
{
	PurpleConnection *gc = ycht->gc;
	YahooData *yd = purple_connection_get_protocol_data(gc);

	yd->chat_online = FALSE;
	ycht->logged_in = FALSE;
}
static void do_nick_set_nick(PurplePluginAction *action) {
	PurpleConnection *gc = action->context;
	JabberStream *js = purple_connection_get_protocol_data(gc);

	/* since the nickname might have been changed by another resource of this account, we always have to request the old one
		from the server to present as the default for the new one */
	jabber_pep_request_item(js, NULL, "http://jabber.org/protocol/nick", NULL, do_nick_got_own_nick_cb);
}
Beispiel #24
0
static int waprpl_send_im(PurpleConnection *gc, const char *who, const char *message, PurpleMessageFlags flags) {
  whatsapp_connection * wconn = purple_connection_get_protocol_data(gc);

  waAPI_sendim(wconn->waAPI,who,message);
  waprpl_check_output(gc);
  
  return 1;
}
Beispiel #25
0
/*------------------------------------------------------------------------
 * Send a message to a contact
 *
 *  @param gc		The connection object
 *  @param who		The username of the recipient
 *  @param message	The message text
 *  @param flags	Message flags (defined in conversation.h)
 *  @return			Positive value (success, and echo to conversation window)
					Zero (success, no echo)
					Negative value (error)
 */
static int mxit_send_im(PurpleConnection* gc, PurpleMessage *msg)
{
	mxit_send_message(purple_connection_get_protocol_data(gc),
		purple_message_get_recipient(msg), purple_message_get_contents(msg),
		TRUE, FALSE);

	return 1;		/* echo to conversation window */
}
Beispiel #26
0
static void modify_impresa_cb(PurpleConnection *gc, const gchar *text)
{
	fetion_account *ac;
	g_return_if_fail(NULL != gc && NULL != gc->proto_data);

	ac = purple_connection_get_protocol_data(gc);
	fetion_modify_info(ac, MODIFY_INFO_IMPRESA, text);
}
Beispiel #27
0
static void fx_remove_group(PurpleConnection *gc, PurpleGroup *group)
{
	const gchar *name = purple_group_get_name(group);
	fetion_account *ac = purple_connection_get_protocol_data(gc);
	Group *blist = fetion_group_list_find_by_name(ac->user->groupList, name);
	if(!blist) return;
	fetion_buddylist_delete(ac, blist->groupid);
}
Beispiel #28
0
static void recv_file_request_denied(PurpleXfer* xfer)
{
	qq_account* ac = purple_connection_get_protocol_data(purple_account_get_connection(xfer->account));
	LwqqClient* lc = ac->qq;
	LwqqMsgFileMessage* file = xfer->data;
	lwqq_msg_refuse_file(lc, file);
	lwqq_msg_free((LwqqMsg*)file);
}
Beispiel #29
0
/*------------------------------------------------------------------------
 * Set or clear our Buddy icon.
 *
 *  @param gc		The connection object
 *  @param img		The buddy icon data
 */
static void mxit_set_buddy_icon( PurpleConnection *gc, PurpleStoredImage *img )
{
	struct MXitSession*	session	= purple_connection_get_protocol_data( gc );

	if ( img == NULL )
		mxit_set_avatar( session, NULL, 0 );
	else
		mxit_set_avatar( session, purple_imgstore_get_data( img ), purple_imgstore_get_size( img ) );
}
Beispiel #30
0
static PurpleXfer *tgprpl_new_xfer_recv (PurpleConnection * gc, const char *who) {
  connection_data *conn = purple_connection_get_protocol_data (gc);
  
  PurpleXfer *X = purple_xfer_new (conn->pa, PURPLE_XFER_RECEIVE, who);
  purple_xfer_set_init_fnc (X, tgprpl_xfer_recv_init);
  purple_xfer_set_cancel_recv_fnc (X, tgprpl_xfer_canceled);
  
  return X;
}