File indexing completed on 2024-05-05 04:46:01

0001 #include "communicator.h"
0002 
0003 #include <KToolInvocation>
0004 
0005 #include <QFileInfo>
0006 #include <QDebug>
0007 #include <QUrl>
0008 
0009 #ifdef Q_OS_ANDROID
0010 #include "androidinterface.h"
0011 #else
0012 #include <QDesktopServices>
0013 #endif
0014 
0015 Communicator::Communicator(QObject *parent) : QObject(parent)
0016 {
0017 
0018 }
0019 
0020 void Communicator::attachEmail(const QStringList &urls)
0021 {
0022     if (urls.isEmpty())
0023         return;
0024 
0025     QFileInfo file(urls[0]);
0026 
0027     KToolInvocation::invokeMailer("", "", "", file.baseName(), "Files shared... ", "", urls);
0028     //    QDesktopServices::openUrl(QUrl("mailto:?subject=test&body=test&attachment;="
0029     //    + url));
0030 }
0031 
0032 void Communicator::email(const QString &to, const QString &cc, const QString &bcc, const QString &subject, const QString &body, const QString &messageFile, const QStringList &urls)
0033 {
0034     KToolInvocation::invokeMailer(to, cc, bcc, subject, body, messageFile, urls);
0035     //    QDesktopServices::openUrl(QUrl("mailto:?subject=test&body=test&attachment;="
0036     //    + url));
0037 
0038 //    Qt.openUrlExternally("mailto:" + contact.email)
0039 
0040 }
0041 
0042 
0043 void Communicator::call(const QString &tel)
0044 {
0045 #ifdef Q_OS_ANDROID
0046     AndroidInterface::call(tel);
0047 #else
0048     QDesktopServices::openUrl(QUrl("call://"+tel));
0049 #endif
0050 
0051 }
0052 
0053 void Communicator::sendSMS(const QString &tel, const QString &subject, const QString &body)
0054 {
0055 #ifdef Q_OS_ANDROID
0056     AndroidInterface::sendSMS(tel,subject, body);
0057 #else
0058     QDesktopServices::openUrl(QUrl("smsto:" + tel +"&sms_body:" + subject+" " + body));
0059 #endif
0060 }