| |
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 program is free software; you can redistribute it and/or modify |
| |
10 * it under the terms of the GNU General Public License as published by |
| |
11 * the Free Software Foundation; either version 2 of the License, or |
| |
12 * (at your option) any later version. |
| |
13 * |
| |
14 * This program is distributed in the hope that it will be useful, |
| |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| |
17 * GNU General Public License for more details. |
| |
18 * |
| |
19 * You should have received a copy of the GNU General Public License |
| |
20 * along with this program; 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_IDLE_MANAGER_H |
| |
28 #define PURPLE_IDLE_MANAGER_H |
| |
29 |
| |
30 #include <glib.h> |
| |
31 #include <glib-object.h> |
| |
32 |
| |
33 #define PURPLE_TYPE_IDLE_MANAGER (purple_idle_manager_get_type()) |
| |
34 G_DECLARE_FINAL_TYPE(PurpleIdleManager, purple_idle_manager, PURPLE, |
| |
35 IDLE_MANAGER, GObject) |
| |
36 |
| |
37 /** |
| |
38 * PurpleIdleManager: |
| |
39 * |
| |
40 * The idle manager keeps track of multiple idle sources and aggregates them |
| |
41 * to the oldest one to report a global idle state. |
| |
42 * |
| |
43 * Idle sources include application usage, device usage, or a manually set |
| |
44 * value, among other possibilities. User interfaces should allow users to |
| |
45 * determine what if any idle sources are tracked in the idle manager. |
| |
46 * |
| |
47 * The idle source with the oldest timestamp is used as the value for |
| |
48 * [property@IdleManager:timestamp] as it is most likely what the user is |
| |
49 * looking for based on the settings they would choose in the user interface. |
| |
50 * |
| |
51 * Most users will only ever have a single idle source, but could add an |
| |
52 * additional manual source to set a specific time that they went idle. |
| |
53 * |
| |
54 * If the user has chosen no idle reporting, which means no sources are ever |
| |
55 * added to [class@IdleManager], then [property@IdleManager:timestamp] will |
| |
56 * always be %NULL. |
| |
57 * |
| |
58 * Most users will choose between application and device usage. The difference |
| |
59 * being that application usage is updated whenever you send a message whereas |
| |
60 * device usage is only updated when you haven't interacted with your device. |
| |
61 * |
| |
62 * However, there is also the ability to manually set an idle time via plugins. |
| |
63 * Typically users will manually set their idle time to something exaggerated |
| |
64 * like months or years. |
| |
65 * |
| |
66 * A manual idle source could also be created to replicate an existing idle |
| |
67 * source like the application usage, so that the user can start using the |
| |
68 * application without resetting the idle time. This would in effect allow the |
| |
69 * user to use the application in "stealth mode" by remaining idle. |
| |
70 * |
| |
71 * In both of these examples, the user wishes to remain idle while still using |
| |
72 * the application. This is precisely why the oldest idle time is used as the |
| |
73 * aggregate. |
| |
74 * |
| |
75 * Since: 3.0.0 |
| |
76 */ |
| |
77 |
| |
78 G_BEGIN_DECLS |
| |
79 |
| |
80 /** |
| |
81 * purple_idle_manager_get_default: |
| |
82 * |
| |
83 * Gets the default idle manager that libpurple is using. |
| |
84 * |
| |
85 * Returns: (transfer none): The default idle manager. |
| |
86 * |
| |
87 * Since: 3.0.0 |
| |
88 */ |
| |
89 PurpleIdleManager *purple_idle_manager_get_default(void); |
| |
90 |
| |
91 /** |
| |
92 * purple_idle_manager_set_source: |
| |
93 * @manager: The instance. |
| |
94 * @source: The name of the source. |
| |
95 * @timestamp: (nullable): The new timestamp for @source. |
| |
96 * |
| |
97 * Sets the timestamp of when @source went idle to @timestamp. If @timestamp is |
| |
98 * %NULL, @source will be removed from @manager. |
| |
99 * |
| |
100 * Returns: %TRUE if [property@IdleManager:timestamp] has changed due to this |
| |
101 * call. |
| |
102 * |
| |
103 * Since: 3.0.0 |
| |
104 */ |
| |
105 gboolean purple_idle_manager_set_source(PurpleIdleManager *manager, const char *source, GDateTime *timestamp); |
| |
106 |
| |
107 /** |
| |
108 * purple_idle_manager_get_timestamp: |
| |
109 * @manager: The instance. |
| |
110 * |
| |
111 * Gets the oldest timestamp of all the sources that @manager knows about. |
| |
112 * |
| |
113 * Returns: (transfer none) (nullable): The oldest timestamp or %NULL if no |
| |
114 * sources are idle. |
| |
115 * |
| |
116 * Since: 3.0.0 |
| |
117 */ |
| |
118 GDateTime *purple_idle_manager_get_timestamp(PurpleIdleManager *manager); |
| |
119 |
| |
120 G_END_DECLS |
| |
121 |
| |
122 #endif /* PURPLE_IDLE_MANAGER_H */ |