Thu, 07 Aug 2025 21:32:18 -0500
Clean up and modernize PurpleImage
Testing Done:
Ran the tests under valgrind and called in the turtles.
Reviewed at https://reviews.imfreedom.org/r/4074/
| 42964 | 1 | /* |
| 2 | * Purple - Internet Messaging Library | |
| 3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> | |
| 4 | * | |
| 5 | * Purple is the legal property of its developers, whose names are too numerous | |
| 6 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 7 | * source distribution. | |
| 8 | * | |
| 9 | * This library is free software; you can redistribute it and/or modify it | |
| 10 | * under the terms of the GNU General Public License as published by the Free | |
| 11 | * Software Foundation; either version 2 of the License, or (at your option) | |
| 12 | * any later version. | |
| 13 | * | |
| 14 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
| 17 | * more details. | |
| 18 | * | |
| 19 | * You should have received a copy of the GNU General Public License along with | |
| 20 | * this library; if not, see <https://www.gnu.org/licenses/>. | |
| 21 | */ | |
| 22 | ||
| 23 | #if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION) | |
| 24 | # error "only <purple.h> may be included directly" | |
| 25 | #endif | |
| 26 | ||
| 27 | #ifndef PURPLE_COMMAND_H | |
| 28 | #define PURPLE_COMMAND_H | |
| 29 | ||
| 30 | #include <glib.h> | |
| 31 | #include <glib-object.h> | |
| 32 | ||
| 33 | #include "purpleconversation.h" | |
|
42967
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
34 | #include "purpletags.h" |
| 42964 | 35 | #include "purpleversion.h" |
| 36 | ||
| 37 | G_BEGIN_DECLS | |
| 38 | ||
| 39 | /** | |
| 40 | * PurpleCommand: | |
| 41 | * | |
| 42 | * An object that represents a command. | |
| 43 | * | |
|
43068
a974441beed0
Add an overview on how commands work
Gary Kramlich <grim@reaperworld.com>
parents:
43053
diff
changeset
|
44 | * See the [Commands Overview](section-commands.html) for more information. |
|
a974441beed0
Add an overview on how commands work
Gary Kramlich <grim@reaperworld.com>
parents:
43053
diff
changeset
|
45 | * |
| 42964 | 46 | * Since: 3.0 |
| 47 | */ | |
| 48 | ||
| 49 | #define PURPLE_TYPE_COMMAND (purple_command_get_type()) | |
| 50 | ||
| 51 | PURPLE_AVAILABLE_IN_3_0 | |
| 52 | G_DECLARE_FINAL_TYPE(PurpleCommand, purple_command, PURPLE, COMMAND, GObject) | |
| 53 | ||
| 54 | /** | |
| 55 | * purple_command_execute: | |
| 56 | * @command: The instance. | |
| 57 | * @conversation: (nullable): The conversation where the command was run. | |
| 58 | * @params: (nullable): The parameters for the command. | |
| 59 | * | |
| 60 | * Emits the [signal@Command::executed] signal. | |
| 61 | * | |
| 62 | * User interfaces should call this method when the user wants to execute the | |
| 63 | * command. | |
| 64 | * | |
| 65 | * Since: 3.0 | |
| 66 | */ | |
| 67 | PURPLE_AVAILABLE_IN_3_0 | |
| 68 | void purple_command_execute(PurpleCommand *command, PurpleConversation *conversation, const char *params); | |
| 69 | ||
| 70 | /** | |
| 71 | * purple_command_executev: | |
| 72 | * @command: The instance. | |
| 73 | * @conversation: (nullable): The conversation where the command was run. | |
| 74 | * @params: (nullable): The parameters for the command. | |
| 75 | * | |
| 76 | * Emits the [signal@Command::executed] signal. | |
| 77 | * | |
| 78 | * User interfaces should call this method when the user wants to execute the | |
| 79 | * command. | |
| 80 | * | |
| 81 | * Since: 3.0 | |
| 82 | */ | |
| 83 | PURPLE_AVAILABLE_IN_3_0 | |
| 84 | void purple_command_executev(PurpleCommand *command, PurpleConversation *conversation, GStrv params); | |
| 85 | ||
| 86 | /** | |
| 87 | * purple_command_get_icon_name: | |
| 88 | * @command: The instance. | |
| 89 | * | |
| 90 | * Gets the icon name of @command. | |
| 91 | * | |
| 92 | * Returns: (transfer none) (nullable): The icon-name if set, otherwise %NULL. | |
| 93 | * | |
| 94 | * Since: 3.0 | |
| 95 | */ | |
| 96 | PURPLE_AVAILABLE_IN_3_0 | |
| 97 | const char *purple_command_get_icon_name(PurpleCommand *command); | |
| 98 | ||
| 99 | /** | |
| 100 | * purple_command_get_last_used: | |
| 101 | * @command: The instance. | |
| 102 | * | |
| 103 | * Gets the last used date time of @command. | |
| 104 | * | |
| 105 | * Returns: (nullable): The time that @command was last used or %NULL. | |
| 106 | * | |
| 107 | * Since: 3.0 | |
| 108 | */ | |
| 109 | PURPLE_AVAILABLE_IN_3_0 | |
| 110 | GDateTime *purple_command_get_last_used(PurpleCommand *command); | |
| 111 | ||
| 112 | /** | |
| 113 | * purple_command_get_name: | |
| 114 | * @command: The instance. | |
| 115 | * | |
| 116 | * Gets the name of the command. | |
| 117 | * | |
| 118 | * Returns: The name of @command. | |
| 119 | * | |
| 120 | * Since: 3.0 | |
| 121 | */ | |
| 122 | PURPLE_AVAILABLE_IN_3_0 | |
| 123 | const char *purple_command_get_name(PurpleCommand *command); | |
| 124 | ||
| 125 | /** | |
| 126 | * purple_command_get_priority: | |
| 127 | * @command: The instance. | |
| 128 | * | |
| 129 | * Gets the priority of @command. | |
| 130 | * | |
| 131 | * Returns: The priority. | |
| 132 | * | |
| 133 | * Since: 3.0 | |
| 134 | */ | |
| 135 | PURPLE_AVAILABLE_IN_3_0 | |
| 136 | int purple_command_get_priority(PurpleCommand *command); | |
| 137 | ||
| 138 | /** | |
| 139 | * purple_command_get_source: | |
| 140 | * @command: The instance. | |
| 141 | * | |
| 142 | * Gets the source of @command. | |
| 143 | * | |
| 144 | * When presenting commands to the user, this value can be used to help them | |
| 145 | * determine where the command came from. | |
| 146 | * | |
| 147 | * Returns: The source. | |
| 148 | * | |
| 149 | * Since: 3.0 | |
| 150 | */ | |
| 151 | PURPLE_AVAILABLE_IN_3_0 | |
| 152 | const char *purple_command_get_source(PurpleCommand *command); | |
| 153 | ||
| 154 | /** | |
| 155 | * purple_command_get_summary: | |
| 156 | * @command: The instance. | |
| 157 | * | |
| 158 | * Gets the summary of @command. | |
| 159 | * | |
| 160 | * When presenting commands to the user, this value can be used to help them | |
| 161 | * determine exactly what this command will do. | |
| 162 | * | |
| 163 | * Returns: The summary. | |
| 164 | * | |
| 165 | * Since: 3.0 | |
| 166 | */ | |
| 167 | PURPLE_AVAILABLE_IN_3_0 | |
| 168 | const char *purple_command_get_summary(PurpleCommand *command); | |
| 169 | ||
| 170 | /** | |
|
42967
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
171 | * purple_command_get_tags: |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
172 | * @command: The instance. |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
173 | * |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
174 | * Gets the [class@Tags] from @command. |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
175 | * |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
176 | * These tags will be matched against [property@Conversation:tags] using |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
177 | * [method@Tags.contains] to determine if command is available for a |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
178 | * [class@Conversation]. |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
179 | * |
|
43053
f2f944ac775c
Implement Purple.CommandManager
Gary Kramlich <grim@reaperworld.com>
parents:
42967
diff
changeset
|
180 | * If this is empty, it will match all conversations. |
|
f2f944ac775c
Implement Purple.CommandManager
Gary Kramlich <grim@reaperworld.com>
parents:
42967
diff
changeset
|
181 | * |
|
42967
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
182 | * Returns: (transfer none): The tags object. |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
183 | * |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
184 | * Since: 3.0 |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
185 | */ |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
186 | PURPLE_AVAILABLE_IN_3_0 |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
187 | PurpleTags *purple_command_get_tags(PurpleCommand *command); |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
188 | |
|
9da19bb7e207
Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
42964
diff
changeset
|
189 | /** |
| 42964 | 190 | * purple_command_get_use_count: |
| 191 | * @command: The instance. | |
| 192 | * | |
| 193 | * Gets the use count of @command. | |
| 194 | * | |
| 195 | * Returns: The use count of @command. | |
| 196 | * | |
| 197 | * Since: 3.0 | |
| 198 | */ | |
| 199 | PURPLE_AVAILABLE_IN_3_0 | |
| 200 | guint purple_command_get_use_count(PurpleCommand *command); | |
| 201 | ||
| 202 | /** | |
| 203 | * purple_command_new: | |
| 204 | * @name: The name of the command. | |
| 205 | * @source: The source of the command. This will be displayed to users and | |
| 206 | * should be marked for translation. | |
| 207 | * @priority: The priority of the command. | |
| 208 | * | |
| 209 | * Creates a new command with the given properties. | |
| 210 | * | |
| 211 | * Returns: (transfer full): The new command. | |
| 212 | * | |
| 213 | * Since: 3.0 | |
| 214 | */ | |
| 215 | PURPLE_AVAILABLE_IN_3_0 | |
| 216 | PurpleCommand *purple_command_new(const char *name, const char *source, int priority); | |
| 217 | ||
| 218 | /** | |
| 219 | * purple_command_set_icon_name: | |
| 220 | * @command: The instance. | |
| 221 | * @icon_name: (nullable): The new icon name. | |
| 222 | * | |
| 223 | * Sets the icon name of @command to @icon_name. | |
| 224 | * | |
| 225 | * Since: 3.0 | |
| 226 | */ | |
| 227 | PURPLE_AVAILABLE_IN_3_0 | |
| 228 | void purple_command_set_icon_name(PurpleCommand *command, const char *icon_name); | |
| 229 | ||
| 230 | /** | |
| 231 | * purple_command_set_last_used: | |
| 232 | * @command: The instance. | |
| 233 | * @last_used: (nullable): The new last used time stamp. | |
| 234 | * | |
| 235 | * Sets the last used time of @command to @last_used. | |
| 236 | * | |
| 237 | * Typically this won't need to be called as the default handler for | |
| 238 | * [signal@Command::executed] will set it. | |
| 239 | * | |
| 240 | * Since: 3.0 | |
| 241 | */ | |
| 242 | PURPLE_AVAILABLE_IN_3_0 | |
| 243 | void purple_command_set_last_used(PurpleCommand *command, GDateTime *last_used); | |
| 244 | ||
| 245 | /** | |
| 246 | * purple_command_set_summary: | |
| 247 | * @command: The instance. | |
| 248 | * @summary: (nullable): The new summary. | |
| 249 | * | |
| 250 | * Sets the summary of @command to @summary. | |
| 251 | * | |
| 252 | * Since: 3.0 | |
| 253 | */ | |
| 254 | PURPLE_AVAILABLE_IN_3_0 | |
| 255 | void purple_command_set_summary(PurpleCommand *command, const char *summary); | |
| 256 | ||
| 257 | /** | |
| 258 | * purple_command_set_use_count: | |
| 259 | * @command: The instance. | |
| 260 | * @use_count: The new use count. | |
| 261 | * | |
| 262 | * Sets the use count of @command to @use_count. | |
| 263 | * | |
| 264 | * Typically this won't need to be called directly as the default handler for | |
| 265 | * [signal@Command::executed] will increment it. | |
| 266 | * | |
| 267 | * Since: 3.0 | |
| 268 | */ | |
| 269 | PURPLE_AVAILABLE_IN_3_0 | |
| 270 | void purple_command_set_use_count(PurpleCommand *command, guint use_count); | |
| 271 | ||
| 272 | G_END_DECLS | |
| 273 | ||
| 274 | #endif /* PURPLE_COMMAND_H */ |