diff --git a/src/classlib/classlib.cbp b/src/classlib/classlib.cbp
index 342adfb..e7fb023 100644
--- a/src/classlib/classlib.cbp
+++ b/src/classlib/classlib.cbp
@@ -33,6 +33,7 @@
+
diff --git a/src/classlib/remote.cc b/src/classlib/remote.cc
index b1df909..e75cf88 100644
--- a/src/classlib/remote.cc
+++ b/src/classlib/remote.cc
@@ -667,7 +667,9 @@
#elif defined(HAVE_DBUS)
- rc = query_intval("connect", DBUS_TYPE_STRING, "", DBUS_TYPE_INVALID);
+ static const char * str = "";
+
+ rc = query_intval("connect", DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
#else
rc = -1;
diff --git a/src/classlib/session.cc b/src/classlib/session.cc
index 4f9f370..735907a 100644
--- a/src/classlib/session.cc
+++ b/src/classlib/session.cc
@@ -294,7 +294,7 @@
return -1;
}
- string * session::file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename)
+ string * session::file_chooser_dialog(int action, const char *title, const char *extension, const char *filename)
{
return NULL;
}
@@ -463,7 +463,7 @@
return string(ebc2asc(buffer,sz));
}
- int session::file_transfer(LIB3270_FT_OPTION options, const gchar *local, const gchar *remote, int lrecl, int blksize, int primspace, int secspace, int dft)
+ int session::file_transfer(LIB3270_FT_OPTION options, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft)
{
log("Can't transfer %s: File transfer is unavailable", local ? local : "file");
return EINVAL;
diff --git a/src/classlib/testprogram.cc b/src/classlib/testprogram.cc
index 028a738..482d0e6 100644
--- a/src/classlib/testprogram.cc
+++ b/src/classlib/testprogram.cc
@@ -59,6 +59,8 @@
cout << "\tHost charset: " << s->c_str() << endl;
delete s;
+ session->connect(false);
+
delete session;
return 0;
}
diff --git a/src/include/pw3270/class.h b/src/include/pw3270/class.h
index cc1bba8..b68c9c1 100644
--- a/src/include/pw3270/class.h
+++ b/src/include/pw3270/class.h
@@ -51,9 +51,15 @@
#include
#include
#include
- #include
#include
+ #ifdef DEBUG
+ #include
+ #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr);
+ #else
+ #define trace(x, ...) // __VA_ARGS__
+ #endif
+
#ifndef ETIMEDOUT
#define ETIMEDOUT 1238
#endif // !ETIMEDOUT
@@ -191,10 +197,10 @@
// Dialogs
virtual int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...);
- virtual string * file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename);
+ virtual string * file_chooser_dialog(int action, const char *title, const char *extension, const char *filename);
// File transfer
- virtual int file_transfer(LIB3270_FT_OPTION options, const gchar *local, const gchar *remote, int lrecl = 0, int blksize = 0, int primspace = 0, int secspace = 0, int dft = 4096);
+ virtual int file_transfer(LIB3270_FT_OPTION options, const char *local, const char *remote, int lrecl = 0, int blksize = 0, int primspace = 0, int secspace = 0, int dft = 4096);
// Charset translation
string * get_3270_text(string *str);
diff --git a/src/openoffice/Makefile.in b/src/openoffice/Makefile.in
index 12a7589..4d95ccf 100644
--- a/src/openoffice/Makefile.in
+++ b/src/openoffice/Makefile.in
@@ -25,9 +25,12 @@
#
PACKAGE_NAME=@PACKAGE_NAME@
-SOURCES=info.cc get.cc service.cc init.cc
+SOURCES=info.cc get.cc set.cc service.cc init.cc connect.cc
+
+UNO_CLASSES= /com/sun/star/uno/XWeak \
+ /com/sun/star/uno/RuntimeException \
+ /com/sun/star/lang/WrappedTargetException
-UNO_CLASSES=XWeak RuntimeException
#---[ LibreOffice SDK ]--------------------------------------------------------
@@ -73,6 +76,7 @@ BINRLS=$(BINDIR)/Release
#---[ lib3270 common class ]---------------------------------------------------
+DEBUG_CFLAGS=-DDEBUG=1 -g -Wall
PW3270_CFLAGS=-I../include
CLASSLIBDIR=../classlib
include $(CLASSLIBDIR)/class.mak
@@ -80,7 +84,7 @@ include $(CLASSLIBDIR)/class.mak
#---[ Build options ]----------------------------------------------------------
CPPUENV="gcc3"
-CXXFLAGS=@CXXFLAGS@ -fvisibility=hidden @DLL_CFLAGS@ -Wno-strict-aliasing -I./include -I$(includedir)/libreoffice -Wno-strict-aliasing -DCPPU_ENV=$(CPPUENV) -DLANGUAGE_BINDING_NAME=\"$(CPPUENV)\"
+CXXFLAGS=@CXXFLAGS@ -fvisibility=hidden @DLL_CFLAGS@ -Wno-strict-aliasing -I../include -I./include -I$(includedir)/libreoffice -Wno-strict-aliasing -DCPPU_ENV=$(CPPUENV) -DLANGUAGE_BINDING_NAME=\"$(CPPUENV)\"
OO_LDFLAGS=-L$(OO_SDK_HOME)/lib -L$(OO_SDK_URE_HOME)/lib \
-Wl,-rpath-link=$(OO_SDK_URE_HOME)/lib,-rpath=$(OO_SDK_URE_HOME)/lib \
@@ -109,7 +113,7 @@ include/%.hpp: $(RDBDIR)/%.rdb
@$(CPPUMAKER) -O./include $(TYPES_RDB) $<
$(OBJDBG)/%.o: %.cc include/$(PACKAGE_NAME)/lib3270.hpp \
- $(foreach CLS, $(basename $(UNO_CLASSES)), include/com/sun/star/uno/$(CLS).hpp) \
+ $(foreach CLS, $(UNO_CLASSES), include/$(CLS).hpp) \
*.hpp Makefile
@echo " CC `basename $@`"
@mkdir -p `dirname $@`
@@ -128,13 +132,13 @@ include/$(PACKAGE_NAME)/lib3270.hpp: $(RDBDIR)/$(PACKAGE_NAME).rdb
Debug: $(BINDBG)/$(PACKAGE_NAME).oxt
-add: $(BINDBG)/$(PACKAGE_NAME).oxt
+run: $(BINDBG)/$(PACKAGE_NAME).oxt
@SHARED=false $(UNOPKG) add --verbose --force $(BINDBG)/$(PACKAGE_NAME).oxt
+ @libreoffice testmacros.odt
+ @SHARED=false $(UNOPKG) remove $(PACKAGE_NAME)
-$(BINDBG)/testprogram: $(OBJDBG)/testprogram@OBJEXT@ $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@)
- @echo $@ ...
- @$(MKDIR) `dirname $@`
- $(CXX) -shared $(LDFLAGS) $(OO_LDFLAGS) -o $(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@ $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@)
+add: $(BINDBG)/$(PACKAGE_NAME).oxt
+ @SHARED=false $(UNOPKG) add --verbose --force $(BINDBG)/$(PACKAGE_NAME).oxt
$(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@: \
$(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) \
@@ -146,7 +150,7 @@ $(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@: \
$(BINDBG)/$(PACKAGE_NAME).oxt: \
$(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@ \
- $(PACKAGE_NAME).rdb \
+ $(RDBDIR)/$(PACKAGE_NAME).rdb \
description.xml \
manifest.xml \
description.txt
@@ -155,7 +159,7 @@ $(BINDBG)/$(PACKAGE_NAME).oxt: \
@$(MKDIR) $(BINDBG)/$(PACKAGE).oxt.tmp
- @cp $(PACKAGE_NAME).rdb $(BINDBG)/$(PACKAGE).oxt.tmp
+ @cp $(RDBDIR)/$(PACKAGE_NAME).rdb $(BINDBG)/$(PACKAGE).oxt.tmp
@cp $(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@ $(BINDBG)/$(PACKAGE).oxt.tmp
@$(MKDIR) $(BINDBG)/$(PACKAGE).oxt.tmp/META-INF
@@ -167,7 +171,6 @@ $(BINDBG)/$(PACKAGE_NAME).oxt: \
@$(CONVERT) ../$(PACKAGE_NAME)/pixmaps/$(PACKAGE_NAME).svg --format=png > $(BINDBG)/$(PACKAGE).oxt.tmp/$(PACKAGE_NAME).png
@cp $(BINDBG)/$(PACKAGE_NAME).uno@DLLEXT@ $(BINDBG)/$(PACKAGE_NAME).oxt.tmp
- @cp $(PACKAGE_NAME).rdb $(BINDBG)/$(PACKAGE_NAME).oxt.tmp
@cd $(BINDBG)/$(PACKAGE).oxt.tmp ; $(ZIP) -r -m ../$(PACKAGE_NAME).oxt .
@rm -fr $(BINDBG)/$(PACKAGE).oxt.tmp
@echo $@ Ok.
@@ -182,6 +185,7 @@ clean:
@rm -fr $(RDBDIR)
@rm -fr $(URDDIR)
@rm -fr include
+ @rm -f *.rdb
@rm -fr $(OBJDIR)
@rm -fr $(BINDIR)
diff --git a/src/openoffice/connect.cc b/src/openoffice/connect.cc
new file mode 100644
index 0000000..c21ca21
--- /dev/null
+++ b/src/openoffice/connect.cc
@@ -0,0 +1,87 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA, 02111-1307, USA
+ *
+ * Este programa está nomeado como connect.cc e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ *
+ */
+
+ #include "globals.hpp"
+ #include "pw3270/lib3270.hpp"
+ #include
+ #include
+
+/*---[ Implement ]-----------------------------------------------------------------------------------------*/
+
+ using namespace pw3270_impl;
+
+ ::sal_Int16 SAL_CALL session_impl::Connect() throw (::com::sun::star::uno::RuntimeException)
+ {
+ trace("%s: hSession=%p",__FUNCTION__,hSession);
+
+ try
+ {
+ if(!hSession)
+ hSession = h3270::session::get_default();
+
+ return hSession->connect(false);
+
+ } catch(std::exception &e)
+ {
+ trace("%s failed: %s",__FUNCTION__,e.what());
+
+ OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE);
+
+ throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this));
+
+ }
+
+ return -1;
+
+
+ }
+
+ ::sal_Int16 SAL_CALL session_impl::Disconnect() throw (::com::sun::star::uno::RuntimeException)
+ {
+ try
+ {
+ if(!hSession)
+ hSession = h3270::session::get_default();
+
+ return hSession->disconnect();
+
+ } catch(std::exception &e)
+ {
+ OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE);
+
+ throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this));
+
+ }
+
+ return -1;
+
+ }
+
+
diff --git a/src/openoffice/get.cc b/src/openoffice/get.cc
index c8d2a56..a1e9d68 100644
--- a/src/openoffice/get.cc
+++ b/src/openoffice/get.cc
@@ -32,6 +32,7 @@
*/
#include "globals.hpp"
+ #include
#include "pw3270/lib3270.hpp"
/*---[ Implement ]-----------------------------------------------------------------------------------------*/
@@ -40,5 +41,12 @@
::rtl::OUString session_impl::getVersion() throw (RuntimeException)
{
- return OUString( RTL_CONSTASCII_USTRINGPARAM("Testing") );
+ trace("%s: hSession=%p",__FUNCTION__,hSession);
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(PACKAGE_VERSION) );
+ }
+
+ ::rtl::OUString session_impl::getRevision() throw (RuntimeException)
+ {
+ trace("%s: hSession=%p",__FUNCTION__,hSession);
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(PACKAGE_REVISION) );
}
diff --git a/src/openoffice/globals.hpp b/src/openoffice/globals.hpp
index f449575..239b642 100644
--- a/src/openoffice/globals.hpp
+++ b/src/openoffice/globals.hpp
@@ -60,7 +60,15 @@
#include
+ #ifdef DEBUG
+ #include
+ #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr);
+ #else
+ #define trace(x, ...) // __VA_ARGS__
+ #endif
+
#include
+ #include
#define DLL_PUBLIC __attribute__((visibility("default")))
@@ -68,6 +76,7 @@
using namespace ::com::sun::star; // for sdk interfaces
using namespace ::com::sun::star::lang; // for sdk interfaces
using namespace ::com::sun::star::uno; // for basic types
+ using namespace PW3270_NAMESPACE;
namespace pw3270_impl
{
@@ -76,6 +85,9 @@
{
public:
+ session_impl();
+ virtual ~session_impl();
+
// XMain
virtual ::sal_Int32 SAL_CALL run( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aArguments ) throw (Exception);
@@ -89,6 +101,16 @@
// lib3270
virtual ::rtl::OUString SAL_CALL getVersion() throw (RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getRevision() throw (RuntimeException);
+
+ virtual ::sal_Int16 SAL_CALL setSessionName( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::sal_Int16 SAL_CALL setHost( const ::rtl::OUString& url ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL Connect() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL Disconnect() throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ h3270::session *hSession;
};
diff --git a/src/openoffice/init.cc b/src/openoffice/init.cc
index 0b725d5..2f075a8 100644
--- a/src/openoffice/init.cc
+++ b/src/openoffice/init.cc
@@ -39,6 +39,19 @@
using namespace pw3270_impl;
+
+session_impl::session_impl()
+{
+ this->hSession = NULL;
+}
+
+session_impl::~session_impl()
+{
+ if(this->hSession)
+ delete this->hSession;
+}
+
+
// XInitialization implementation
void session_impl::initialize( Sequence< Any > const & args ) throw (Exception)
{
@@ -52,6 +65,9 @@ void session_impl::initialize( Sequence< Any > const & args ) throw (Exception)
// Initialize
+ // TODO: Get arguments.
+
+
}
// XMain
diff --git a/src/openoffice/loffice3270.cbp b/src/openoffice/loffice3270.cbp
index db6c3b3..3d11352 100644
--- a/src/openoffice/loffice3270.cbp
+++ b/src/openoffice/loffice3270.cbp
@@ -33,13 +33,16 @@
+
+
+
@@ -49,6 +52,7 @@
+
diff --git a/src/openoffice/pw3270.idl b/src/openoffice/pw3270.idl
index 6286c7d..5952450 100644
--- a/src/openoffice/pw3270.idl
+++ b/src/openoffice/pw3270.idl
@@ -43,7 +43,17 @@ module pw3270
*/
interface lib3270 : com::sun::star::uno::XInterface
{
+ // Constants
string getVersion();
+ string getRevision();
+
+ // Host definition
+ short setHost([in] string url);
+ short Connect();
+ short Disconnect();
+
+ // Misc Settings
+ short setSessionName([in] string name);
};
service session
diff --git a/src/openoffice/set.cc b/src/openoffice/set.cc
new file mode 100644
index 0000000..e025a9a
--- /dev/null
+++ b/src/openoffice/set.cc
@@ -0,0 +1,99 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA, 02111-1307, USA
+ *
+ * Este programa está nomeado como get.cc e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ * Referência:
+ *
+ * https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/Class_Definition_with_Helper_Template_Classes
+ *
+ */
+
+ #include "globals.hpp"
+ #include
+ #include
+ #include "pw3270/lib3270.hpp"
+
+/*---[ Implement ]-----------------------------------------------------------------------------------------*/
+
+ using namespace pw3270_impl;
+ using namespace com::sun::star::uno;
+
+ ::sal_Int16 SAL_CALL session_impl::setSessionName( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ if(hSession)
+ {
+ // Remove old session
+ delete hSession;
+ hSession = NULL;
+ }
+
+ OString vlr = rtl::OUStringToOString( name , RTL_TEXTENCODING_UNICODE );
+
+ trace("%s(\"%s\")",__FUNCTION__,vlr.getStr());
+
+ try
+ {
+
+ hSession = h3270::session::create(((const char *) vlr.getStr()));
+ trace("%s: hSession(\"%s\"=%p",__FUNCTION__,vlr.getStr(),hSession);
+
+ } catch(std::exception &e)
+ {
+ OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE);
+
+ throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this));
+
+ return -1;
+
+ }
+
+ return 0;
+
+ }
+
+ ::sal_Int16 SAL_CALL session_impl::setHost( const ::rtl::OUString& url ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ if(!hSession)
+ hSession = h3270::session::get_default();
+
+ OString vlr = rtl::OUStringToOString( url , RTL_TEXTENCODING_UNICODE );
+
+ try
+ {
+
+ return hSession->set_url(vlr.getStr());
+
+ } catch(std::exception &e)
+ {
+ OUString msg = OUString(e.what(),strlen(e.what()),RTL_TEXTENCODING_UTF8,RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE);
+
+ throw css::uno::RuntimeException(msg,static_cast< cppu::OWeakObject * >(this));
+
+ }
+
+ return -1;
+ }
+
diff --git a/src/openoffice/testmacros.odt b/src/openoffice/testmacros.odt
index e3585e7..35a28a7 100644
Binary files a/src/openoffice/testmacros.odt and b/src/openoffice/testmacros.odt differ
--
libgit2 0.21.2