Skip to content

Commit

Permalink
many many fix
Browse files Browse the repository at this point in the history
  • Loading branch information
prrvchr committed Oct 29, 2023
1 parent d913066 commit 2b329af
Show file tree
Hide file tree
Showing 18 changed files with 268 additions and 248 deletions.
Binary file modified eMailerOOo.oxt
Binary file not shown.
Binary file modified source/eMailerOOo/dist/eMailerOOo.oxt
Binary file not shown.
8 changes: 5 additions & 3 deletions source/eMailerOOo/eMailerOOo/DialogStrings_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,11 @@ MergerPage1.Label7.Label=Error loading data source
MergerPage1.Label8.HelpText=
MergerPage1.Label8.Label=
MergerPage1.Label8.Label.0=An error occurred while loading the data source: <%s>\n%s
MergerPage1.Label8.Label.1=Could not load data source, file:\n<%s>\ndoes not exist!!!
MergerPage1.Label8.Label.2=Cannot use data source, it does not provide the UNO service: %s!!!
MergerPage1.Label8.Label.3=Cannot use data source, it does not support the UNO interface: %s!!!
MergerPage1.Label8.Label.1=Could not load data source, <%s> it does not exist!!!
MergerPage1.Label8.Label.2=Could not load data source, file:\n<%s>\nis not an odb file!!!
MergerPage1.Label8.Label.3=Could not load data source, file:\n<%s>\ndoes not exist!!!
MergerPage1.Label8.Label.4=Cannot use data source, it does not provide the UNO service: %s!!!
MergerPage1.Label8.Label.5=Cannot use data source, it does not support the UNO interface: %s!!!
MergerPage1.Label9.HelpText=Select or add a mailing list
MergerPage1.Label9.Label=Available mailing lists
MergerPage1.Label10.HelpText=Select, add or delete a mailing list
Expand Down
8 changes: 5 additions & 3 deletions source/eMailerOOo/eMailerOOo/DialogStrings_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,11 @@ MergerPage1.Label7.Label=Erreur lors du chargement de la source de donn\u00e9es
MergerPage1.Label8.HelpText=
MergerPage1.Label8.Label=
MergerPage1.Label8.Label.0=Une erreur c'est produite lors du chargement de la source de donn\u00e9es: <%s>\n%s
MergerPage1.Label8.Label.1=Impossible de charger la source de donn\u00e9es, le fichier:\n<%s>\nn'existe pas!!!
MergerPage1.Label8.Label.2=Impossible d'utiliser la source de donn\u00e9es, elle ne fournit pas le service UNO: %s!!!
MergerPage1.Label8.Label.3=Impossible d'utiliser la source de donn\u00e9es, elle ne poss\u00e8de pas l'interface UNO: %s!!!
MergerPage1.Label8.Label.1=Impossible de charger la source de donn\u00e9es: <%s> elle n'existe pas!!!
MergerPage1.Label8.Label.2=Impossible de charger la source de donn\u00e9es, le fichier:\n<%s>\nn'est pas un fichier odb!!!
MergerPage1.Label8.Label.3=Impossible de charger la source de donn\u00e9es, le fichier:\n<%s>\nn'existe pas!!!
MergerPage1.Label8.Label.4=Impossible d'utiliser la source de donn\u00e9es, elle ne fournit pas le service UNO: %s!!!
MergerPage1.Label8.Label.5=Impossible d'utiliser la source de donn\u00e9es, elle ne poss\u00e8de pas l'interface UNO: %s!!!
MergerPage1.Label9.HelpText=S\u00e9lectionner ou ajouter une liste de diffusion
MergerPage1.Label9.Label=Listes de diffusion disponibles
MergerPage1.Label10.HelpText=S\u00e9lectionner, ajouter ou supprimer une liste de diffusion
Expand Down
30 changes: 20 additions & 10 deletions source/eMailerOOo/resource/eMailer_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@
1011=Start sending %s emails...
1012=Sending %s out of %s email(s)
1013=No email to send...
1014=Error in MailSpooler._run(): %s
1015=SpoolerService stopped
1014=SpoolerService stopped

1020=Spooler._sendMails()
1021=Start sending email N\u00ba: %s
1022=Sending email N\u00ba: %s aborted!!!
1023=End sending email N\u00ba: %s
1023=Error: While sending the email N\u00ba: %s the error occurred: %s
1024=Error: While sending the email N\u00ba: %s the error occurred: %s with trace:\n%s
1025=End sending email N\u00ba: %s

1030=Spooler._getThreadMessage()
1031=%s - Document merge N\u00ba: %s of: %s
Expand All @@ -145,15 +146,24 @@
1040=Spooler._getMailServer()
1041=Email N\u00ba: %s cannot be send, Unable to connect with account: %s to server %s - Error: %s

1050=Spooler._viewJob()
1051=Start writing the email N\u00ba: %s
1052=End writing email N\u00ba: %s
1050=Spooler._getMail()
1051=Error: Unable to start composing an email, no job ID was provided!!!
1052=Start composing the email N\u00ba: %s
1053=Error: While composing the email N\u00ba: %s the error occurred: %s
1054=Error: While composing the email N\u00ba: %s the error occurred: %s with trace:\n%s
1055=End composing the email N\u00ba: %s

1060=Mailer.setBatch()
1061=Email N\u00ba: %s cannot be send, the Document: %s dont exist...
1500=Mailer._getDescriptors()
1501=Could not load data source: <%s> it does not exist!!!
1502=Could not load data source, file: <%s> is not an odb file!!!
1503=Could not load data source, file: <%s> does not exist!!!
1504=Could not load data source: <%s>, the table: <%s> does not exist!!!

1070=Mailer._getMailUrl()
1071=Email N\u00ba: %s cannot be send, the attachment: %s dont exist...
1510=Mailer._initMailer()
1511=Error: While composing the email N\u00ba: %s, the Document: %s dont exist...

1520=Mailer._getMailAttachmentUrl()
1521=Error: While composing the email N\u00ba: %s, the attachment: %s dont exist...

2000=SpoolerManager.clearLog()
2001=Starting the SpoolerLogger
30 changes: 20 additions & 10 deletions source/eMailerOOo/resource/eMailer_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@
1011=Debut d'envoi de %s courriel(s)...
1012=Envoi de %s courriel(s) sur %s
1013=Aucun courriel \u00e0 envoyer...
1014=Erreur dans MailSpooler._run(): %s
1015=SpoolerService est arr\u00eat\u00e9
1014=SpoolerService est arr\u00eat\u00e9
1020=Spooler._sendMails()
1021=Debut d'envoi du courriel N\u00ba: %s
1022=L'envoi du courriel N\u00ba: %s a \u00e9t\u00e9 annul\u00e9!!!
1023=Fin d'envoi du courriel N\u00ba: %s
1023=Erreur: Lors de l'envoi du courriel N\u00ba: %s il s'est produit l'erreur: %s
1024=Erreur: Lors de l'envoi du courriel N\u00ba: %s il s'est produit l'erreur: %s avec la trace:\n%s
1025=Fin d'envoi du courriel N\u00ba: %s

1030=Spooler._getThreadMessage()
1031=%s - Publipostage N\u00ba: %s de: %s
Expand All @@ -145,15 +146,24 @@
1040=Spooler._getMailServer()
1041=Le courriel N\u00ba: %s ne peut \u00eatre envoy\u00e9, Impossible de se connecter avec le compte: %s au serveur %s - Erreur: %s

1050=Spooler._viewJob()
1051=D\u00e9but de la r\u00e9daction du courriel N\u00ba: %s
1052=Fin de la r\u00e9daction du courriel N\u00ba: %s
1050=Spooler._getMail()
1051=Erreur : Impossible de commencer à r\u00e9diger un courriel, aucun ID de travail n'a \u00e9t\u00e9 fourni!!!
1052=D\u00e9but de la r\u00e9daction du courriel N\u00ba: %s
1053=Erreur: Lors de la r\u00e9daction du courriel N\u00ba: %s il s'est produit l'erreur: %s
1054=Erreur: Lors de la r\u00e9daction du courriel N\u00ba: %s il s'est produit l'erreur: %s avec la trace:\n%s
1055=Fin de la r\u00e9daction du courriel N\u00ba: %s
1060=Mailer.setBatch()
1061=Le courriel N\u00ba: %s ne peut \u00eatre envoy\u00e9, le Document: %s n'existe pas...
1500=Mailer._getDescriptors()
1501=Impossible de charger la source de donn\u00e9es: <%s> elle n'existe pas!!!
1502=Impossible de charger la source de donn\u00e9es, le fichier: <%s> n'est pas un fichier odb!!!
1503=Impossible de charger la source de donn\u00e9es, le fichier: <%s> n'existe pas!!!
1503=Impossible de charger la source de donn\u00e9es: <%s> la table: <%s> n'existe pas!!!
1070=Mailer._getMailUrl()
1071=Le courriel N\u00ba: %s ne peut \u00eatre envoy\u00e9, le fichier joint: %s n'existe pas...
1510=Mailer._initMailer()
1511=Erreur: Lors de la r\u00e9daction du courriel N\u00ba: %s, le Document: %s n'existe pas...

1520=Mailer._getMailAttachmentUrl()
1521=Erreur: Lors de la r\u00e9daction du courriel N\u00ba: %s, le fichier joint: %s n'existe pas...
2000=SpoolerManager.clearLog()
2001=D\u00e9marrage de SpoolerLogger
2 changes: 1 addition & 1 deletion source/eMailerOOo/service/MailDispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def initialize(self, args):
# XDispatchProvider
def queryDispatch(self, url, frame, flags):
dispatch = None
if url.Path in ('ispdb', 'spooler', 'mailer', 'merger', 'viewer'):
if url.Path in ('ispdb', 'spooler', 'mailer', 'merger', 'mail'):
parent = self._frame.getContainerWindow()
dispatch = MailDispatch(self._ctx, parent)
return dispatch
Expand Down
2 changes: 1 addition & 1 deletion source/eMailerOOo/service/SpoolerService.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, ctx):
if self._spooler is None:
with self._lock:
if self._spooler is None:
SpoolerService.__spooler = Spooler(ctx)
SpoolerService.__spooler = Spooler(ctx, self)

__lock = Lock()
__spooler = None
Expand Down
11 changes: 2 additions & 9 deletions source/eMailerOOo/service/pythonpath/emailer/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,11 @@ def updateRecipient(self, state, messageid, jobid):
call = self._getCall('updateRecipient')
call.setInt(1, state)
call.setString(2, messageid)
call.setInt(3, jobid)
call.setTimestamp(3, getDateTime(False))
call.setInt(4, jobid)
state = call.executeUpdate()
call.close()

def setBatchState(self, state, batchid):
call = self._getCall('setBatchState')
call.setInt(1, state)
call.setTimestamp(2, getDateTime())
call.setInt(3, batchid)
result = call.executeUpdate()
call.close()

# Procedures called internally
def _initialize(self, connection, odb):
sleep(0.2)
Expand Down
17 changes: 7 additions & 10 deletions source/eMailerOOo/service/pythonpath/emailer/dbqueries.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def getSqlQuery(ctx, name, format=None):
s10 = '"Senders"."Table"'
s11 = '"Recipients"."Filter"'
s12 = '"Senders"."Created"'
s13 = '"Recipients"."Created"'
s13 = '"Recipients"."Modified"'
s = (s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13)
f1 = '"Senders"'
f2 = 'JOIN "Recipients" ON "Senders"."BatchId"="Recipients"."BatchId"'
Expand Down Expand Up @@ -229,10 +229,7 @@ def getSqlQuery(ctx, name, format=None):
# Update Queries
# MailSpooler Update Queries
elif name == 'updateRecipient':
query = 'UPDATE "Recipients" SET "State"=?, "MessageId"=?, "Modified"=DEFAULT WHERE "JobId"=?;'

elif name == 'setBatchState':
query = 'UPDATE "Recipients" SET "State"=?, "Modified"=? WHERE "BatchId"=?;'
query = 'UPDATE "Recipients" SET "State"=?, "MessageId"=?, "Modified"=? WHERE "JobId"=?;'

# Function creation Queries
# IspDb Function Queries
Expand Down Expand Up @@ -281,11 +278,11 @@ def getSqlQuery(ctx, name, format=None):
DYNAMIC RESULT SETS 1
BEGIN ATOMIC
DECLARE RSLT CURSOR WITH RETURN FOR
SELECT S."Sender",S."Subject",S."Document",
S."DataSource",S."Query",S."Table",S."ThreadId",
CASE WHEN S."DataSource" IS NULL THEN FALSE ELSE TRUE END AS "Merge"
FROM "Senders" AS S
WHERE S."BatchId"=BATCHID
SELECT "Sender", "Subject", "Document",
"DataSource", "Query", "Table", "ThreadId",
CASE WHEN "DataSource" IS NULL OR "Query" IS NULL OR "Table" IS NULL THEN FALSE ELSE TRUE END AS "Merge"
FROM "Senders"
WHERE "BatchId"=BATCHID
FOR READ ONLY;
OPEN RSLT;
END;"""
Expand Down
59 changes: 29 additions & 30 deletions source/eMailerOOo/service/pythonpath/emailer/maildispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
from com.sun.star.frame.DispatchResultState import SUCCESS
from com.sun.star.frame.DispatchResultState import FAILURE

from com.sun.star.uno import Exception as UnoException

from com.sun.star.ui.dialogs.ExecutableDialogResults import OK

from com.sun.star.logging.LogLevel import INFO
Expand All @@ -56,9 +58,7 @@

from .unotool import createMessageBox
from .unotool import getPathSettings
from .unotool import getSimpleFile
from .unotool import getStringResource
from .unotool import getTempFile

from .logger import getLogger
from .logger import RollerHandler
Expand Down Expand Up @@ -109,8 +109,8 @@ def dispatch(self, url, arguments):
state, result = self._showMailer(arguments)
elif url.Path == 'merger':
state, result = self._showMerger()
elif url.Path == 'viewer':
state, result = self._viewMail(arguments)
elif url.Path == 'mail':
state, result = self._getMail(arguments)
return state, result

def addStatusListener(self, listener, url):
Expand Down Expand Up @@ -206,34 +206,33 @@ def _showMerger(self):
print(msg)

#Viewer methods
def _viewMail(self, arguments):
try:
state = FAILURE
job = None
url = ''
for argument in arguments:
if argument.Name == 'JobId':
job = argument.Value
if job is not None:
logger = getLogger(self._ctx, g_spoolerlog)
handler = RollerHandler(self._ctx, logger.Name)
logger.addRollerHandler(handler)
logger.logprb(INFO, 'MailSpooler', '_viewMail()', 1051, job)
mailer = Mailer(self._ctx, self._getDataSource().DataBase, logger)
def _getMail(self, arguments):
state = FAILURE
mail = None
job = None
for argument in arguments:
if argument.Name == 'JobId':
job = argument.Value
logger = getLogger(self._ctx, g_spoolerlog)
handler = RollerHandler(self._ctx, logger.Name)
logger.addRollerHandler(handler)
if job is None:
logger.logprb(SEVERE, 'MailSpooler', '_getMail()', 1051)
else:
logger.logprb(INFO, 'MailSpooler', '_getMail()', 1052, job)
mailer = Mailer(self._ctx, self, self._getDataSource().DataBase, logger)
try:
mail = mailer.getMail(job)
url = '%s/Email.eml' % getTempFile(self._ctx).Uri
output = getSimpleFile(self._ctx).openFileWrite(url)
output.writeBytes(uno.ByteSequence(mail.asBytes()))
output.flush()
output.closeOutput()
mailer.dispose()
logger.logprb(INFO, 'MailSpooler', '_viewMail()', 1052, job)
logger.removeRollerHandler(handler)
except UnoException as e:
logger.logprb(SEVERE, 'MailSpooler', '_getMail()', 1053, job, e.Message)
except Exception as e:
logger.logprb(SEVERE, 'MailSpooler', '_getMail()', 1054, job, str(e), traceback.format_exc())
else:
logger.logprb(INFO, 'MailSpooler', '_getMail()', 1055, job)
state = SUCCESS
return state, url
except Exception as e:
msg = "Error: %s - %s" % (e, traceback.format_exc())
print(msg)
mailer.dispose()
logger.removeRollerHandler(handler)
return state, mail

# Private methods
def _isInitialized(self):
Expand Down
21 changes: 21 additions & 0 deletions source/eMailerOOo/service/pythonpath/emailer/mailertool.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

from com.sun.star.sdbc import SQLException

from com.sun.star.uno import Exception as UnoException

from .database import DataBase

from .datasource import DataSource
Expand All @@ -40,6 +42,7 @@
from .unotool import getFileSequence
from .unotool import getPathSettings
from .unotool import getPropertyValueSet
from .unotool import getSimpleFile
from .unotool import getTypeDetection
from .unotool import getUrl

Expand Down Expand Up @@ -88,6 +91,24 @@ def getDataSource(ctx, method, sep, callback):
return DataSource(ctx, database)
return None

def getDataBaseContext(ctx, source, name, resolver, code, *format):
dbcontext = createService(ctx, 'com.sun.star.sdb.DatabaseContext')
if not dbcontext.hasByName(name):
msg = resolver(code, name, *format)
raise UnoException(msg, source)
location = dbcontext.getDatabaseLocation(name)
# FIXME: The location can be an embedded database in odt file
# FIXME: ie: vnd.sun.star.pkg://file://path/document.odt/EmbeddedDatabase
# FIXME: eMailerOOo cannot work with such a datasource
if not location.startswith('file://'):
msg = resolver(code +1, location, *format)
raise UnoException(msg, source)
# We need to check if the registered datasource has an existing odb file
if not getSimpleFile(ctx).exists(location):
msg = resolver(code +2, location, *format)
raise UnoException(msg, source)
return dbcontext, location

def getMessageImage(ctx, url):
lenght, sequence = getFileSequence(ctx, url)
img = base64.b64encode(sequence.value).decode('utf-8')
Expand Down
Loading

0 comments on commit 2b329af

Please sign in to comment.