mirror of https://github.com/vitalif/grive2
Remove bgrive (dead and unused code)
parent
f16f212281
commit
12774a952a
|
@ -9,4 +9,3 @@ add_definitions( -D_FILE_OFFSET_BITS=64 )
|
|||
|
||||
add_subdirectory( libgrive )
|
||||
add_subdirectory( grive )
|
||||
add_subdirectory( bgrive )
|
||||
|
|
|
@ -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)
|
|
@ -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 <QtCore/QDebug>
|
||||
|
||||
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<unsigned>(row) >= parent->ChildCount() )
|
||||
BOOST_THROW_EXCEPTION(
|
||||
Exception()
|
||||
<< InvalidRow_( row )
|
||||
<< ResourceName_( parent->Title() )
|
||||
) ;
|
||||
|
||||
|
||||
return createIndex( row, column, const_cast<Resource*>(m_drv.Child(parent, row)) ) ;
|
||||
}
|
||||
|
||||
const Resource* DriveModel::Res( const QModelIndex& idx ) const
|
||||
{
|
||||
return idx.isValid()
|
||||
? reinterpret_cast<const Resource*>(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<Resource*>(parent) ) ;
|
||||
}
|
||||
|
||||
} // end of namespace
|
|
@ -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 <QtCore/QAbstractItemModel>
|
||||
|
||||
#include "drive2/Drive.hh"
|
||||
#include "util/Exception.hh"
|
||||
|
||||
namespace gr {
|
||||
|
||||
namespace http
|
||||
{
|
||||
class Agent ;
|
||||
}
|
||||
|
||||
class DriveModel : public QAbstractItemModel
|
||||
{
|
||||
public :
|
||||
typedef boost::error_info<struct InvalidRow, int> InvalidRow_ ;
|
||||
typedef boost::error_info<struct ResourceName, std::string> 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
|
||||
|
|
@ -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 <QtCore/QDebug>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
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
|
|
@ -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 <QtGui/QMainWindow>
|
||||
#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
|
||||
|
|
@ -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 <QtGui/QApplication>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#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 <string>
|
||||
#include <iostream>
|
||||
|
||||
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<http::Agent>( new http::CurlAgent ) ) ;
|
||||
|
||||
QApplication app( argc, argv ) ;
|
||||
MainWnd wnd( &agent ) ;
|
||||
wnd.show();
|
||||
|
||||
return app.exec() ;
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Grive</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QTreeView" name="m_dir">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Title:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_title"/>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="2">
|
||||
<widget class="QLabel" name="m_icon">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Filename:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_filename"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Mime type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="m_mime_type"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Last Updated:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QDateTimeEdit" name="m_last_update"/>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QGraphicsView" name="m_preview"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="m_menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="m_menu_file">
|
||||
<property name="title">
|
||||
<string>&File</string>
|
||||
</property>
|
||||
<addaction name="m_action_exit"/>
|
||||
</widget>
|
||||
<addaction name="m_menu_file"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="m_statusbar"/>
|
||||
<action name="m_action_exit">
|
||||
<property name="text">
|
||||
<string>E&xit</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>m_action_exit</sender>
|
||||
<signal>activated()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>299</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Loading…
Reference in New Issue