Dump unported code of contactsrunner, akonadi-search has pimcontactsrunner

Reviewers: broulik, jriddell, davidedmundson

Reviewed By: broulik, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10116

(cherry picked from commit a19c9118)
parent 1e565290
......@@ -10,9 +10,6 @@ add_subdirectory(spellchecker)
add_subdirectory(dictionary)
#
# if(KDEPIMLIBS_FOUND)
# if (NOT KDE_PLATFORM_FEATURE_DISABLE_DEPRECATED)
# add_subdirectory(contacts)
# endif (NOT KDE_PLATFORM_FEATURE_DISABLE_DEPRECATED)
# add_subdirectory(events)
# endif(KDEPIMLIBS_FOUND)
#
......
set(krunner_contacts_SRCS
contactsrunner.cpp
imageiconengine.cpp
)
kde4_add_plugin(krunner_contacts ${krunner_contacts_SRCS})
target_link_libraries(krunner_contacts ${KDE4_KIO_LIBS} ${KDE4_PLASMA_LIBS}
${KDEPIMLIBS_KABC_LIBS} ${KDE4_AKONADI_CONTACT_LIBS})
install(TARGETS krunner_contacts DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES plasma-runner-contacts.desktop DESTINATION ${SERVICES_INSTALL_DIR})
#! /usr/bin/env bash
$XGETTEXT *.cpp -o $podir/plasma_runner_contacts.pot
/*
* Copyright (C) 2007 Teemu Rytilahti <tpr@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "contactsrunner.h"
#include <KDebug>
#include <KLocale>
#include <KIcon>
#include <KToolInvocation>
#include <akonadi/contact/contactdefaultactions.h>
/*#include <KMimeType>
*/
#include <kabc/stdaddressbook.h>
#include <kabc/addressee.h>
#include <kabc/phonenumber.h>
#include <kabc/picture.h>
#include "imageiconengine.h"
ContactsRunner::ContactsRunner(QObject *parent, const QVariantList& args)
: Plasma::AbstractRunner(parent, args)
{
Q_UNUSED(args);
setObjectName(QLatin1String( "Contacts" ));
m_book = KABC::StdAddressBook::self(true /*asynchronous*/);
m_icon = KIcon(QLatin1String( "internet-mail" ));
setIgnoredTypes(Plasma::RunnerContext::FileSystem | Plasma::RunnerContext::NetworkLocation);
addSyntax(Plasma::RunnerSyntax(QLatin1String( ":q:" ), i18n("Finds people in your address book matching :q:.")));
setDefaultSyntax(Plasma::RunnerSyntax(i18nc("list of all people in address book", "contacts"),
i18n("List all people in your address book.")));
}
ContactsRunner::~ContactsRunner()
{
}
void ContactsRunner::match(Plasma::RunnerContext &context)
{
const QString term = context.query().toLower();
if (term.size() < 3) {
return;
}
QList<Plasma::QueryMatch> matches;
foreach (const KABC::Addressee &a, m_book->allAddressees()) {
if (!context.isValid()) {
return;
}
bool matchedName;
bool matchedMail;
if (term.compare(i18nc("list of all people in address book", "contacts"), Qt::CaseInsensitive) == 0 || term.compare(QLatin1String( "contacts" ), Qt::CaseInsensitive) == 0) {
matchedName = true;
matchedMail = true;
} else {
matchedName = a.realName().contains(term, Qt::CaseInsensitive);
matchedMail = false;
}
if (!matchedName && !matchedMail) {
// Name didn't match, so lets try the name portion of the email address
const int indexOf = a.preferredEmail().indexOf(term, Qt::CaseInsensitive);
matchedMail = indexOf > -1 && indexOf < a.preferredEmail().indexOf(QLatin1Char( '@' ));
}
if ((matchedName || matchedMail) && !a.preferredEmail().isEmpty()) {
//kDebug() << "Possible match: " << a.realName() << " <" << a.preferredEmail() << ">";
Plasma::QueryMatch match(this);
//TODO: exact match if the name is exact? =)
match.setType(Plasma::QueryMatch::PossibleMatch);
if(!a.photo().isEmpty()) {
/* TODO it isn't anymore possible to use url as a photo for an user?
if(a.photo().isIntern()) {
}
else {
KURL url(a.photo().url());
kDebug() << "photo url: " << url.prettyUrl() << endl;
if(url.isLocalFile()) {
icon = QIcon(url);
}
}*/
QIcon icon(new ImageIconEngine(a.photo().data()));
match.setIcon(icon);
} else {
match.setIcon(m_icon);
}
match.setText(i18nc("Open the default mail program to mail someone", "Mail to %1", a.realName()));
if (!a.realName().isEmpty()) {
match.setData(QString(a.realName() + QLatin1String( " <" ) + a.preferredEmail() + QLatin1Char( '>' )));
} else {
match.setData(a.preferredEmail());
}
matches.append(match);
}
if (matchedName) {
KABC::PhoneNumber::TypeList list;
list << KABC::PhoneNumber::Home
<< KABC::PhoneNumber::Work
<< KABC::PhoneNumber::Voice
<< KABC::PhoneNumber::Cell
<< KABC::PhoneNumber::Video
<< KABC::PhoneNumber::Car;
foreach (const KABC::PhoneNumber::Type type, list) {
KABC::PhoneNumber phonenumber = a.phoneNumber(type);
if (!phonenumber.isEmpty()) {
//kDebug() << "Possible match: " << a.realName() << " tel: " << phonenumber.number();
Plasma::QueryMatch match(this);
//TODO: exact match if the name is exact? =)
match.setType(Plasma::QueryMatch::PossibleMatch);
if (!a.photo().isEmpty()) {
/* TODO it isn't anymore possible to use url as a photo for an user?
if(a.photo().isIntern()) {
}
else {
KURL url(a.photo().url());
kDebug() << "photo url: " << url.prettyUrl() << endl;
if(url.isLocalFile()) {
icon = QIcon(url);
}
}*/
QIcon icon(new ImageIconEngine(a.photo().data()));
match.setIcon(icon);
} else {
match.setIcon(m_icon);
}
match.setText(i18nc("Open the default telephone program to call someone", "Call %1 at %2", a.realName(), phonenumber.typeLabel()));
match.setSubtext(phonenumber.number());
match.setData(QString(QLatin1String("call:") + phonenumber.number()));
matches.append(match);
}
}
}
}
context.addMatches(term, matches);
}
void ContactsRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
{
Q_UNUSED(context);
const QString address = match.data().toString();
const QString name = match.text();
kDebug() << "run name '" << name << "' with address '" << address << "'";
if (address.startsWith(QLatin1String("call:"))) {
KABC::PhoneNumber number;
number.setNumber(address.mid(5));
Akonadi::ContactDefaultActions actions;
actions.dialPhoneNumber( number );
} else {
KToolInvocation::invokeMailer(address);
}
}
/*
* Copyright (C) 2007 Teemu Rytilahti <tpr@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef CONTACTSRUNNER_H
#define CONTACTSRUNNER_H
#include <plasma/abstractrunner.h>
#include <KIcon>
namespace KABC {
class AddressBook;
}
class ContactsRunner : public Plasma::AbstractRunner {
Q_OBJECT
public:
ContactsRunner( QObject *parent, const QVariantList& args );
~ContactsRunner();
void match(Plasma::RunnerContext &context);
void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match);
private:
KABC::AddressBook *m_book;
KIcon m_icon;
};
K_EXPORT_PLASMA_RUNNER(contacts, ContactsRunner)
#endif
/*
* Copyright (C) 2009 Christoph Feck <christoph@maxiom.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "imageiconengine.h"
#include <QtGui/QApplication>
#include <QtGui/QPainter>
#include <QtGui/QStyle>
#include <QtGui/QStyleOption>
ImageIconEngine::ImageIconEngine(const QImage &image)
: m_image(image)
{
}
ImageIconEngine::~ImageIconEngine()
{
}
QSize ImageIconEngine::actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)
{
Q_UNUSED(mode);
Q_UNUSED(state);
return size;
}
void ImageIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)
{
painter->fillRect(rect, Qt::transparent);
QPixmap p = pixmap(rect.size(), mode, state);
QRect r = p.rect();
r.moveCenter(rect.center());
painter->drawPixmap(r, p);
}
QPixmap ImageIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
{
Q_UNUSED(state);
QImage image = m_image;
if (size.isValid() && size != image.size()) {
image = image.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
QStyleOption opt;
return QApplication::style()->generatedIconPixmap(mode, QPixmap::fromImage(image), &opt);
}
/*
* Copyright (C) 2009 Christoph Feck <christoph@maxiom.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef IMAGEICONENGINE_H
#define IMAGEICONENGINE_H
#include <QtGui/QIconEngineV2>
#include <QtGui/QIcon>
class ImageIconEngine : public QIconEngineV2
{
public:
ImageIconEngine(const QImage &image);
~ImageIconEngine();
QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state);
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
private:
QImage m_image;
};
#endif
[Desktop Entry]
Name=Contacts
Name[ar]=جهات الاتصال
Name[bs]=Kontakti
Name[ca]=Contactes
Name[ca@valencia]=Contactes
Name[cs]=Kontakty
Name[da]=Kontakter
Name[de]=Kontakte
Name[el]=Επαφές
Name[en_GB]=Contacts
Name[eo]=Kontaktoj
Name[es]=Contactos
Name[et]=Kontaktid
Name[eu]=Kontaktuak
Name[fi]=Yhteystiedot
Name[fr]=Contacts
Name[ga]=Teagmhálacha
Name[gl]=Contactos
Name[he]=אנשי קשר
Name[hr]=Kontakti
Name[hu]=Névjegyek
Name[ia]=Contactos
Name[is]=Tengiliðir
Name[it]=Contatti
Name[ja]=連絡先
Name[kk]=Контакттар
Name[km]=ទំនាក់ទំនង
Name[ko]=연락처
Name[ku]=Têkilî
Name[lt]=Kontaktai
Name[lv]=Kontakti
Name[mr]=संपर्क
Name[nb]=Kontakter
Name[nds]=Kontakten
Name[nl]=Contactpersonen
Name[nn]=Kontaktar
Name[pa]=ਸੰਪਰਕ
Name[pl]=Kontakty
Name[pt]=Contactos
Name[pt_BR]=Contatos
Name[ro]=Contacte
Name[ru]=Контакты
Name[sk]=Kontakty
Name[sl]=Stiki
Name[sq]=Kontakte
Name[sr]=контакти
Name[sr@ijekavian]=контакти
Name[sr@ijekavianlatin]=kontakti
Name[sr@latin]=kontakti
Name[sv]=Kontakter
Name[th]=ที่อยู่ติดต่อ
Name[tr]=Kişiler
Name[ug]=ئالاقەداشلار
Name[uk]=Контакти
Name[wa]=Soçons
Name[x-test]=xxContactsxx
Name[zh_CN]=联系人
Name[zh_TW]=聯絡人
Comment=Finds entries in your address book
Comment[ar]=تبحث عن مدخلات في دفتر العناوين
Comment[bs]=Pronalazi unose u vašem adresaru
Comment[ca]=Cerca entrades a la llibreta d'adreces
Comment[ca@valencia]=Busca entrades a la llibreta d'adreces
Comment[cs]=Vyhledávání položek v adresáři
Comment[da]=Finder indgange i din adressebog.
Comment[de]=Einträge in Ihrem Adressbuch suchen
Comment[el]=Αναζητά καταχωρήσεις στο βιβλίο διευθύνσεών σας
Comment[en_GB]=Finds entries in your address book
Comment[es]=Busca entradas en su libreta de direcciones
Comment[et]=Kirjete otsimine aadressiraamatust
Comment[eu]=Zure helbide liburuan sarrerak aurkitzen ditu
Comment[fi]=Etsii yhteystietoja osoitekirjasta
Comment[fr]=Trouve des entrées dans votre carnet d'adresses
Comment[ga]=Aimsigh teagmhálacha i do leabhar seoltaí
Comment[gl]=Atopa entradas no caderno de enderezos
Comment[he]=מצא רשומות מתוך האנשי קשר שלך
Comment[hr]=Traži unose u vašem adresaru
Comment[hu]=Bejegyzések keresése a címjegyzékben
Comment[is]=Finnur færslur í heimilisfangaskránni
Comment[it]=Cerca voci nella rubrica dei contatti
Comment[ja]=アドレス帳のエントリを見つけます
Comment[kk]=Адрестік кітапшаңызды ақтару
Comment[km]=រក​ធាតុ​នៅ​ក្នុង​សៀវភៅ​អាសយដ្ឋាន​របស់​អ្នក
Comment[ko]=주소록에서 항목 찾기
Comment[ku]=Têketinên di pirtûka navnîşanan de dibîne
Comment[lt]=Randa įrašus jūsų adresų knygelėje
Comment[lv]=Atrod ierakstus adrešu grāmatā
Comment[mr]=तुमच्या पत्ता पुस्तकातील नोंदी शोधतो
Comment[nb]=Finner oppføringer i adresseboka
Comment[nds]=Indrääg binnen Dien Adressbook söken
Comment[nl]=Doorzoekt ingangen in uw adresboek
Comment[nn]=Finn oppføringar i adresseboka
Comment[pa]=ਆਪਣੀ ਐਡਰੈੱਸ ਬੁੱਕ ਵਿੱਚ ਐਂਟਰੀਆਂ ਲੱਭੋ
Comment[pl]=Wyszukuje wpisów w twojej książce adresowej
Comment[pt]=Descobre elementos no seu livro de endereços
Comment[pt_BR]=Localiza entradas no seu livro de endereços
Comment[ro]=Găsește adrese în cartea de adrese
Comment[ru]=Поиск записей в адресной книге
Comment[sk]=Vyhľadávanie položiek vo vašom adresári
Comment[sl]=Najde stike iz vašega imenika
Comment[sr]=Потражите уносе кроз адресар
Comment[sr@ijekavian]=Потражите уносе кроз адресар
Comment[sr@ijekavianlatin]=Potražite unose kroz adresar
Comment[sr@latin]=Potražite unose kroz adresar
Comment[sv]=Hittar poster i din adressbok
Comment[th]=ค้นรายการในสมุดที่อยู่ของคุณ
Comment[tr]=Adres defterinizdeki arkadaşlarınız
Comment[uk]=Знайти записи у вашій адресній книзі
Comment[wa]=Trove des intrêyes dins vosse calpin d' adresses
Comment[x-test]=xxFinds entries in your address bookxx
Comment[zh_CN]=在地址簿里查找条目
Comment[zh_TW]=找到通訊錄中的聯絡人
ServiceTypes=Plasma/Runner
Type=Service
Icon=internet-mail
X-KDE-Library=krunner_contacts
X-KDE-PluginInfo-Author=Teemu Rytilahti
X-KDE-PluginInfo-Email=tpr@iki.fi
X-KDE-PluginInfo-Name=kabccontacts
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-License=LGPL
X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-AdvertiseSingleRunnerQueryMode=true
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment