Skip to content

Commit

Permalink
UNO Mail API refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
prrvchr committed Oct 30, 2023
1 parent 2b329af commit b62dd13
Show file tree
Hide file tree
Showing 30 changed files with 169 additions and 173 deletions.
Binary file modified eMailerOOo.oxt
Binary file not shown.
4 changes: 2 additions & 2 deletions source/eMailerOOo/META-INF/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
<manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data" manifest:full-path="OptionsDialog.xcu"/>
<manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-schema" manifest:full-path="Options.xcs"/>
<manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data" manifest:full-path="ProtocolHandler.xcu"/>
<manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=Python" manifest:full-path="service/MailServiceConfiguration.py"/>
<manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=Python" manifest:full-path="service/MailUser.py"/>
<manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=Python" manifest:full-path="service/MailMessage.py"/>
<manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=Python" manifest:full-path="service/MailServiceProvider.py"/>
<manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=Python" manifest:full-path="service/MailDispatcher.py"/>
<manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=Python" manifest:full-path="service/MailSpooler.py"/>
<manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=Python" manifest:full-path="service/OptionsHandler.py"/>
<manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=Python" manifest:full-path="service/SpoolerService.py"/>
</manifest:manifest>
Binary file modified source/eMailerOOo/dist/eMailerOOo.oxt
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
╚════════════════════════════════════════════════════════════════════════════════════╝
*/

#ifndef __com_sun_star_mail_SpoolerService_idl__
#define __com_sun_star_mail_SpoolerService_idl__
#ifndef __com_sun_star_mail_MailSpooler_idl__
#define __com_sun_star_mail_MailSpooler_idl__

#include <com/sun/star/mail/XSpoolerService.idl>
#include <com/sun/star/mail/XMailSpooler.idl>

module com { module sun { module star { module mail {

service SpoolerService: XSpoolerService
service MailSpooler: XMailSpooler
{

create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@
╚════════════════════════════════════════════════════════════════════════════════════╝
*/

#ifndef __com_sun_star_mail_MailServiceConfiguration_idl__
#define __com_sun_star_mail_MailServiceConfiguration_idl__
#ifndef __com_sun_star_mail_MailUser_idl__
#define __com_sun_star_mail_MailUser_idl__

module com { module sun { module star { module mail {

interface XMailServiceConfiguration;
interface XMailUser;

service MailServiceConfiguration : XMailServiceConfiguration
service MailUser : XMailUser
{
/**
Constructs an instance of a MailServiceConfiguration.
Constructs an instance of a MailUser.
This service use the Mozilla IspDB configuration as a backend.

@param sSender
[in] the e-mail address of the account used to send email with the XMailService.
The e-mail address has to conform to <a href="http://www.ietf.org/rfc/rfc822.txt">RFC&nbsp;822</a>.

@see com::sun::star::mail::XMailServiceProvider
@see com::sun::star::mail::XMailServiceConfiguration
@see com::sun::star::mail::XMailUser
*/
create([in] string sSender);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,16 @@
╚════════════════════════════════════════════════════════════════════════════════════╝
*/

#ifndef __com_sun_star_mail_XSpoolerService_idl__
#define __com_sun_star_mail_XSpoolerService_idl__
#ifndef __com_sun_star_mail_XMailSpooler_idl__
#define __com_sun_star_mail_XMailSpooler_idl__

#include <com/sun/star/uno/XInterface.idl>
#include <com/sun/star/mail/XSpoolerListener.idl>
#include <com/sun/star/io/XActiveDataControl.idl>

module com { module sun { module star { module mail {

interface XSpoolerService : com::sun::star::uno::XInterface
interface XMailSpooler : com::sun::star::io::XActiveDataControl
{

void start();
void stop();
boolean isStarted();

long addJob([in] string Sender,
Expand All @@ -58,9 +55,6 @@ interface XSpoolerService : com::sun::star::uno::XInterface
long getJobState([in] long JobId);
sequence<long> getJobIds([in] long BatchId);

void addListener([in] XSpoolerListener Listener);
void removeListener([in] XSpoolerListener Listener);

};

}; }; }; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
╚════════════════════════════════════════════════════════════════════════════════════╝
*/

#ifndef __com_sun_star_mail_XMailServiceConfiguration_idl__
#define __com_sun_star_mail_XMailServiceConfiguration_idl__
#ifndef __com_sun_star_mail_XMailUser_idl__
#define __com_sun_star_mail_XMailUser_idl__

#include <com/sun/star/uno/XInterface.idl>
#include <com/sun/star/mail/XAuthenticator.idl>
Expand All @@ -34,7 +34,7 @@

module com { module sun { module star { module mail {

interface XMailServiceConfiguration : com::sun::star::uno::XInterface
interface XMailUser : com::sun::star::uno::XInterface
{

boolean supportIMAP();
Expand Down
45 changes: 0 additions & 45 deletions source/eMailerOOo/idl/com/sun/star/mail/XSpoolerListener.idl

This file was deleted.

9 changes: 5 additions & 4 deletions source/eMailerOOo/resource/eMailer_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,17 @@
507=HsqlDB driver version %s is obsolete.%sYou need to update this driver to version %s or higher.
508=%s - Configuration error

1000=SpoolerService.start()
1001=Starting the SpoolerService
1000=MailSpooler.start()
1001=Starting the MailSpooler
1002=Email cannot be send, network is offline...
1003=SpoolerService is started.
1003=MailSpooler is started.

1010=Spooler.run()
1011=Start sending %s emails...
1012=Sending %s out of %s email(s)
1013=No email to send...
1014=SpoolerService stopped
1014=MailSpooler is closed
1015=MailSpooler has been stopped

1020=Spooler._sendMails()
1021=Start sending email N\u00ba: %s
Expand Down
9 changes: 5 additions & 4 deletions source/eMailerOOo/resource/eMailer_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,17 @@
507=La version %s du pilote HsqlDB est obsolète.%sVous devez mettre à jour ce pilote vers une version %s ou supérieure.
508=%s - Erreur de configuration

1000=SpoolerService.start()
1001=D\u00e9marrage de SpoolerService
1000=MailSpooler.start()
1001=D\u00e9marrage de MailSpooler
1002=Le courriel ne peut \u00eatre envoy\u00e9, le r\u00e9seau est hors ligne...
1003=SpoolerService \u00e0 d\u00e9marr\u00e9.
1003=MailSpooler \u00e0 d\u00e9marr\u00e9.

1010=Spooler.run()
1011=Debut d'envoi de %s courriel(s)...
1012=Envoi de %s courriel(s) sur %s
1013=Aucun courriel \u00e0 envoyer...
1014=SpoolerService est arr\u00eat\u00e9
1014=MailSpooler c'est fermé
1015=MailSpooler a été arret\u00e9

1020=Spooler._sendMails()
1021=Debut d'envoi du courriel N\u00ba: %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

from com.sun.star.lang import XServiceInfo

from com.sun.star.mail import XSpoolerService
from com.sun.star.mail import XMailSpooler

from com.sun.star.logging.LogLevel import INFO
from com.sun.star.logging.LogLevel import SEVERE
Expand All @@ -44,35 +44,35 @@

# pythonloader looks for a static g_ImplementationHelper variable
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationName = 'com.sun.star.mail.SpoolerService'
g_ImplementationName = 'com.sun.star.mail.MailSpooler'


class SpoolerService(unohelper.Base,
XServiceInfo,
XSpoolerService):
class MailSpooler(unohelper.Base,
XServiceInfo,
XMailSpooler):
def __init__(self, ctx):
if self._spooler is None:
with self._lock:
if self._spooler is None:
SpoolerService.__spooler = Spooler(ctx, self)
MailSpooler.__spooler = Spooler(ctx, self)

__lock = Lock()
__spooler = None
@property
def _lock(self):
return SpoolerService.__lock
return MailSpooler.__lock
@property
def _spooler(self):
return SpoolerService.__spooler
return MailSpooler.__spooler

# XSpoolerService
# XMailSpooler
def start(self):
if not self.isStarted():
self._spooler.start()

def stop(self):
def terminate(self):
if self.isStarted():
self._spooler.stop()
self._spooler.terminate()

def isStarted(self):
return self._spooler.isStarted()
Expand Down Expand Up @@ -107,6 +107,6 @@ def getSupportedServiceNames(self):
return g_ImplementationHelper.getSupportedServiceNames(g_ImplementationName)


g_ImplementationHelper.addImplementation(SpoolerService, # UNO object class
g_ImplementationHelper.addImplementation(MailSpooler, # UNO object class
g_ImplementationName, # Implementation name
(g_ImplementationName,)) # List of implemented services
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
import uno
import unohelper

from com.sun.star.mail import XMailServiceConfiguration
from com.sun.star.mail import XMailUser

from com.sun.star.lang import XServiceInfo

from emailer import DispatchListener
from emailer import MailUser
from emailer import User

from emailer import executeDispatch
from emailer import getPropertyValueSet
Expand All @@ -44,23 +44,23 @@

# pythonloader looks for a static g_ImplementationHelper variable
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationName = 'org.openoffice.pyuno.MailServiceConfiguration'
g_ImplementationName = 'org.openoffice.pyuno.MailUser'


class MailServiceConfiguration(unohelper.Base,
XServiceInfo,
XMailServiceConfiguration):
class MailUser(unohelper.Base,
XServiceInfo,
XMailUser):
def __init__(self, ctx, sender=''):
self._ctx = ctx
self._sender = sender
user = MailUser(ctx, sender)
user = User(ctx, sender)
if user.isNew():
self._user = None
else:
self._user = user
print("MailServiceConfiguration.__init__() Sender: %s" % sender)
print("MailUser.__init__() Sender: %s" % sender)

# XMailServiceConfiguration
# XMailUser
def supportIMAP(self):
if self._user is None:
self._initUser()
Expand All @@ -79,18 +79,18 @@ def getReplyToAddress(self):
def getAuthenticator(self, stype):
if self._user is None:
self._initUser()
print("MailServiceConfiguration.getAuthenticator() MailServerType: %s" % stype.value)
print("MailUser.getAuthenticator() MailServerType: %s" % stype.value)
return self._user.getAuthenticator(stype.value)

def getConnectionContext(self, stype):
if self._user is None:
self._initUser()
print("MailServiceConfiguration.getConnectionContext() MailServerType: %s" % stype.value)
print("MailUser.getConnectionContext() MailServerType: %s" % stype.value)
return self._user.getConnectionContext(stype.value)

# Internal method
def setUser(self, sender):
self._user = MailUser(self._ctx, sender)
self._user = User(self._ctx, sender)

def _initUser(self):
listener = DispatchListener(self.setUser)
Expand All @@ -106,6 +106,6 @@ def getSupportedServiceNames(self):
return g_ImplementationHelper.getSupportedServiceNames(g_ImplementationName)


g_ImplementationHelper.addImplementation(MailServiceConfiguration, # UNO object class
g_ImplementationHelper.addImplementation(MailUser, # UNO object class
g_ImplementationName, # Implementation name
('com.sun.star.mail.MailServiceConfiguration',)) # List of implemented services
('com.sun.star.mail.MailUser',)) # List of implemented services
2 changes: 1 addition & 1 deletion source/eMailerOOo/service/pythonpath/emailer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from .unotool import getPropertyValueSet
from .unotool import getConfiguration

from .mailuser import MailUser
from .user import User

from .maildispatch import MailDispatch

Expand Down
2 changes: 1 addition & 1 deletion source/eMailerOOo/service/pythonpath/emailer/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def getFilterValue(self, value, dbtype):
def getFilter(self, identifier, value, dbtype):
return '"%s" = %s' % (identifier, self.getFilterValue(value, dbtype))

# Procedures called by the SpoolerService
# Procedures called by the MailSpooler
def insertJob(self, sender, subject, document, recipient, attachment):
recipients = Array('VARCHAR', recipient)
attachments = Array('VARCHAR', attachment)
Expand Down
6 changes: 3 additions & 3 deletions source/eMailerOOo/service/pythonpath/emailer/dbqueries.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def getSqlQuery(ctx, name, format=None):
"""

# Delete Procedure Queries
# SpoolerService Delete Procedure Queries
# MailSpooler Delete Procedure Queries
elif name == 'createDeleteJobs':
query = """\
CREATE PROCEDURE "DeleteJobs"(IN JOBIDS INTEGER ARRAY)
Expand Down Expand Up @@ -312,7 +312,7 @@ def getSqlQuery(ctx, name, format=None):
END;"""

# Insert Procedure Queries
# SpoolerService Insert Procedure Queries
# MailSpooler Insert Procedure Queries
elif name == 'createInsertJob':
query = """\
CREATE PROCEDURE "InsertJob"(IN SENDER VARCHAR(320),
Expand Down Expand Up @@ -343,7 +343,7 @@ def getSqlQuery(ctx, name, format=None):
SET BATCHID = ID;
END;"""

# SpoolerService Insert Procedure Queries
# MailSpooler Insert Procedure Queries
elif name == 'createInsertMergeJob':
query = """\
CREATE PROCEDURE "InsertMergeJob"(IN SENDER VARCHAR(320),
Expand Down
Loading

0 comments on commit b62dd13

Please sign in to comment.