pluginenv.cpp
1/*
2 This file is part of libqopensync.
3
4 Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22
23#include <opensync/opensync.h>
24#include <opensync/opensync-plugin.h>
25
26#include "plugin.h"
27#include "result.h"
28
29#include "pluginenv.h"
30
31using namespace QSync;
32
33PluginEnv::PluginEnv()
34{
35 OSyncError *error = 0;
36 mPluginEnv = osync_plugin_env_new( &error );
37}
38
39PluginEnv::~PluginEnv()
40{
41 osync_plugin_env_free( mPluginEnv );
42}
43
44Result PluginEnv::initialize()
45{
46 OSyncError *error = 0;
47 if ( !osync_plugin_env_load( mPluginEnv, NULL, &error ) )
48 return Result( &error );
49 else
50 return Result();
51}
52
53Result PluginEnv::finalize()
54{
55 osync_plugin_env_free( mPluginEnv );
56 return Result();
57}
58
59int PluginEnv::pluginCount() const
60{
61 return osync_plugin_env_num_plugins( mPluginEnv );
62}
63
64Plugin PluginEnv::pluginAt( int pos ) const
65{
66 Plugin plugin;
67
68 if ( pos < 0 || pos >= pluginCount() )
69 return plugin;
70
71 OSyncPlugin *oplugin = osync_plugin_env_nth_plugin( mPluginEnv, pos );
72 plugin.mPlugin = oplugin;
73
74 return plugin;
75}
76
77Plugin PluginEnv::pluginByName( const TQString &name ) const
78{
79 Plugin plugin;
80
81 OSyncPlugin *oplugin = osync_plugin_env_find_plugin( mPluginEnv, name.latin1() );
82 if ( oplugin )
83 plugin.mPlugin = oplugin;
84
85 return plugin;
86}
87
88/*
89Conversion PluginEnv::conversion() const
90{
91 Conversion conversion;
92 conversion.mPluginEnv = mPluginEnv;
93
94 return conversion;
95}
96*/