PageRenderTime 22ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
19#include "DatabaseCommand_AddClientAuth.h"
20
21#include "DatabaseImpl.h"
22#include "TomahawkSqlQuery.h"
23#include "utils/Logger.h"
24#include "Source.h"
25
26
27namespace Tomahawk
28{
29
30DatabaseCommand_AddClientAuth::DatabaseCommand_AddClientAuth( const QString& clientToken,
31                                                              const QString& website,
32                                                              const QString& name,
33                                                              const QString& userAgent,
34                                                              QObject* parent )
35    : DatabaseCommand( parent )
36    , m_clientToken( clientToken )
37    , m_website( website )
38    , m_name( name )
39    , m_userAgent( userAgent )
40{
41}
42
43
44void DatabaseCommand_AddClientAuth::exec( DatabaseImpl* lib )
45{
46    TomahawkSqlQuery q = lib->newquery();
47    q.prepare( "INSERT INTO http_client_auth (token, website, name, ua, mtime, permissions) VALUES (?, ?, ?, ?, ?, ?)" );
48    q.addBindValue( m_clientToken );
49    q.addBindValue( m_website );
50    q.addBindValue( m_name );
51    q.addBindValue( m_userAgent );
52    q.addBindValue( 0 );
53    q.addBindValue( "*" );
54
55    if ( !q.exec() )
56    {
57        qWarning() << "Failed to insert http client into auth table!";
58    }
59}
60
61}