/src/libtomahawk/database/DatabaseCommand_AddClientAuth.cpp

http://github.com/tomahawk-player/tomahawk · C++ · 61 lines · 35 code · 9 blank · 17 comment · 1 complexity · e73d7ca7c321f8174741568f97b5e193 MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
  4. *
  5. * Tomahawk 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. * Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "DatabaseCommand_AddClientAuth.h"
  19. #include "DatabaseImpl.h"
  20. #include "TomahawkSqlQuery.h"
  21. #include "utils/Logger.h"
  22. #include "Source.h"
  23. namespace Tomahawk
  24. {
  25. DatabaseCommand_AddClientAuth::DatabaseCommand_AddClientAuth( const QString& clientToken,
  26. const QString& website,
  27. const QString& name,
  28. const QString& userAgent,
  29. QObject* parent )
  30. : DatabaseCommand( parent )
  31. , m_clientToken( clientToken )
  32. , m_website( website )
  33. , m_name( name )
  34. , m_userAgent( userAgent )
  35. {
  36. }
  37. void DatabaseCommand_AddClientAuth::exec( DatabaseImpl* lib )
  38. {
  39. TomahawkSqlQuery q = lib->newquery();
  40. q.prepare( "INSERT INTO http_client_auth (token, website, name, ua, mtime, permissions) VALUES (?, ?, ?, ?, ?, ?)" );
  41. q.addBindValue( m_clientToken );
  42. q.addBindValue( m_website );
  43. q.addBindValue( m_name );
  44. q.addBindValue( m_userAgent );
  45. q.addBindValue( 0 );
  46. q.addBindValue( "*" );
  47. if ( !q.exec() )
  48. {
  49. qWarning() << "Failed to insert http client into auth table!";
  50. }
  51. }
  52. }