kitchensync

result.cpp

00001 /*
00002     This file is part of libqopensync.
00003 
00004     Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "result.h"
00023 
00024 #include <opensync/opensync.h>
00025 
00026 using namespace QSync;
00027 
00028 Result::Result()
00029   : mType( NoError )
00030 {
00031 }
00032 
00033 Result::Result( Type type )
00034   : mType( type )
00035 {
00036 }
00037 
00038 Result::Result( OSyncError **error, bool deleteError )
00039 {
00040   OSyncErrorType otype = osync_error_get_type( error );
00041   Type type;
00042 
00043   switch ( otype ) {
00044     case OSYNC_NO_ERROR:
00045       type = NoError;
00046       break;
00047     default:
00048     case OSYNC_ERROR_GENERIC:
00049       type = GenericError;
00050       break;
00051     case OSYNC_ERROR_IO_ERROR:
00052       type = IOError;
00053       break;
00054     case OSYNC_ERROR_NOT_SUPPORTED:
00055       type = NotSupported;
00056       break;
00057     case OSYNC_ERROR_TIMEOUT:
00058       type = Timeout;
00059       break;
00060     case OSYNC_ERROR_DISCONNECTED:
00061       type = Disconnected;
00062       break;
00063     case OSYNC_ERROR_FILE_NOT_FOUND:
00064       type = FileNotFound;
00065       break;
00066     case OSYNC_ERROR_EXISTS:
00067       type = Exists;
00068       break;
00069     case OSYNC_ERROR_CONVERT:
00070       type = Convert;
00071       break;
00072     case OSYNC_ERROR_MISCONFIGURATION:
00073       type = Misconfiguration;
00074       break;
00075     case OSYNC_ERROR_INITIALIZATION:
00076       type = Initialization;
00077       break;
00078     case OSYNC_ERROR_PARAMETER:
00079       type = Parameter;
00080       break;
00081     case OSYNC_ERROR_EXPECTED:
00082       type = Expected;
00083       break;
00084     case OSYNC_ERROR_NO_CONNECTION:
00085       type = NoConnection;
00086       break;
00087     case OSYNC_ERROR_TEMPORARY:
00088       type = Temporary;
00089       break;
00090     case OSYNC_ERROR_LOCKED:
00091       type = Locked;
00092       break;
00093     case OSYNC_ERROR_PLUGIN_NOT_FOUND:
00094       type = PluginNotFound;
00095       break;
00096   }
00097 
00098   mType = type;
00099   mName = QString::fromUtf8( osync_error_get_name( error ) );
00100   mMessage = QString::fromUtf8( osync_error_print( error ) );
00101 
00102   if ( deleteError )
00103     osync_error_free( error );
00104 }
00105 
00106 Result::~Result()
00107 {
00108 }
00109 
00110 void Result::setName( const QString &name )
00111 {
00112   mName = name;
00113 }
00114 
00115 QString Result::name() const
00116 {
00117   return mName;
00118 }
00119 
00120 void Result::setMessage( const QString &message )
00121 {
00122   mMessage = message;
00123 }
00124 
00125 QString Result::message() const
00126 {
00127   return mMessage;
00128 }
00129 
00130 void Result::setType( Type type )
00131 {
00132   mType = type;
00133 }
00134 
00135 Result::Type Result::type() const
00136 {
00137   return mType;
00138 }
00139 
00140 bool Result::isError() const
00141 {
00142   return mType != NoError;
00143 }
00144 
00145 Result::operator bool () const
00146 {
00147   return ( mType != NoError );
00148 }
00149 
KDE Home | KDE Accessibility Home | Description of Access Keys