PageRenderTime 167ms CodeModel.GetById 61ms app.highlight 44ms RepoModel.GetById 36ms app.codeStats 1ms

/src/sip/jabber/googlewrapper/googlewrapper.cpp

http://github.com/tomahawk-player/tomahawk
C++ | 86 lines | 50 code | 19 blank | 17 comment | 1 complexity | 3db0528f4942adb9d6c5d063d43c9159 MD5 | raw file
 1/*
 2    <one line to give the program's name and a brief idea of what it does.>
 3    Copyright (C) 2011  Leo Franchi <leo.franchi@kdab.com>
 4
 5    This program is free software: you can redistribute it and/or modify
 6    it under the terms of the GNU General Public License as published by
 7    the Free Software Foundation, either version 3 of the License, or
 8    (at your option) any later version.
 9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17*/
18
19
20#include "googlewrapper.h"
21#include "ui_configwidget.h"
22
23#include "utils/tomahawkutilsgui.h"
24
25#include <QtPlugin>
26#include <QInputDialog>
27
28
29SipPlugin*
30GoogleWrapperFactory::createPlugin( const QString& pluginId )
31{
32    return new GoogleWrapper( pluginId.isEmpty() ? generateId() : pluginId );
33}
34
35
36QIcon
37GoogleWrapperFactory::icon() const
38{
39    return QIcon( ":/gmail-logo.png" );
40}
41
42
43GoogleWrapper::GoogleWrapper ( const QString& pluginID )
44    : JabberPlugin ( pluginID )
45{
46    m_ui->headerLabel->setText( tr( "Configure this Google Account" ) );
47    m_ui->emailLabel->setText( tr( "Google Address" ) );
48    m_ui->jabberBlurb->setText( tr( "Enter your Google login to connect with your friends using Tomahawk!" ) );
49    m_ui->logoLabel->setPixmap( QPixmap( ":/gmail-logo.png" ) );
50    m_ui->jabberServer->setText( "talk.google.com" );
51    m_ui->jabberPort->setValue( 5222 );
52    m_ui->groupBoxJabberAdvanced->hide();
53}
54
55
56QIcon
57GoogleWrapper::icon() const
58{
59    return QIcon( ":/gmail-logo.png" );
60}
61
62
63QString
64GoogleWrapper::defaultSuffix() const
65{
66    return "@gmail.com";
67}
68
69
70void
71GoogleWrapper::showAddFriendDialog()
72{
73    bool ok;
74    QString id = QInputDialog::getText( TomahawkUtils::tomahawkWindow(), tr( "Add Friend" ),
75                                        tr( "Enter Google Address:" ), QLineEdit::Normal, "", &ok ).trimmed();
76    if ( !ok )
77        return;
78
79    qDebug() << "Attempting to add google contact to roster:" << id;
80    addContact( id );
81}
82
83
84#ifdef GOOGLE_WRAPPER
85Q_EXPORT_PLUGIN2( sipfactory, GoogleWrapperFactory )
86#endif