kitchensync

pluginenv.cpp

00001 /*
00002     This file is part of libqopensync.
00003 
00004     Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
00005     Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #include <opensync/opensync.h>
00024 #include <opensync/opensync-plugin.h>
00025 
00026 #include "plugin.h"
00027 #include "result.h"
00028 
00029 #include "pluginenv.h"
00030 
00031 using namespace QSync;
00032 
00033 PluginEnv::PluginEnv()
00034 {
00035   OSyncError *error = 0;
00036   mPluginEnv = osync_plugin_env_new( &error );
00037 }
00038 
00039 PluginEnv::~PluginEnv()
00040 {
00041   osync_plugin_env_free( mPluginEnv );
00042 }
00043 
00044 Result PluginEnv::initialize()
00045 {
00046   OSyncError *error = 0;
00047   if ( !osync_plugin_env_load( mPluginEnv, NULL, &error ) )
00048     return Result( &error );
00049   else
00050     return Result();
00051 }
00052 
00053 Result PluginEnv::finalize()
00054 {
00055   osync_plugin_env_free( mPluginEnv ); 
00056   return Result();
00057 }
00058 
00059 int PluginEnv::pluginCount() const
00060 {
00061   return osync_plugin_env_num_plugins( mPluginEnv );
00062 }
00063 
00064 Plugin PluginEnv::pluginAt( int pos ) const
00065 {
00066   Plugin plugin;
00067 
00068   if ( pos < 0 || pos >= pluginCount() )
00069     return plugin;
00070 
00071   OSyncPlugin *oplugin = osync_plugin_env_nth_plugin( mPluginEnv, pos );
00072   plugin.mPlugin = oplugin;
00073 
00074   return plugin;
00075 }
00076 
00077 Plugin PluginEnv::pluginByName( const TQString &name ) const
00078 {
00079   Plugin plugin;
00080 
00081   OSyncPlugin *oplugin = osync_plugin_env_find_plugin( mPluginEnv, name.latin1() );
00082   if ( oplugin )
00083     plugin.mPlugin = oplugin;
00084 
00085   return plugin;
00086 }
00087 
00088 /*
00089 Conversion PluginEnv::conversion() const
00090 {
00091   Conversion conversion;
00092   conversion.mPluginEnv = mPluginEnv;
00093 
00094   return conversion;
00095 }
00096 */