예제 #1
0
    def _SendInvitation(self, options, address, uid, calName, token, rights) :
        msg = MIMEMultipart()
        msg['Subject'] = "%s has shared a calendar with you" % (options.user)
        msg['From'] = "%s@localhost" % (options.user)
        msg['To'] = address

        description = MIMEMultipart("alternative")
        description.attach(MIMEText("This is a thing"))
        description.attach(MIMEText("<b>This is a thing, in html</b>", "html"))
        
        msg.attach(description)

        invitation = {}
        invitation["owner"] = options.user
        # FIXME: get the server name right
        invitation["server"] = "localhost"
        invitation["calendarName"] = calName
        invitation["calendarId"] = uid
        invitation["token"] = token
        invitation["rights"] = rights
        
        msg.attach(MIMEText(simplejson.dumps(invitation), "x-bongo-invitation"))
                
        print "sending:"
        print msg.as_string()
        self._SendMessage(options, address, msg)
예제 #2
0
    def run(self, options, args):
        from libbongo.libs import msgapi

        if len(args) > 0:
            self.print_usage()
            self.exit()

        mdb = MdbUtil.GetMdb(options)
        user = options.demo_user

        context, username = MdbUtil.GetContext(user)

        address = "*****@*****.**" % (user)
        name = "Rupert Monkey"

        try:
            Util.GetUserAttributes(mdb, context, user)
            print "using existing user %s" % (user)
        except:
            print "adding user %s" % (user)
            self.AddUser(mdb, context, user, address)

        dragonfly = {"calendar": defaultData["calendarPreferences"]}
        dragonfly["mail"] = {"from": address}
        print "dragonfly config is: %s" % simplejson.dumps(dragonfly)

        try:
            store = StoreClient(user, user)
            # Clear out the existing store
            store.Reset()
            store.Quit()

            store = StoreClient(user, user)

            contact = self.CreateMyContact(store, address, name)
            dragonfly["addressbook"] = {"me": contact}

            store.Write("/preferences", DocTypes.Unknown, simplejson.dumps(dragonfly), filename="dragonfly")

            self.ImportMail(store, address, name, defaultData)
            self.ImportContacts(store, defaultData)
            self.ImportCalendars(user, defaultData)

        finally:
            store.Quit()
예제 #3
0
 def AsJson(self):
     return simplejson.dumps(self.data)
예제 #4
0
 def CreateMyContact(self, store, address, name):
     mycontact = {"n": [{"value": name}], "fn": name, "email": [{"type": ["WORK"], "value": address}]}
     return store.Write("/addressbook/personal", DocTypes.Addressbook, simplejson.dumps(mycontact))