From 12774a952a2ef7534b0750966827c09cb404f5e2 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 14 May 2015 01:22:37 +0300 Subject: [PATCH] Remove bgrive (dead and unused code) --- CMakeLists.txt | 1 - bgrive/CMakeLists.txt | 42 ------------- bgrive/src/DriveModel.cc | 116 ---------------------------------- bgrive/src/DriveModel.hh | 61 ------------------ bgrive/src/MainWnd.cc | 58 ----------------- bgrive/src/MainWnd.hh | 56 ----------------- bgrive/src/main.cc | 62 ------------------ bgrive/ui/MainWindow.ui | 132 --------------------------------------- 8 files changed, 528 deletions(-) delete mode 100644 bgrive/CMakeLists.txt delete mode 100644 bgrive/src/DriveModel.cc delete mode 100644 bgrive/src/DriveModel.hh delete mode 100644 bgrive/src/MainWnd.cc delete mode 100644 bgrive/src/MainWnd.hh delete mode 100644 bgrive/src/main.cc delete mode 100644 bgrive/ui/MainWindow.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index 48f1460..def7ca0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,4 +9,3 @@ add_definitions( -D_FILE_OFFSET_BITS=64 ) add_subdirectory( libgrive ) add_subdirectory( grive ) -add_subdirectory( bgrive ) diff --git a/bgrive/CMakeLists.txt b/bgrive/CMakeLists.txt deleted file mode 100644 index 7bb3269..0000000 --- a/bgrive/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -project( bgrive ) - -find_package(Qt4 REQUIRED) -find_package(Boost REQUIRED) -INCLUDE(${QT_USE_FILE}) - -include_directories( - ${bgrive_SOURCE_DIR}/../libgrive/src - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} -) - -file (GLOB BGRIVE_EXE_SRC - ${bgrive_SOURCE_DIR}/src/*.cc -) - -file (GLOB BGRIVE_UI - ${bgrive_SOURCE_DIR}/ui/*.ui -) - -QT4_WRAP_UI(BGRIVE_UI_SRCS ${BGRIVE_UI}) -QT4_WRAP_CPP(BGRIVE_MOC_SRCS - src/MainWnd.hh ) - -add_executable( bgrive_executable - ${BGRIVE_EXE_SRC} - ${BGRIVE_UI_SRCS} - ${BGRIVE_MOC_SRCS} -) - -target_link_libraries( bgrive_executable - ${Boost_LIBRARIES} - ${QT_QTMAIN_LIBRARY} - ${QT_LIBRARIES} - grive -) - -set_target_properties( bgrive_executable - PROPERTIES OUTPUT_NAME bgrive -) - -install(TARGETS bgrive_executable RUNTIME DESTINATION bin) diff --git a/bgrive/src/DriveModel.cc b/bgrive/src/DriveModel.cc deleted file mode 100644 index bc3bcf4..0000000 --- a/bgrive/src/DriveModel.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - grive: an GPL program to sync a local directory with Google Drive - Copyright (C) 2013 Wan Wai Ho - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation version 2 - of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. -*/ - -#include "DriveModel.hh" - -#include "drive2/Resource.hh" - -#include - -namespace gr { - -using namespace v2; - -DriveModel::DriveModel( http::Agent *agent ) -{ - m_drv.Refresh( agent ) ; -} - -Qt::ItemFlags DriveModel::flags( const QModelIndex& ) const -{ - return Qt::ItemIsEnabled | Qt::ItemIsSelectable ; -} - -QVariant DriveModel::data( const QModelIndex& index, int role ) const -{ - const Resource *res = Res(index) ; - if ( role == Qt::DisplayRole && res != 0 ) - { - switch ( index.column() ) - { - case 0: return QString::fromUtf8(res->Title().c_str()) ; - default: break ; - } - } - - return QVariant() ; -} - -QVariant DriveModel::headerData( int section, Qt::Orientation orientation, int role ) const -{ - return role == Qt::DisplayRole ? QString("header") : QVariant() ; -} - -int DriveModel::rowCount( const QModelIndex& parent ) const -{ - return Res(parent)->ChildCount() ; -} - -int DriveModel::columnCount( const QModelIndex& parent ) const -{ - return 1 ; -} - -bool DriveModel::hasChildren( const QModelIndex& parent ) const -{ - return Res(parent)->ChildCount() > 0 ; -} - -QModelIndex DriveModel::index( int row, int column, const QModelIndex& parent_idx ) const -{ - const Resource *parent = Res(parent_idx) ; - - // check out-of-bound - if ( parent != 0 && static_cast(row) >= parent->ChildCount() ) - BOOST_THROW_EXCEPTION( - Exception() - << InvalidRow_( row ) - << ResourceName_( parent->Title() ) - ) ; - - - return createIndex( row, column, const_cast(m_drv.Child(parent, row)) ) ; -} - -const Resource* DriveModel::Res( const QModelIndex& idx ) const -{ - return idx.isValid() - ? reinterpret_cast(idx.internalPointer()) - : m_drv.Root() ; -} - -QModelIndex DriveModel::parent( const QModelIndex& idx ) const -{ - // if I am root, my parent is myself - const Resource *res = Res(idx) ; - if ( res == m_drv.Root() ) - return QModelIndex() ; - - // if my parent is root, return model index of root (i.e. QModelIndex()) - const Resource *parent = m_drv.Parent(res) ; - if ( parent == 0 || parent == m_drv.Root() || idx.column() != 0 ) - return QModelIndex() ; - - // check grand-parent to know the row() of my parent - const Resource *grand = m_drv.Parent(parent) ; - return createIndex( grand->Index(parent->ID()), 0, const_cast(parent) ) ; -} - -} // end of namespace diff --git a/bgrive/src/DriveModel.hh b/bgrive/src/DriveModel.hh deleted file mode 100644 index f39847f..0000000 --- a/bgrive/src/DriveModel.hh +++ /dev/null @@ -1,61 +0,0 @@ -/* - grive: an GPL program to sync a local directory with Google Drive - Copyright (C) 2013 Wan Wai Ho - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation version 2 - of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. -*/ - -#pragma once - -#include - -#include "drive2/Drive.hh" -#include "util/Exception.hh" - -namespace gr { - -namespace http -{ - class Agent ; -} - -class DriveModel : public QAbstractItemModel -{ -public : - typedef boost::error_info InvalidRow_ ; - typedef boost::error_info ResourceName_ ; - -public : - DriveModel( http::Agent *agent ) ; - - // QAbstractItemModel overrides - Qt::ItemFlags flags( const QModelIndex & index ) const ; - QVariant data( const QModelIndex& index, int role ) const ; - QVariant headerData( int section, Qt::Orientation orientation, int role ) const ; - int rowCount( const QModelIndex& parent ) const ; - int columnCount( const QModelIndex& parent ) const ; - bool hasChildren ( const QModelIndex& parent ) const ; - QModelIndex index( int row, int column, const QModelIndex& parent ) const ; - QModelIndex parent( const QModelIndex& idx ) const ; - - const v2::Resource* Res( const QModelIndex& idx ) const ; - -private : - v2::Drive m_drv ; -} ; - -} // end of namespace - diff --git a/bgrive/src/MainWnd.cc b/bgrive/src/MainWnd.cc deleted file mode 100644 index 28d4e08..0000000 --- a/bgrive/src/MainWnd.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* - grive: an GPL program to sync a local directory with Google Drive - Copyright (C) 2013 Wan Wai Ho - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation version 2 - of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. -*/ - -#include "MainWnd.hh" - -#include "drive2/Resource.hh" - -#include - -#include - -namespace gr { - -using namespace v2 ; - -MainWnd::MainWnd( http::Agent *agent ) : - m_drive( agent ) -{ - m_ui.setupUi(this) ; - m_ui.m_dir->setModel( &m_drive ) ; - - connect( - m_ui.m_dir, SIGNAL(activated(const QModelIndex&)), - this, SLOT(OnClick(const QModelIndex&)) - ) ; -} - -void MainWnd::OnClick( const QModelIndex& index ) -{ - const Resource *res = m_drive.Res(index) ; - if ( res != 0 ) - ShowResource( res ) ; -} - -void MainWnd::ShowResource( const v2::Resource *res ) -{ - m_ui.m_title->setText( QString::fromUtf8(res->Title().c_str()) ) ; - m_ui.m_mime_type->setText( QString::fromUtf8(res->Mime().c_str()) ) ; -} - -} // end of namespace diff --git a/bgrive/src/MainWnd.hh b/bgrive/src/MainWnd.hh deleted file mode 100644 index fe9401b..0000000 --- a/bgrive/src/MainWnd.hh +++ /dev/null @@ -1,56 +0,0 @@ -/* - grive: an GPL program to sync a local directory with Google Drive - Copyright (C) 2013 Wan Wai Ho - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation version 2 - of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. -*/ - -#pragma once - -#include -#include "ui_MainWindow.h" - -#include "DriveModel.hh" - -class QModelIndex ; - -namespace gr { - -namespace http -{ - class Agent ; -} - -class MainWnd : public QMainWindow -{ - Q_OBJECT - -public : - MainWnd( http::Agent *agent ) ; - -private : - void ShowResource( const v2::Resource *res ) ; - -public slots : - void OnClick( const QModelIndex& index ) ; - -private : - Ui::MainWindow m_ui ; - DriveModel m_drive ; -} ; - -} // end of namespace - diff --git a/bgrive/src/main.cc b/bgrive/src/main.cc deleted file mode 100644 index ea578ec..0000000 --- a/bgrive/src/main.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - grive: an GPL program to sync a local directory with Google Drive - Copyright (C) 2013 Wan Wai Ho - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation version 2 - of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. -*/ - -#include "MainWnd.hh" - -#include -#include - -#include "drive2/Drive.hh" - -#include "http/CurlAgent.hh" -#include "http/Header.hh" -#include "protocol/JsonResponse.hh" - -#include "protocol/Json.hh" -#include "protocol/OAuth2.hh" -#include "protocol/AuthAgent.hh" - -#include "util/File.hh" - -#include -#include - -const std::string client_id = "22314510474.apps.googleusercontent.com" ; -const std::string client_secret = "bl4ufi89h-9MkFlypcI7R785" ; - -using namespace gr ; -using namespace gr::v2 ; - -int main( int argc, char **argv ) -{ - File file( ".grive" ) ; - Json cfg = Json::Parse( &file ) ; - - std::string refresh_token = cfg["refresh_token"].Str() ; - OAuth2 token( refresh_token, client_id, client_secret ) ; - - AuthAgent agent( token, std::auto_ptr( new http::CurlAgent ) ) ; - - QApplication app( argc, argv ) ; - MainWnd wnd( &agent ) ; - wnd.show(); - - return app.exec() ; -} diff --git a/bgrive/ui/MainWindow.ui b/bgrive/ui/MainWindow.ui deleted file mode 100644 index 61c9920..0000000 --- a/bgrive/ui/MainWindow.ui +++ /dev/null @@ -1,132 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - Grive - - - - - - - Qt::Horizontal - - - - - 0 - 0 - - - - - - - - - Title: - - - - - - - - - - - - - - - - - Filename: - - - - - - - - - - Mime type: - - - - - - - - - - Last Updated: - - - - - - - - - - - - - - - - - - - 0 - 0 - 800 - 23 - - - - - &File - - - - - - - - - E&xit - - - - - - - m_action_exit - activated() - MainWindow - close() - - - -1 - -1 - - - 399 - 299 - - - - -