Port to KTp::Actions
REVIEW: 107403
Dan Vrátil
11 years ago
42 | 42 | #include <KTp/Models/contact-model-item.h> |
43 | 43 | #include <KTp/presence.h> |
44 | 44 | #include <KTp/global-presence.h> |
45 | #include <KTp/actions.h> | |
45 | 46 | |
46 | 47 | struct MatchInfo { |
47 | 48 | Tp::AccountPtr account; |
225 | 226 | Tp::AccountPtr account = data.account; |
226 | 227 | Tp::ContactPtr contact = data.contact; |
227 | 228 | |
228 | Tp::ChannelRequestHints hints; | |
229 | hints.setHint(QLatin1String("org.freedesktop.Telepathy.ChannelRequest"), | |
230 | QLatin1String("DelegateToPreferredHandler"), | |
231 | QVariant(true)); | |
232 | ||
233 | 229 | if (match.selectedAction() == action(QLatin1String("start-text-chat"))) { |
234 | ||
235 | account->ensureTextChat(contact, | |
236 | QDateTime::currentDateTime(), | |
237 | QLatin1String("org.freedesktop.Telepathy.Client.KTp.TextUi"), | |
238 | hints); | |
239 | ||
230 | KTp::Actions::startChat(account, contact); | |
240 | 231 | } else if (match.selectedAction() == action(QLatin1String("start-audio-call"))) { |
241 | ||
242 | account->ensureAudioCall(contact, | |
243 | QLatin1String("audio"), | |
244 | QDateTime::currentDateTime(), | |
245 | QLatin1String("org.freedesktop.Telepathy.Client.KTp.CallUi")); | |
246 | ||
232 | KTp::Actions::startAudioCall(account, contact); | |
247 | 233 | } else if (match.selectedAction() == action("start-video-call")) { |
248 | ||
249 | account->ensureAudioVideoCall(contact, | |
250 | QLatin1String("audio"), QLatin1String("video"), | |
251 | QDateTime::currentDateTime(), | |
252 | QLatin1String("org.freedesktop.Telepathy.Client.KTp.CallUi")); | |
253 | ||
234 | KTp::Actions::startAudioVideoCall(account, contact); | |
254 | 235 | } else if (match.selectedAction() == action("start-file-transfer")) { |
255 | 236 | |
256 | QStringList filenames = KFileDialog::getOpenFileNames( | |
237 | QStringList filenames = KFileDialog::getOpenFileNames( | |
257 | 238 | KUrl("kfiledialog:///FileTransferLastDirectory"), |
258 | 239 | QString(), |
259 | 240 | 0, |
264 | 245 | } |
265 | 246 | |
266 | 247 | Q_FOREACH (const QString &filename, filenames) { |
267 | Tp::FileTransferChannelCreationProperties properties( | |
268 | filename, KMimeType::findByFileContent(filename)->name()); | |
269 | ||
270 | account->createFileTransfer(contact, | |
271 | properties, | |
272 | QDateTime::currentDateTime(), | |
273 | QLatin1String("org.freedesktop.Telepathy.Client.KTp.FileTransfer")); | |
248 | KTp::Actions::startFileTransfer(account, contact, filename); | |
274 | 249 | } |
275 | 250 | |
276 | 251 | } else if (match.selectedAction() == action("start-desktop-sharing")) { |
277 | ||
278 | account->createStreamTube(contact, | |
279 | QLatin1String("rfb"), | |
280 | QDateTime::currentDateTime(), | |
281 | QLatin1String("org.freedesktop.Telepathy.Client.krfb_rfb_handler")); | |
282 | ||
252 | KTp::Actions::startDesktopSharing(account, contact); | |
283 | 253 | } else if (match.selectedAction() == action(QLatin1String("show-log-viewer"))) { |
284 | ||
285 | /* Use "--" so that KCmdLineArgs does not try to parse UIDs starting with "-" as arguments */ | |
286 | KToolInvocation::kdeinitExec(QLatin1String("ktp-log-viewer"), | |
287 | QStringList() << QLatin1String("--") << account->uniqueIdentifier() << contact->id()); | |
288 | ||
254 | KTp::Actions::openLogViewer(account, contact); | |
289 | 255 | } |
290 | 256 | } |
291 | 257 |