Mon, 30 Jun 2025 20:44:05 -0500
Prepare for the 2.92.0 release
Testing Done:
Ran `meson dist`
Reviewed at https://reviews.imfreedom.org/r/4039/
|
43057
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * Purple is the legal property of its developers, whose names are too numerous |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * source distribution. |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * This library is free software; you can redistribute it and/or modify it |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * under the terms of the GNU General Public License as published by the Free |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * Software Foundation; either version 2 of the License, or (at your option) |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * any later version. |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * This library is distributed in the hope that it will be useful, but WITHOUT |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * more details. |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License along with |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | * this library; if not, see <https://www.gnu.org/licenses/>. |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | #include "purplecommands.h" |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include "purpleconversation.h" |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | #include "purplemessage.h" |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | /****************************************************************************** |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | * Helpers |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | *****************************************************************************/ |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | static PurpleMessage * |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | purple_message_from_command(PurpleConversation *conversation, GStrv params) { |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | PurpleAccount *account = NULL; |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | PurpleContactInfo *info = NULL; |
|
43100
e6df74d36862
Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
43057
diff
changeset
|
37 | PurpleConversationMember *member = NULL; |
|
e6df74d36862
Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
43057
diff
changeset
|
38 | PurpleConversationMembers *members = NULL; |
|
43057
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | PurpleMessage *message = NULL; |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | char *body = NULL; |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | account = purple_conversation_get_account(conversation); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | if(!PURPLE_IS_ACCOUNT(account)) { |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | return NULL; |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | } |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | |
|
43100
e6df74d36862
Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
43057
diff
changeset
|
47 | members = purple_conversation_get_members(conversation); |
|
e6df74d36862
Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
43057
diff
changeset
|
48 | |
|
43057
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | info = purple_account_get_contact_info(account); |
|
43100
e6df74d36862
Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
43057
diff
changeset
|
50 | member = purple_conversation_members_find_member(members, info); |
|
43057
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | body = g_strjoinv(" ", params); |
|
43100
e6df74d36862
Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
43057
diff
changeset
|
53 | message = purple_message_new(member, body); |
|
43057
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | g_free(body); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | return message; |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | } |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | /****************************************************************************** |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | * Action Command |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | *****************************************************************************/ |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | static void |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | purple_action_command_executed(G_GNUC_UNUSED PurpleCommand *command, |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | PurpleConversation *conversation, |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | GStrv params, |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | G_GNUC_UNUSED gpointer data) |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | { |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | PurpleMessage *message = NULL; |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | message = purple_message_from_command(conversation, params); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | if(PURPLE_IS_MESSAGE(message)) { |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | purple_message_set_action(message, TRUE); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | purple_conversation_send_message_async(conversation, message, NULL, |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | NULL, NULL); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | } |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | g_clear_object(&message); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | } |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | PurpleCommand * |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | purple_action_command_new(void) { |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | PurpleCommand *command = NULL; |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | command = purple_command_new("action", "libpurple", 0); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | purple_command_set_summary(command, _("Sends a message as an action")); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | g_signal_connect(command, "executed", |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | G_CALLBACK(purple_action_command_executed), NULL); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | return command; |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | } |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | /****************************************************************************** |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | * Say Command |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | *****************************************************************************/ |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | static void |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | purple_say_command_executed(G_GNUC_UNUSED PurpleCommand *command, |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | PurpleConversation *conversation, |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | GStrv params, |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | G_GNUC_UNUSED gpointer data) |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | { |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | PurpleMessage *message = NULL; |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | message = purple_message_from_command(conversation, params); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | if(PURPLE_IS_MESSAGE(message)) { |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | purple_conversation_send_message_async(conversation, message, NULL, |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | NULL, NULL); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | } |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | g_clear_object(&message); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | } |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | PurpleCommand * |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | purple_say_command_new(void) { |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | PurpleCommand *command = NULL; |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | command = purple_command_new("say", "libpurple", 0); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | purple_command_set_summary(command, _("Sends a message")); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | g_signal_connect(command, "executed", |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | G_CALLBACK(purple_say_command_executed), NULL); |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | return command; |
|
2c801eae5449
Add commands for say and action
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | } |