Exemplo n.º 1
0
 def retrieveEvent(self, identifier):
     # Returns the object or None if nothing is received.
     retrieveObject = DomainObjectRetrieve(self.refId)
     retrieveObject.identifiers = [identifier]
     retrieveCompleted = self.getResponseForRequest(retrieveObject)
     returnObject = self.serializeEvent(retrieveCompleted['properties']['objects'][0])
     return returnObject
Exemplo n.º 2
0
 def getReminderIdentifier(self, identifier):
     retrieveCMD = DomainObjectRetrieve(self.refId)
     x = ReminderObject()
     x.identifier = identifier
     retrieveCMD.identifiers = [x]
     answer = self.getResponseForRequest(retrieveCMD)
     if ObjectIsCommand(answer, DomainObjectRetrieveCompleted):
         answer = DomainObjectRetrieveCompleted(answer)
         result = ReminderObject()
         result.initializeFromPlist(answer.objects[0].to_plist())
         return result
     else:
         return None
Exemplo n.º 3
0
    def changeName(self, nameType, value):      
      meSearch = ABPersonSearch(self.refId)
      meSearch.me = True
      meSearch.scope = "Local"
      
      answer = self.getResponseForRequest(meSearch)
      
      if ObjectIsCommand(answer, ABPersonSearchCompleted):
	results = ABPersonSearchCompleted(answer)
	results = results.results[0]
      else:
	raise StopPluginExecution("Unknown response: {0}".format(answer))
      
      mePerson = ABPerson()
      mePerson.identifier = results.identifier
      
      domainRetrieve = DomainObjectRetrieve(self.refId)
      domainRetrieve.identifiers = [mePerson]
      
      domainAnswer = self.getResponseForRequest(domainRetrieve)
      
      if not ObjectIsCommand(domainAnswer, DomainObjectRetrieveCompleted):
	raise StopPluginExecution("Unknown response: {0}".format(domainAnswer))      

      domainUpdate = DomainObjectUpdate(self.refId)
      domainUpdate.identifier = mePerson
      
      newName = ABPerson()
      
      if nameType in ["nick", "nick name"]:
	newName.nickName = value
      if nameType in ["firstName", "first name"]:
	newName.firstName = value
      if nameType in ["lastName", "last name"]:
	newName.lastName = value
      
      domainUpdate.setFields = newName
      
      updateAnswer = self.getResponseForRequest(domainUpdate)
      
      if not ObjectIsCommand(updateAnswer, DomainObjectUpdateCompleted):
	raise StopPluginExecution("Unknown response: {0}".format(updateAnswer))
      
      domainCommit = DomainObjectCommit(self.refId)
      domainCommit.identifier = mePerson
      
      commitAnswer = self.getResponseForRequest(domainCommit)
      
      if not ObjectIsCommand(commitAnswer, DomainObjectCommitCompleted):
	raise StopPluginExecution("Unknown response: {0}".format(commitAnswer))
Exemplo n.º 4
0
 def getSmssForIdentifier(self, identifier):
     # fetch the current version
     retrieveCMD = DomainObjectRetrieve(self.refId)
     x = SmsSms()
     x.identifier = identifier
     retrieveCMD.identifiers = [x]
     answer = self.getResponseForRequest(retrieveCMD)
     if ObjectIsCommand(answer, DomainObjectRetrieveCompleted):
         answer = DomainObjectRetrieveCompleted(answer)
         if len(answer.objects) > 1:
             self.logger.warning("I do not support multiple messages!")
         result = SmsSms()
         result.initializeFromPlist(answer.objects[0].to_plist())
         return result
     else:
         return None
Exemplo n.º 5
0
 def getSmssForIdentifier(self, identifier):
     # fetch the current version
     retrieveCMD = DomainObjectRetrieve(self.refId)
     x = SmsSms()
     x.identifier = identifier
     retrieveCMD.identifiers = [x]
     answer = self.getResponseForRequest(retrieveCMD)
     if ObjectIsCommand(answer, DomainObjectRetrieveCompleted):
         answer = DomainObjectRetrieveCompleted(answer)
         if len(answer.objects) > 1:
             self.logger.warning("I do not support multiple messages!")
         result = SmsSms()
         result.initializeFromPlist(answer.objects[0].to_plist())
         return result
     else:
         return None