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