Sun, 09 Nov 2008 20:55:10 +0000
Added menu items to buddy list context menu to start voice and video sessions
After discussing the matter with Maiku, we decided to have two choises.
"Audio call" which will show up if audio sessions is possible with a buddy and
the other item is either "Audio/Video" or "Video" depending on if the buddy
supports both at the same time or not
| 11907 | 1 | /* |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
2 | * pidgin |
| 11907 | 3 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
4 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 11907 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17129
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 11907 | 21 | * |
| 22 | */ | |
| 23 | #include "internal.h" | |
|
12410
98d8abd3db98
[gaim-migrate @ 14717]
Richard Laager <rlaager@pidgin.im>
parents:
12278
diff
changeset
|
24 | #include "gtkidle.h" |
| 11907 | 25 | |
|
13324
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
26 | #ifdef HAVE_IOKIT |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
27 | # include <CoreFoundation/CoreFoundation.h> |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
28 | # include <IOKit/IOKitLib.h> |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
29 | #else |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
30 | # ifdef USE_SCREENSAVER |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
31 | # ifdef _WIN32 |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
32 | # include "idletrack.h" |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
33 | # else |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
34 | /* We're on X11 and not MacOS X with IOKit. */ |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
35 | # include <X11/Xlib.h> |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
36 | # include <X11/Xutil.h> |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
37 | # include <X11/extensions/scrnsaver.h> |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
38 | # include <gdk/gdkx.h> |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
39 | # endif /* !_WIN32 */ |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
40 | # endif /* USE_SCREENSAVER */ |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
41 | #endif /* !HAVE_IOKIT */ |
| 11907 | 42 | |
|
12272
4eee92ead973
[gaim-migrate @ 14574]
Mark Doliner <markdoliner@pidgin.im>
parents:
12252
diff
changeset
|
43 | #include "idle.h" |
| 11907 | 44 | |
| 45 | /** | |
| 46 | * Get the number of seconds the user has been idle. In Unix-world | |
|
13324
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
47 | * this is based on the X Windows usage. In MS Windows this is |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
48 | * based on keyboard/mouse usage information obtained from the OS. |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
49 | * In MacOS X, this is based on keyboard/mouse usage information |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
50 | * obtained from the OS, if configure detected IOKit. Otherwise, |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
51 | * MacOS X is handled as a case of X Windows. |
| 11907 | 52 | * |
| 53 | * In Debian bug #271639, jwz says: | |
| 54 | * | |
| 15884 | 55 | * Purple should simply ask xscreensaver how long the user has been idle: |
| 11907 | 56 | * % xscreensaver-command -time |
| 57 | * XScreenSaver 4.18: screen blanked since Tue Sep 14 14:10:45 2004 | |
| 58 | * | |
| 59 | * Or you can monitor the _SCREENSAVER_STATUS property on root window #0. | |
| 60 | * Element 0 is the status (0, BLANK, LOCK), element 1 is the time_t since | |
| 61 | * the last state change, and subsequent elements are which hack is running | |
| 62 | * on the various screens: | |
| 63 | * % xprop -f _SCREENSAVER_STATUS 32ac -root _SCREENSAVER_STATUS | |
| 64 | * _SCREENSAVER_STATUS(INTEGER) = BLANK, 1095196626, 10, 237 | |
| 65 | * | |
| 66 | * See watch() in xscreensaver/driver/xscreensaver-command.c. | |
| 67 | * | |
| 68 | * @return The number of seconds the user has been idle. | |
| 69 | */ | |
|
13324
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
70 | #if defined(USE_SCREENSAVER) || defined(HAVE_IOKIT) |
|
12272
4eee92ead973
[gaim-migrate @ 14574]
Mark Doliner <markdoliner@pidgin.im>
parents:
12252
diff
changeset
|
71 | static time_t |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
72 | pidgin_get_time_idle(void) |
| 11907 | 73 | { |
|
13324
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
74 | # ifdef HAVE_IOKIT |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
75 | /* Query the IOKit API */ |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
76 | |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
77 | static io_service_t macIOsrvc = NULL; |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
78 | CFTypeRef property; |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
79 | uint64_t idle_time = 0; /* nanoseconds */ |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
80 | |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
81 | if (macIOsrvc == NULL) |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
82 | { |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
83 | mach_port_t master; |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
84 | IOMasterPort(MACH_PORT_NULL, &master); |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
85 | macIOsrvc = IOServiceGetMatchingService(master, |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
86 | IOServiceMatching("IOHIDSystem")); |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
87 | } |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
88 | |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
89 | property = IORegistryEntryCreateCFProperty(macIOsrvc, CFSTR("HIDIdleTime"), |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
90 | kCFAllocatorDefault, 0); |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
91 | CFNumberGetValue((CFNumberRef)property, |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
92 | kCFNumberSInt64Type, &idle_time); |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
93 | CFRelease(property); |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
94 | |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
95 | /* convert nanoseconds to seconds */ |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
96 | return idle_time / 1000000000; |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
97 | # else |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
98 | # ifdef _WIN32 |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
99 | /* Query Windows */ |
|
15574
18d9d1c05994
Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents:
15562
diff
changeset
|
100 | return (GetTickCount() - winpidgin_get_lastactive()) / 1000; |
|
13324
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
101 | # else |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
102 | /* We're on X11 and not MacOS X with IOKit. */ |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
103 | |
|
12272
4eee92ead973
[gaim-migrate @ 14574]
Mark Doliner <markdoliner@pidgin.im>
parents:
12252
diff
changeset
|
104 | /* Query xscreensaver */ |
| 11907 | 105 | static XScreenSaverInfo *mit_info = NULL; |
| 17129 | 106 | static int has_extension = -1; |
| 11907 | 107 | int event_base, error_base; |
| 17129 | 108 | |
| 109 | if (has_extension == -1) | |
| 110 | has_extension = XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base); | |
| 111 | ||
| 112 | if (has_extension) | |
| 113 | { | |
| 114 | if (mit_info == NULL) | |
| 11907 | 115 | mit_info = XScreenSaverAllocInfo(); |
| 17129 | 116 | |
| 11907 | 117 | XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info); |
| 118 | return (mit_info->idle) / 1000; | |
| 17129 | 119 | } |
| 120 | else | |
| 11907 | 121 | return 0; |
|
13324
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
122 | # endif /* !_WIN32 */ |
|
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
123 | # endif /* !HAVE_IOKIT */ |
|
12278
21bcbadf956d
[gaim-migrate @ 14582]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12272
diff
changeset
|
124 | } |
|
13324
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
125 | #endif /* USE_SCREENSAVER || HAVE_IOKIT */ |
| 11907 | 126 | |
| 15884 | 127 | static PurpleIdleUiOps ui_ops = |
| 11907 | 128 | { |
|
13324
8ff1c408ef3e
[gaim-migrate @ 15693]
Richard Laager <rlaager@pidgin.im>
parents:
12410
diff
changeset
|
129 | #if defined(USE_SCREENSAVER) || defined(HAVE_IOKIT) |
|
16752
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
15931
diff
changeset
|
130 | pidgin_get_time_idle, |
|
12278
21bcbadf956d
[gaim-migrate @ 14582]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12272
diff
changeset
|
131 | #else |
|
16752
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
15931
diff
changeset
|
132 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
15931
diff
changeset
|
133 | #endif /* USE_SCREENSAVER || HAVE_IOKIT */ |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
15931
diff
changeset
|
134 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
15931
diff
changeset
|
135 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
15931
diff
changeset
|
136 | NULL, |
|
12278
21bcbadf956d
[gaim-migrate @ 14582]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12272
diff
changeset
|
137 | NULL |
|
12272
4eee92ead973
[gaim-migrate @ 14574]
Mark Doliner <markdoliner@pidgin.im>
parents:
12252
diff
changeset
|
138 | }; |
| 11907 | 139 | |
| 15884 | 140 | PurpleIdleUiOps * |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
141 | pidgin_idle_get_ui_ops() |
| 11907 | 142 | { |
|
12272
4eee92ead973
[gaim-migrate @ 14574]
Mark Doliner <markdoliner@pidgin.im>
parents:
12252
diff
changeset
|
143 | return &ui_ops; |
| 11907 | 144 | } |