From: Andrey Paskal Date: Sun, 24 May 2009 18:30:18 +0000 (+0400) Subject: Extention Service welcome back to project HEAD. X-Git-Url: https://gitweb.ananas.su/?a=commitdiff_plain;h=3e3ea690b637df133deb03291e6963bef74044dd;p=projects%2Fananas-labs-qt4.git Extention Service welcome back to project HEAD. --- diff --git a/src/extensions/extensions.pro b/src/extensions/extensions.pro index bf22596..09c873b 100644 --- a/src/extensions/extensions.pro +++ b/src/extensions/extensions.pro @@ -3,4 +3,5 @@ SUBDIRS = example SUBDIRS += text SUBDIRS += xml SUBDIRS += meta +SUBDIRS += service #unix:SUBDIRS += te diff --git a/src/extensions/service/aextguid.cpp b/src/extensions/service/aextguid.cpp new file mode 100644 index 0000000..de8fe02 --- /dev/null +++ b/src/extensions/service/aextguid.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** $Id: aextguid.cpp,v 1.2 2007/09/19 06:32:06 app Exp $ +** +** Code file of the Report Result Object of Ananas +** Designer and Engine applications +** +** Created : 20070819 +** +** Copyright (C) 2005-2007 Grigory Panov , Moscow. +** Copyright (C) 2005-2007 Ananas Project. +** +** This file is part of the Library of the Ananas +** automation accounting system. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.leaderit.ru/page=ananas or email sales@leaderit.ru +** See http://www.leaderit.ru/gpl/ for GPL licensing information. +** +** Contact org@leaderit.ru if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include +#include "aextguid.h" + +aExtGUID::aExtGUID() + : AExtension("GUID") +{ +} + +aExtGUID::~aExtGUID() +{ +} + + +/** + * \en + * Class for generate GUID strings from Ananas Script. Linux only !!! + * \_en + * \ru + * Генерирует строку GUID (глобально-уникального идентификатора, Globally Unique IDentifier). + * Только в Linux версиях. В Windows возвращает 00000000-0000-... (Для Qt3.2) + * + * GUID представляет собой 128-битное значение, уникальное для всех практических целей. + * \brief Генерирует строку GUID в верхнем регистре. + * + * Пример использования функции Generate() + * \code + * var newGUID = (new GUID).Generate(); + * sysMessage (0, newGUID); + * возвращает строку вида {FC98E407-B3F7-4914-A2B1-36B4C2A93228} + * + * Для преобразования в нижний регистр необходимо использовать + * newGUID.toLowerCase(); + * \endcode + * + * \_ru + */ +QString aExtGUID::Generate() const +{ + +#ifdef Q_OS_WIN32 + return QUuid().toString(); +#else + return QUuid::createUuid().toString().upper(); +#endif +} + +#include +typedef AExtensionPlugin aExtGUIDPlugin; +A_EXPORT_PLUGIN( aExtGUIDPlugin ) diff --git a/src/extensions/service/aextguid.h b/src/extensions/service/aextguid.h new file mode 100644 index 0000000..d6bb38e --- /dev/null +++ b/src/extensions/service/aextguid.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** $Id: aextguid.h,v 1.2 2007/09/19 06:32:06 app Exp $ +** +** Header file of the Report Result Object of Ananas +** Designer and Engine applications +** +** Created : 20070819 +** +** Copyright (C) 2005-2007 Grigory Panov , Moscow. +** Copyright (C) 2005-2007 Ananas Project. +** +** This file is part of the Library of the Ananas +** automation accounting system. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.leaderit.ru/page=ananas or email sales@leaderit.ru +** See http://www.leaderit.ru/gpl/ for GPL licensing information. +** +** Contact org@leaderit.ru if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#ifndef AEXTGUID_H +#define AEXTGUID_H + +#include "aextension.h" +#include "aobject.h" + +/** + * \en + * Class for generate GUID strings from Ananas Script. + * \_en + * \ru + * \brief Генерирует строку GUID в верхенм регистре. + * + * + * \_ru + */ + +class ANANAS_EXPORT aExtGUID: public AExtension +{ + Q_OBJECT +public: + aExtGUID(); + ~aExtGUID(); + + +public slots: + QString Generate() const; +}; + +#endif diff --git a/src/extensions/service/aextservice.cpp b/src/extensions/service/aextservice.cpp new file mode 100644 index 0000000..91b8dbb --- /dev/null +++ b/src/extensions/service/aextservice.cpp @@ -0,0 +1,139 @@ +#include "aservice.h" +#include "aextservice.h" +#include "adatabase.h" +#include "alog.h" + +#include + +aExtSERVICE::aExtSERVICE() + : AExtension("Service") +{ +} + +aExtSERVICE::~aExtSERVICE() +{ +} + + +/** + * \en + * Defines what office (Microsoft Office или Open office) it is used by default for creation of reports + * \_en + * \ru + * определяет какой офис(Microsoft Office или Open office) используется по-умолчанию для создания отчетов + * \code + * var defOffice = (new Service).GetOffice(); + * sysMessage (0, defOffice); + * возвращает строку: + * "MSO" - Microsoft Office + * "OOO" - Open Office + * \endcode + * \_ru + */ +QString aExtSERVICE::GetOffice() const +{ +#ifdef Q_OS_WIN32 + bool ok; + QString office = aService::readConfigVariable("defaultOffice", &ok); + if (ok) + return office; + else + return ""; +#else + return ""; +#endif +} + + +/** + * \en + * Class for generate GUID strings from Ananas Script. Linux only !!! + * \_en + * \ru + * Генерирует строку GUID (глобально-уникального идентификатора, Globally Unique IDentifier). + * Только в Linux версиях. В Windows возвращает 00000000-0000-... (Для Qt3.2) + * + * GUID представляет собой 128-битное значение, уникальное для всех практических целей. + * \brief Генерирует строку GUID в верхнем регистре. + * + * Пример использования функции Generate() + * \code + * var newGUID = (new Service).Generate(); + * sysMessage (0, newGUID); + * возвращает строку вида {FC98E407-B3F7-4914-A2B1-36B4C2A93228} + * + * Для преобразования в нижний регистр необходимо использовать + * newGUID.toLowerCase(); + * \endcode + * + * \_ru + */ +QString aExtSERVICE::Generate() const +{ + +#ifdef Q_OS_WIN32 + return QUuid().toString(); +#else + return QUuid::createUuid().toString().upper(); +#endif +} + +/** + * \ru + * \brief Возвращает имя используемого rc файла с полным путем. + * + * Враппер. Вызывает аналогичный метод класса aCfgRc. + * \see aCfgRc.getRcFileName() + * + * Пример использования + * \code + * service = new Service(); + * sys.Message(0,"Name of used rc file is '"+service.GetRcFileName() + "'"); + * \endcode + * + * \_ru + */ +QString +aExtSERVICE::GetRcFileName() const +{ + return db->cfg.rc.getRcFileName(); +}; + +/** + * \ru + * \brief Возвращает значение указанного параметра, хранящегося в rc файле. + * + * \param paramName - имя параметра, значение которого требуется получить из файла ресурсов. + * \return значение параметра в случае успеха; пустую строку в случае неудачи. Пишет в лог сообщения о возникающих ошибках. + * + * Пример использования + * \code + * service = new Service(); + * sys.Message(0,"File of business-scheme is '"+service.GetRcValue('configfile') + "'"); + * \endcode + * + * \_ru + */ +QString +aExtSERVICE::GetRcValue( QString paramName ) const +{ + if ( !paramName || paramName.isNull() ) + { + aLog::print(aLog::MT_ERROR, tr("Empty rc file parameter name. Can't read such parameter from rc file.")); + return ""; + } + QString paramValue = db->cfg.rc.value( paramName ); + if ( !paramValue || paramValue.isEmpty() ) + { + aLog::print(aLog::MT_ERROR,tr("rc file parameter '%1' not found or empty.").arg(paramName)); + return ""; + } + return paramValue; +} + + + + +#include +typedef AExtensionPlugin aExtSERVICEPlugin; +A_EXPORT_PLUGIN( aExtSERVICEPlugin ) diff --git a/src/extensions/service/aextservice.h b/src/extensions/service/aextservice.h new file mode 100644 index 0000000..ef2c470 --- /dev/null +++ b/src/extensions/service/aextservice.h @@ -0,0 +1,29 @@ +#ifndef AEXTSERVICE_H +#define AEXTSERVICE_H + +#include "aextension.h" +#include "aobject.h" + +/** + * \ru + * \brief Сервисные функции для доступа из Скрипта. + * + * \_ru + */ +class ANANAS_EXPORT aExtSERVICE: public AExtension +{ + Q_OBJECT +public: + aExtSERVICE(); + ~aExtSERVICE(); + + +public slots: + QString GetOffice() const; + QString Generate() const; + + QString GetRcFileName() const; + QString GetRcValue( QString paramName ) const; +}; + +#endif diff --git a/src/extensions/service/service.pro b/src/extensions/service/service.pro new file mode 100644 index 0000000..60ac715 --- /dev/null +++ b/src/extensions/service/service.pro @@ -0,0 +1,28 @@ +TARGET = aextservice + +SOURCES += aextservice.cpp +HEADERS += aextservice.h + +include ( ../../ananas.pri ) + +shared { +win32:DEFINES+= ANANAS_DLL +} else { +win32:DEFINES += ANANAS_NO_DLL +} + +TEMPLATE =lib +CONFIG += plugin + +INCLUDEPATH += ../../lib +LIBS += -L../../lib -lananas + +LANGUAGE = C++ +win32:DESTDIR = .. + +unix{ + libext.path = $(LIBDIR)/ananas + libext.files = libaextservice.so + INSTALLS += libext +} +