Commit c6b366b2 authored by Sebastien Robin's avatar Sebastien Robin

- add vcard and mobile phone support

- clean some parts


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15529 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3a40f0f5
......@@ -84,16 +84,6 @@ class Subscriber(Subscription):
Send ACK for a group of documents
"""
def getConduit(self):
"""
Return the conduit of the publication
"""
#LOG('Subscriber.getConduit, self.getPhysicalPath()',0,self.getPhysicalPath())
#LOG('Subscriber.getConduit, self.getParent().getPhysicalPath()',0,self.aq_parent.getPhysicalPath())
#LOG('Subscriber.getConduit, self.getParent()',0,self.getParent())
return self.aq_parent.getConduit()
#return self.conduit
def SendDocuments(self):
"""
We send all the updated documents (ie. documents not marked
......@@ -155,7 +145,8 @@ class Publication(Subscription):
def __init__(self, id, title, publication_url, destination_path,
source_uri, query, xml_mapping, conduit, gpg_key, id_generator,
gid_generator, media_type, auth_required, authentication_format,
authentication_type, activity_enabled):
authentication_type, activity_enabled, synchronize_with_erp5_sites,
sync_content_type):
"""
constructor
"""
......@@ -178,6 +169,8 @@ class Publication(Subscription):
self.auth_required = auth_required
self.authentication_format = authentication_format
self.authentication_type = authentication_type
self.setSyncContentType(sync_content_type)
self.setSynchronizeWithERP5Sites(synchronize_with_erp5_sites)
def getPublicationUrl(self):
"""
......@@ -238,6 +231,7 @@ class Publication(Subscription):
"""
Add a new subscriber to the publication
"""
LOG('addSubscriber starting ...',0,'')
# We have to remove the subscriber if it already exist (there were probably a reset on the client)
self.delSubscriber(subscriber.getSubscriptionUrl())
new_id = subscriber.getId()
......
......@@ -575,6 +575,7 @@ def addSubscription( self, id, title='', REQUEST=None ):
"""
Add a new Subscribption
"""
LOG('addSubscription starting...',0,'')
o = Subscription( id ,'','','','','','')
self._setObject( id, o )
if REQUEST is not None:
......@@ -648,7 +649,8 @@ class Subscription(Folder, SyncCode):
def __init__(self, id, title, publication_url, subscription_url,
destination_path, source_uri, target_uri, query, xml_mapping,
conduit, gpg_key, id_generator, gid_generator, media_type, login,
password, activity_enabled, alert_code):
password, activity_enabled, alert_code, synchronize_with_erp5_sites,
sync_content_type):
"""
We need to create a dictionnary of
signatures of documents which belong to the synchronisation
......@@ -679,7 +681,8 @@ class Subscription(Folder, SyncCode):
self.setConduit(conduit)
Folder.__init__(self, id)
self.title = title
self.setSyncContentType(sync_content_type)
self.setSynchronizeWithERP5Sites(synchronize_with_erp5_sites)
#self.signatures = PersitentMapping()
def getAlertCodeList(self):
......@@ -727,7 +730,7 @@ class Subscription(Folder, SyncCode):
def getSourceURI(self):
"""
getter for the source_uri (the local path of the subscription)
getter for the source_uri (the local path of the subscription data base)
"""
return getattr(self, 'source_uri', None)
......@@ -739,11 +742,26 @@ class Subscription(Folder, SyncCode):
def getTargetURI(self):
"""
getter for the target_uri (the distant Publication we want to synchronize
with)
getter for the target_uri (the distant Publication data base we want to
synchronize with)
"""
return getattr(self, 'target_uri', None)
def setSyncContentType(self, sync_content_type):
"""
content type used by the subscriber
"""
self.sync_content_type=sync_content_type
# the varible name is sync_content_type instead of content_type because
# content_type seems to be a function name already used
def getSyncContentType(self):
"""
getter of the subscriber sync_content_type
"""
return getattr(self, 'sync_content_type', 'application/vnd.syncml+xml')
def getSynchronizationType(self, default=None):
"""
"""
......@@ -770,6 +788,21 @@ class Subscription(Folder, SyncCode):
value = None
self.xml_mapping = value
def setSynchronizeWithERP5Sites(self, synchronize_with_erp5_sites):
"""
if the synchronisation is made with another ERP5 site,
synchronize_with_erp5_sites is True, False in other case
XXX in the future, the method used to sendHttpResponse will be the same
in all cases, so this method will be useless
"""
self.synchronize_with_erp5_sites = synchronize_with_erp5_sites
def getSynchronizeWithERP5Sites(self):
"""
return True if the synchronisation is between two erp5 sites
"""
return getattr(self, 'synchronize_with_erp5_sites', None)
def checkCorrectRemoteSessionId(self, session_id):
"""
We will see if the last session id was the same
......@@ -886,7 +919,7 @@ class Subscription(Folder, SyncCode):
def setPublicationUrl(self, publication_url):
"""
return the publication url
set the publication url
"""
self.publication_url = publication_url
......@@ -1058,6 +1091,30 @@ class Subscription(Folder, SyncCode):
break
return o
def getObjectFromRid(self, rid):
"""
return the object corresponding to the id
"""
signature = self.getSignatureFromRid(rid)
destination = self.getDestination()
o = None
if signature is not None and signature.getPath() is not None:
try:
o = destination.getPortalObject().restrictedTraverse(signature.getPath())
except:
pass
return o
# def setOneWaySyncFromServer(self,value):
# """
# If this option is enabled, then we will not
# send our own modifications
# """
# self.one_way_sync_from_server = value
#
def getObjectList(self, **kw):
"""
This returns the list of sub-object corresponding
......
......@@ -75,7 +75,8 @@ class SubscriptionSynchronization(XMLSyncUtils):
self.sendResponse(from_url=subscription.subscription_url,
to_url=subscription.publication_url, sync_id=subscription.getTitle(),
xml=xml_a,domain=subscription)
xml=xml_a,domain=subscription,
content_type=subscription.getSyncContentType())
return {'has_response':1,'xml':xml_a}
......@@ -86,7 +87,7 @@ class SubscriptionSynchronization(XMLSyncUtils):
response = None #check if subsync replies to this messages
subscription = self.unrestrictedTraverse(subscription_path)
if msg==None and (subscription.getSubscriptionUrl()).find('file')>=0:
msg = self.readResponse(sync_id=subscription.getSourceURI(),
msg = self.readResponse(sync_id=subscription.getSubscriptionUrl(),
from_url=subscription.getSubscriptionUrl())
if msg==None:
response = self.SubSyncInit(subscription)
......@@ -170,7 +171,8 @@ class SubscriptionSynchronization(XMLSyncUtils):
self.sendResponse(from_url=subscription.subscription_url,
to_url=subscription.publication_url, sync_id=subscription.getTitle(),
xml=xml_a,domain=subscription)
xml=xml_a,domain=subscription,
content_type=subscription.getSyncContentType())
return {'has_response':1,'xml':xml_a}
......
......@@ -37,8 +37,9 @@ class SyncCode(Persistent):
# SyncML Alert Codes
TWO_WAY = 200
SLOW_SYNC = 201 # This means we get the data from the publication
WAITING_DATA = 214
ONE_WAY_FROM_SERVER = 204
WAITING_DATA = 214
REFRESH_REQUIRED = 508
# SyncML Status Codes
SUCCESS = 200
......@@ -121,3 +122,9 @@ class SyncCode(Persistent):
MEDIA_TYPE = {}
MEDIA_TYPE['TEXT_XML'] = 'text/xml'
MEDIA_TYPE['TEXT_VCARD'] = 'text/vcard'
MEDIA_TYPE['TEXT_XVCARD'] = 'text/x-vcard'
#content types :
CONTENT_TYPE = {}
CONTENT_TYPE['SYNCML_XML'] = 'application/vnd.syncml+xml'
CONTENT_TYPE['SYNCML_WBXML'] = 'application/vnd.syncml+wbxml'
This diff is collapsed.
This diff is collapsed.
......@@ -55,6 +55,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<b>Query :</b> the type of objects you want to synchronize</br>
<b>XML Mapping :</b> the page template used on each object before
an export</br>
<b>Synchronize with other ERP5 sites :</b> The method currently used
to send data to erp5 and external sites is not the same (it will be
improved soon)</br>
<b>Content Type :</b> the type of content use to exchange data
(could be 'application/vnd.syncml+wbxml' or
'application/vnd.syncml+xml' for example)</br>
<b>Conduit :</b> the conduit used to synchronize</br>
<b>GPG key name :</b>a name of gpg key to use</br>
<b>Id Generator :</b> This set the method name wich allows to
......@@ -80,6 +86,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<b>Query :</b> the type of objects you want to synchronize</br>
<b>XML Mapping :</b> the page template used on each object before
an export</br>
<b>Synchronize with other ERP5 sites :</b> The method currently used
to send data to erp5 and external sites is not the same (it will be
improved soon)</br>
<b>Content Type :</b> the type of content use to exchange data
(could be 'application/vnd.syncml+wbxml' or
'application/vnd.syncml+xml' for example)</br>
<b>Conduit :</b> the conduit used to synchronize</br>
<b>GPG key name :</b>a name of gpg key to use</br>
<b>Id Generator :</b> This set the method name wich allows to
......
......@@ -108,6 +108,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="xml_mapping" value="<dtml-var getXMLMapping>" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Synchronize with other ERP5 sites
</label></div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="synchronize_with_erp5_sites" value="1" <dtml-if expr="getSynchronizeWithERP5Sites()">CHECKED</dtml-if>>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Content Type
</label></div>
</td>
<td align="left" valign="top">
<input type="text" name="sync_content_type" value="<dtml-var getSyncContentType>" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
......
......@@ -144,6 +144,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="xml_mapping" value="<dtml-var getXMLMapping>" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Synchronize with other ERP5 sites
</label></div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="synchronize_with_erp5_sites" value="1" <dtml-if expr="getSynchronizeWithERP5Sites()">CHECKED</dtml-if>>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Content Type
</label></div>
</td>
<td align="left" valign="top">
<input type="text" name="sync_content_type" value="<dtml-var getSyncContentType>" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
......
......@@ -103,6 +103,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="xml_mapping" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Synchronize with other ERP5 sites
</label></div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="synchronize_with_erp5_sites" value="1">
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Content Type
</label></div>
</td>
<td align="left" valign="top">
<input type="text" name="sync_content_type" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
......
......@@ -140,6 +140,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="xml_mapping" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Synchronize with other ERP5 sites
</label></div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="synchronize_with_erp5_sites" value="1">
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Content Type
</label></div>
</td>
<td align="left" valign="top">
<input type="text" name="sync_content_type" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment