Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit adddf18

Browse files
committed
Handle group conversations just like ordinary one-to-one conversations.
Adjust README. Bump version because of bugfix.
1 parent 528fa51 commit adddf18

File tree

4 files changed

+21
-53
lines changed

4 files changed

+21
-53
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# purple-signald
22

3-
A libpurple/Pidgin plugin for [signald](https://git.callpipe.com/finn/signald)
3+
A libpurple/Pidgin plugin for [signald](https://git.callpipe.com/finn/signald) (signal, formerly textsecure).
44

55
signald is written by Finn Herzfeld.
66

7-
I never wrote code for use in Pidgin before. EionRobb's purple-discord sources were of great help.
7+
I never wrote code for use in Pidgin before. EionRobb's [purple-discord](https://github.com/EionRobb/purple-discord) sources were of great help.
88

99
Tested on Ubuntu 18.04.
1010

@@ -16,5 +16,5 @@ Tested on Ubuntu 18.04.
1616
### Missing Features
1717

1818
* Integrating with the buddy list
19-
* Group chats
20-
* anything beyond messaging single recipients, really
19+
* Proper group chats (right now you can send and receive group messages, but you cannot tell which one of the group members is answering)
20+
* Anything beyond simple messaging, really

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.0
1+
0.1.1

glib_compat.h

Lines changed: 0 additions & 43 deletions
This file was deleted.

libsignald.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
#define SIGNALD_PLUGIN_ID "prpl-hehoe-signald"
4141
#ifndef SIGNALD_PLUGIN_VERSION
42-
#define SIGNALD_PLUGIN_VERSION "0.1"
42+
#define SIGNALD_PLUGIN_VERSION "0.1.1"
4343
#endif
4444
#define SIGNALD_PLUGIN_WEBSITE "https://github.com/hoehermann/libpurple-signald"
4545

@@ -82,11 +82,13 @@ signald_assume_all_buddies_online(SignaldAccount *sa)
8282

8383
void
8484
signald_process_message(SignaldAccount *sa,
85-
const gchar *username, const gchar *content, const gchar *timestamp_str)
85+
const gchar *username, const gchar *content, const gchar *timestamp_str,
86+
const gchar *groupid_str, const gchar *groupname)
8687
{
8788
PurpleMessageFlags flags = PURPLE_MESSAGE_RECV;
8889
time_t timestamp = purple_str_to_time(timestamp_str, FALSE, NULL, NULL, NULL);
89-
purple_serv_got_im(sa->pc, username, content, flags, timestamp);
90+
const gchar * sender = groupid_str && *groupid_str ? groupid_str : username;
91+
purple_serv_got_im(sa->pc, sender, content, flags, timestamp);
9092
}
9193

9294
void
@@ -108,6 +110,7 @@ signald_handle_input(SignaldAccount *sa, const char * json)
108110
if (purple_strequal(type, "version")) {
109111
purple_debug_error("signald", "signald version ignored.\n");
110112
} else if (purple_strequal(type, "success")) {
113+
// TODO: mark message as delayed (maybe do not echo) until success is reported
111114
purple_debug_error("signald", "Success noticed.\n");
112115
} else if (purple_strequal(type, "subscribed")) {
113116
purple_debug_error("signald", "Subscribed!\n");
@@ -120,13 +123,21 @@ signald_handle_input(SignaldAccount *sa, const char * json)
120123
gboolean isreceipt = json_object_get_boolean_member(obj, "isReceipt");
121124
if (isreceipt) {
122125
// TODO: this could be displayed in the conversation window
126+
// purple_conv_chat_write(to, username, msg, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
123127
purple_debug_error("signald", "Received reciept.\n");
124128
} else {
125129
const gchar *username = json_object_get_string_member(obj, "source");
126130
const gchar *timestamp_str = json_object_get_string_member(obj, "timestampISO"); // TODO: create time_t from integer timestamp as timestampISO probably means "time of delivery" instead of the time the message was sent
127131
obj = json_object_get_object_member(obj, "dataMessage");
128132
const gchar *message = json_object_get_string_member(obj, "message");
129-
signald_process_message(sa, username, message, timestamp_str);
133+
obj = json_object_get_object_member(obj, "groupInfo");
134+
const gchar *groupid_str = NULL;
135+
const gchar *groupname = NULL;
136+
if (obj) {
137+
groupid_str = json_object_get_string_member(obj, "groupId");
138+
groupname = json_object_get_string_member(obj, "name");
139+
}
140+
signald_process_message(sa, username, message, timestamp_str, groupid_str, groupname);
130141
}
131142
} else {
132143
purple_debug_error("signald", "Ignored message of unknown type.\n");
@@ -297,7 +308,7 @@ signald_send_im(PurpleConnection *pc,
297308
JsonObject *data = json_object_new();
298309
json_object_set_string_member(data, "type", "send");
299310
json_object_set_string_member(data, "username", purple_account_get_username(sa->account));
300-
json_object_set_string_member(data, "recipientNumber", who);
311+
json_object_set_string_member(data, who[0]=='+' ? "recipientNumber" : "recipientGroupId", who);
301312
json_object_set_string_member(data, "messageBody", message);
302313
char *json = json_object_to_string(data);
303314
char *jsonn = append_newline(json);

0 commit comments

Comments
 (0)