Imported Upstream version 15.04.0
Maximiliano Curia
8 years ago
0 | REVIEWBOARD_URL = "https://git.reviewboard.kde.org" | |
1 | REPOSITORY = 'git://anongit.kde.org/ktp-contact-runner' |
0 | 0 | project(KTPContactRunner) |
1 | 1 | |
2 | set(KTP_CONTACT_RUNNER_VERSION "0.8.80") | |
2 | cmake_minimum_required(VERSION 2.8.12) | |
3 | ||
4 | set(KTP_CONTACT_RUNNER_VERSION "15.04.0") | |
3 | 5 | set(IS_KTP_INTERNAL_MODULE TRUE) |
4 | 6 | |
5 | set(CMAKE_MODULE_PATH | |
6 | ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules | |
7 | ${CMAKE_MODULE_PATH}) | |
7 | find_package(ECM 1.0.0 REQUIRED NO_MODULE) | |
8 | set (CMAKE_MODULE_PATH | |
9 | ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH} | |
10 | ) | |
8 | 11 | cmake_policy(SET CMP0002 OLD) |
9 | 12 | |
10 | 13 | # Find the required Libaries |
11 | find_package(KDE4 REQUIRED) | |
12 | find_package(TelepathyQt4 0.9.1 REQUIRED) | |
13 | find_package(KTp REQUIRED) | |
14 | include(KDE4Defaults) | |
14 | find_package (Qt5 REQUIRED CONFIG COMPONENTS Widgets Core DBus Network) | |
15 | find_package (KF5 REQUIRED COMPONENTS I18n Service Runner) | |
16 | find_package (KTp REQUIRED) | |
15 | 17 | |
18 | include(KDEInstallDirs) | |
19 | include(KDECMakeSettings) | |
20 | include(KDECompilerSettings) | |
21 | include(FeatureSummary) | |
16 | 22 | |
17 | add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) | |
18 | 23 | include_directories( |
19 | 24 | ${CMAKE_SOURCE_DIR} |
20 | 25 | ${CMAKE_BINARY_DIR} |
21 | ${KDE4_INCLUDES} | |
22 | ${TELEPATHY_QT4_INCLUDE_DIR} | |
23 | ${KTP_INCLUDE_DIR} | |
24 | 26 | ) |
25 | 27 | |
26 | 28 | # We add our source code here |
27 | 29 | set(runner_SRCS src/contactrunner.cpp) |
28 | 30 | |
29 | kde4_add_plugin(krunner_ktp_contacts ${runner_SRCS}) | |
31 | add_library(krunner_ktp_contacts MODULE ${runner_SRCS}) | |
30 | 32 | target_link_libraries(krunner_ktp_contacts |
31 | ${KDE4_PLASMA_LIBS} | |
32 | ${KDE4_KIO_LIBS} | |
33 | ${TELEPATHY_QT4_LIBRARIES} | |
34 | ${KTP_MODELS_LIBRARIES} | |
35 | ${KTP_LIBRARIES}) | |
33 | Qt5::Widgets | |
34 | KF5::I18n | |
35 | KF5::Service | |
36 | KF5::Runner | |
37 | KTp::Models | |
38 | KTp::CommonInternals) | |
36 | 39 | |
37 | 40 | install(TARGETS krunner_ktp_contacts |
38 | 41 | DESTINATION ${PLUGIN_INSTALL_DIR}) |
45 | 48 | DESTINATION ${SERVICES_INSTALL_DIR} |
46 | 49 | ) |
47 | 50 | |
48 | find_package(Msgfmt REQUIRED) | |
49 | find_package(Gettext REQUIRED) | |
50 | add_subdirectory( po ) |
0 | 0 | [Desktop Entry] |
1 | 1 | Name=Instant Messaging |
2 | Name[ast]=Mensaxería nel intre | |
2 | 3 | Name[bs]=Brze poruke |
3 | 4 | Name[ca]=Missatgeria instantània |
4 | 5 | Name[ca@valencia]=Missatgeria instantània |
52 | 53 | Comment[es]=Iniciar una conversación con cualquiera de sus contactos de MI o cambiar su estado de MI |
53 | 54 | Comment[et]=Vestluse alustamine mõne oma kiirsuhtluskontaktiga või enda kiirsuhtlusoleku muutmine |
54 | 55 | Comment[fi]=Aloita keskustelu muun pikaviestinkäyttäjän kanssa tai vaihda pikaviestintilaasi |
55 | Comment[fr]=Démarre une discussion avec n'importe lequel de vos contacts de messagerie instantanée ou change l'état de celle-ci | |
56 | Comment[fr]=Démarre une conversation avec n'importe lequel de vos contacts de messagerie instantanée ou change l'état de celle-ci | |
56 | 57 | Comment[gl]=Inicie unha conversa con calquera dos seus contactos ou cambie seu estado na IM |
57 | 58 | Comment[hu]=Csevegés indítása az azonnali üzenetküldési partnerei valamelyikével vagy az azonnali üzenetküldési állapotának módosítása |
58 | 59 | Comment[ia]=Initia conversation con qualcunque de tu contactos de IM o modifica tu status de IM |
18 | 18 | |
19 | 19 | #include "contactrunner.h" |
20 | 20 | |
21 | #include <KDebug> | |
22 | #include <KFileDialog> | |
23 | #include <KMimeType> | |
24 | #include <KToolInvocation> | |
25 | #include <KStandardDirs> | |
21 | #include <QDebug> | |
22 | #include <QFileDialog> | |
23 | #include <QStandardPaths> | |
24 | ||
25 | #include <KLocalizedString> | |
26 | 26 | |
27 | 27 | #include <TelepathyQt/ContactManager> |
28 | 28 | #include <TelepathyQt/Contact> |
43 | 43 | #include <KTp/contact-factory.h> |
44 | 44 | #include <KTp/contact.h> |
45 | 45 | |
46 | Q_LOGGING_CATEGORY(KTP_CONTACT_RUNNER, "ktp-contact-runner") | |
47 | ||
46 | 48 | struct MatchInfo { |
47 | 49 | Tp::AccountPtr account; |
48 | 50 | Tp::ContactPtr contact; |
60 | 62 | |
61 | 63 | setObjectName(QLatin1String("IM Contacts Runner")); |
62 | 64 | |
63 | m_loggerDisabled = KStandardDirs::findExe(QLatin1String("ktp-log-viewer")).isEmpty(); | |
65 | m_loggerDisabled = QStandardPaths::findExecutable(QLatin1String("ktp-log-viewer")).isEmpty(); | |
64 | 66 | |
65 | 67 | addSyntax(Plasma::RunnerSyntax(QLatin1String(":q:"), i18n("Finds all IM contacts matching :q:."))); |
66 | 68 | addSyntax(Plasma::RunnerSyntax(QLatin1String("chat :q:"), i18n("Finds all contacts matching :q: that are capable of text chats (default behavior)"))); |
134 | 136 | void ContactRunner::accountManagerReady(Tp::PendingOperation *operation) |
135 | 137 | { |
136 | 138 | if (operation->isError()) { |
137 | kWarning() << operation->errorMessage(); | |
139 | qCWarning(KTP_CONTACT_RUNNER) << operation->errorMessage(); | |
138 | 140 | return; |
139 | 141 | } |
140 | 142 | |
141 | kDebug() << "Accounts manager is ready!"; | |
142 | ||
143 | 143 | m_globalPresence->setAccountManager(m_accountManager); |
144 | 144 | } |
145 | 145 | |
146 | QList< QAction* > ContactRunner::actionsForMatch(const Plasma::QueryMatch &match) | |
147 | { | |
148 | QList< QAction* > actions; | |
149 | ||
150 | MatchInfo data = match.data().value< MatchInfo >(); | |
146 | QList<QAction*> ContactRunner::actionsForMatch(const Plasma::QueryMatch &match) | |
147 | { | |
148 | QList<QAction*> actions; | |
149 | ||
150 | MatchInfo data = match.data().value<MatchInfo>(); | |
151 | 151 | if (!data.contact) { |
152 | 152 | return actions; |
153 | 153 | } |
215 | 215 | } |
216 | 216 | |
217 | 217 | if (!data.account || !data.contact) { |
218 | kWarning() << "Running invalid contact info"; | |
218 | qCWarning(KTP_CONTACT_RUNNER) << "Running invalid contact info"; | |
219 | 219 | return; |
220 | 220 | } |
221 | 221 | |
231 | 231 | KTp::Actions::startAudioVideoCall(account, contact); |
232 | 232 | } else if (match.selectedAction() == action("start-file-transfer")) { |
233 | 233 | |
234 | QStringList filenames = KFileDialog::getOpenFileNames( | |
235 | KUrl("kfiledialog:///FileTransferLastDirectory"), | |
236 | QString(), | |
237 | 0, | |
238 | i18n("Choose files to send to %1", contact->alias())); | |
234 | QStringList filenames = QFileDialog::getOpenFileNames(0, | |
235 | i18n("Choose files to send to %1", contact->alias()), | |
236 | QStringLiteral("kfiledialog:///FileTransferLastDirectory")); | |
239 | 237 | |
240 | 238 | if (filenames.isEmpty()) { // User hit cancel button |
241 | 239 | return; |
404 | 402 | match.setSelectedAction(defaultAction); |
405 | 403 | match.setRelevance(relevance); |
406 | 404 | |
407 | context.addMatch(term, match); | |
405 | context.addMatch(match); | |
408 | 406 | } |
409 | 407 | } |
410 | 408 | } |
507 | 505 | |
508 | 506 | match.setData(qVariantFromValue(data)); |
509 | 507 | |
510 | context.addMatch(context.query(), match); | |
511 | } | |
508 | context.addMatch(match); | |
509 | } | |
510 | ||
511 | K_EXPORT_PLASMA_RUNNER(ktp_contacts, ContactRunner) | |
512 | 512 | |
513 | 513 | #include "contactrunner.moc" |
19 | 19 | #ifndef KTPCONTACTRUNNER_H |
20 | 20 | #define KTPCONTACTRUNNER_H |
21 | 21 | |
22 | #include <QtCore/QModelIndex> | |
22 | #include <QModelIndex> | |
23 | #include <QLoggingCategory> | |
23 | 24 | |
24 | #include <Plasma/AbstractRunner> | |
25 | #include <KIcon> | |
25 | #include <KRunner/AbstractRunner> | |
26 | 26 | |
27 | 27 | #include <TelepathyQt/AccountManager> |
28 | ||
29 | Q_DECLARE_LOGGING_CATEGORY(KTP_CONTACT_RUNNER) | |
28 | 30 | |
29 | 31 | namespace KTp |
30 | 32 | { |
78 | 80 | bool m_loggerDisabled; |
79 | 81 | }; |
80 | 82 | |
81 | K_EXPORT_PLASMA_RUNNER(ktp_contacts, ContactRunner) | |
82 | ||
83 | 83 | #endif /* KTPCONTACTRUNNER_H */ |