Merge branch 'EionRobb-group-typing-notifications' into dev-1.4.0
Merges pull request #359
This commit is contained in:
commit
77d50c3ae1
3 changed files with 67 additions and 0 deletions
|
@ -55,6 +55,7 @@ struct tgl_update_callback tgp_callback = {
|
|||
|
||||
// FIXME: what about user_registred, user_activated, new_authorization, our_id ?
|
||||
.type_in_secret_chat_notification = update_secret_chat_typing,
|
||||
.type_in_chat_notification = update_chat_typing,
|
||||
.chat_update = update_chat_handler,
|
||||
.channel_update = update_channel_handler,
|
||||
.user_update = update_user_handler,
|
||||
|
@ -523,6 +524,8 @@ static void update_on_failed_login (struct tgl_state *TLS) {
|
|||
purple_connection_error (tls_get_conn (TLS), TLS->error);
|
||||
}
|
||||
|
||||
static gulong chat_conversation_typing_signal = 0;
|
||||
|
||||
static void tgprpl_login (PurpleAccount * acct) {
|
||||
info ("tgprpl_login(): Purple is telling the prpl to connect the account");
|
||||
|
||||
|
@ -622,6 +625,11 @@ static void tgprpl_login (PurpleAccount * acct) {
|
|||
|
||||
purple_connection_set_state (conn->gc, PURPLE_CONNECTING);
|
||||
tgl_login (TLS);
|
||||
|
||||
if (!chat_conversation_typing_signal) {
|
||||
chat_conversation_typing_signal = purple_signal_connect(purple_conversations_get_handle(), "chat-conversation-typing",
|
||||
purple_connection_get_prpl (gc), PURPLE_CALLBACK(tgprpl_send_chat_typing), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void tgprpl_close (PurpleConnection *gc) {
|
||||
|
|
57
tgp-chat.c
57
tgp-chat.c
|
@ -218,6 +218,63 @@ int tgprpl_send_chat (PurpleConnection *gc, int id, const char *message, PurpleM
|
|||
return tgp_msg_send (gc_get_tls (gc), message, P->id);
|
||||
}
|
||||
|
||||
unsigned int tgprpl_send_chat_typing (PurpleConversation *conv, PurpleTypingState typing, gpointer ignored)
|
||||
{
|
||||
PurpleConnection *gc = purple_conversation_get_gc (conv);
|
||||
tgl_peer_t *P;
|
||||
PurpleConvChat *chat;
|
||||
int id;
|
||||
|
||||
if (!PURPLE_CONNECTION_IS_CONNECTED (gc))
|
||||
return 0;
|
||||
|
||||
if (g_strcmp0(purple_plugin_get_id (purple_connection_get_prpl (gc)), PLUGIN_ID))
|
||||
return 0;
|
||||
|
||||
debug ("tgprpl_send_chat_typing()");
|
||||
|
||||
chat = purple_conversation_get_chat_data (conv);
|
||||
id = purple_conv_chat_get_id (chat);
|
||||
|
||||
P = tgl_peer_get (gc_get_tls (gc), TGL_MK_CHAT(id));
|
||||
if (! P) {
|
||||
P = tgl_peer_get (gc_get_tls (gc), TGL_MK_CHANNEL(id));
|
||||
}
|
||||
g_return_val_if_fail(P != NULL, -1);
|
||||
|
||||
tgl_do_send_typing (gc_get_tls (gc), P->id, typing == PURPLE_TYPING ? tgl_typing_typing : tgl_typing_cancel,
|
||||
0, 0);
|
||||
|
||||
// when the group receives a typing notification it is obvious that the previous messages were read
|
||||
pending_reads_send_user (gc_get_tls (gc), P->id);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
void update_chat_typing (struct tgl_state *TLS, struct tgl_user *U, struct tgl_chat *C, enum tgl_typing_status status) {
|
||||
debug ("update_chat_typing()");
|
||||
|
||||
PurpleConvChat *chat = NULL;
|
||||
PurpleConversation *conv = purple_find_chat (tls_get_conn (TLS), tgl_get_peer_id (C->id));
|
||||
if (conv) {
|
||||
chat = purple_conversation_get_chat_data (conv);
|
||||
}
|
||||
g_return_if_fail(chat != NULL);
|
||||
|
||||
const char *name = tgp_blist_lookup_purple_name (TLS, U->id);
|
||||
g_return_if_fail(name != NULL);
|
||||
|
||||
PurpleConvChatBuddyFlags flags = purple_conv_chat_user_get_flags (chat, name);
|
||||
|
||||
if (status == tgl_typing_typing) {
|
||||
flags |= PURPLE_CBFLAGS_TYPING;
|
||||
} else {
|
||||
flags &= ~PURPLE_CBFLAGS_TYPING;
|
||||
}
|
||||
|
||||
purple_conv_chat_user_set_flags(chat, name, flags);
|
||||
}
|
||||
|
||||
void tgprpl_kick_from_chat (PurpleConnection *gc, int id, const char *who) {
|
||||
debug ("tgprpl_kick_from_chat()");
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ PurpleChat *tgp_chat_blist_store (struct tgl_state *TLS, tgl_peer_t *P, const ch
|
|||
|
||||
PurpleConversation *tgp_chat_show (struct tgl_state *TLS, tgl_peer_t *P);
|
||||
int tgprpl_send_chat (PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags);
|
||||
unsigned int tgprpl_send_chat_typing (PurpleConversation *conv, PurpleTypingState typing, gpointer ignored);
|
||||
char *tgprpl_get_chat_name (GHashTable *data);
|
||||
void tgprpl_chat_join (PurpleConnection *gc, GHashTable *data);
|
||||
GList *tgprpl_chat_join_info (PurpleConnection *gc);
|
||||
|
@ -62,5 +63,6 @@ int tgp_channel_loaded (struct tgl_state *TLS, tgl_peer_id_t id);
|
|||
|
||||
void update_channel_handler (struct tgl_state *TLS, struct tgl_channel *C, unsigned flags);
|
||||
void update_chat_handler (struct tgl_state *TLS, struct tgl_chat *C, unsigned flags);
|
||||
void update_chat_typing (struct tgl_state *TLS, struct tgl_user *U, struct tgl_chat *C, enum tgl_typing_status status);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue