~ubuntu-branches/ubuntu/oneiric/emesene/oneiric-proposed

« back to all changes in this revision

Viewing changes to emesenelib/core.py

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2010-04-14 01:33:51 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20100414013351-r2icbt5gs4ai71j8
Tags: 1.6.1-0ubuntu1
* New upstream release (LP: #562646).
* Fix missing-debian-source-format lintian warning.
* Refresh 20_dont_build_own_libmimic.patch patch.
* Bump Standards-Version to 3.8.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
import common
52
52
import string
53
53
import base64
 
54
# gzipped requests ftw!
 
55
import StringIO, gzip
54
56
 
55
57
class Msnp(ProfileManager.ProfileManager):
56
58
    '''This class give support to the MSNP15 protocol to use the MSN Messenger network'''
113
115
            (gobject.TYPE_STRING,gobject.TYPE_STRING)),
114
116
        'self-current-media-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
115
117
            (gobject.TYPE_STRING,gobject.TYPE_STRING,gobject.TYPE_PYOBJECT)),
 
118
        'self-dp-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
 
119
            (gobject.TYPE_STRING,)),
116
120
 
117
121
        'new-conversation' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
118
122
            (gobject.TYPE_STRING,gobject.TYPE_PYOBJECT)),
182
186
            (gobject.TYPE_PYOBJECT,gobject.TYPE_PYOBJECT,)),
183
187
        'finished-file-transfer' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
184
188
            (gobject.TYPE_PYOBJECT,gobject.TYPE_PYOBJECT)),
 
189
        # used to prevent notifications at login
 
190
        'enable-notifications' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
185
191
    }
186
192
 
187
193
    ## constants (ftw!)
198
204
    # TODO: ADD WEBCAM IF USER PREFERENCE TELL TO SHOW AND IMPORT WEBCAMDEVICE DOESN'T GIVE ERRORS
199
205
 
200
206
    def __init__(self, host, port, user, password, \
201
 
        userConfigDir, proxy = None, canUseP4=False):
 
207
        userConfigDir, proxy = None, canUseP4=False, config=None):
202
208
        '''Constructor, intialize variables.'''
203
 
        gobject.GObject.__init__(self)
204
 
 
 
209
        #gobject.GObject.__init__(self)
 
210
        ProfileManager.ProfileManager.__init__(self, config)
 
211
 
205
212
        if proxy == None:
206
213
            self.socket = Socket.Socket(host, port)
207
214
        else:
222
229
        self.nick = ''
223
230
 
224
231
        self.status = 'FLN'
 
232
        
 
233
        self.canNotify = False
225
234
 
226
235
        self.switchboards = [] # the switchboards to process
227
236
        self.switchboardsByTid = {}
229
238
        self.signals = [] # gobject signals to disconnect on logout
230
239
        self.selfSignals = [] # msnp signals
231
240
 
 
241
        # try creating a profile only once, if it doesn't exist
 
242
        self.triedCreatingProfile = False
 
243
        # don't try to update the profile if there's no cache
232
244
        self.affinityCache = ''
 
245
        # don't loop setting dp
 
246
        self.firstSetDpFail = False
 
247
        # id of stored dp
 
248
        self.dpid = ''
233
249
 
234
250
        self.contactManager = ContactData.ContactList({})
235
251
        self.msnObjectsManager = Msnobj.MsnObjectsManager(user)
506
522
            "Content-Length": str(len(body)),
507
523
            "Connection": "Keep-Alive",
508
524
            "Cache-Control": "no-cache",
 
525
            "Accept-encoding": "gzip", # highly improves bandwidth usage
509
526
        }
510
527
 
511
528
        succeeded = False
531
548
                        proxy.sendall(proxy_pieces)
532
549
                        response = proxy.recv(8192) 
533
550
                        status=response.split()[1]
534
 
                        if status!=str(200):  raise 'Error status=',str(status)
 
551
                        if status!=str(200):  raise ValueError,'Error status=%s' % str(status)
535
552
 
536
553
                        # trivial setup for ssl socket
537
554
                        if HAVE_PY25:
553
570
 
554
571
            if response:
555
572
                data = response.read()
 
573
                isGzipd = response.getheader('Content-Encoding', '')
 
574
                if isGzipd == 'gzip':
 
575
                    # data is gzipped, unzipit!
 
576
                    cstream = StringIO.StringIO(data)
 
577
                    gzpr = gzip.GzipFile(fileobj=cstream)
 
578
                    data = gzpr.read()
556
579
            else:
557
580
                raise common.AuthError, "Can't connect to HTTPS server: " + \
558
581
                    str(e)
740
763
            # have something to do with this, but this seems safer
741
764
            self.accountConfirmed = False
742
765
            self.emit('account-unconfirmed')
 
766
        elif command == "PRP" and self.profile_retrieved and not self.canNotify:
 
767
            self.emit('enable-notifications')
 
768
            self.canNotify = True
743
769
 
744
770
    def parseUBX(self, command, tid, params, payload):
745
771
        '''this function parses the UBX payload, and sets the personal
986
1012
            if myself != None:
987
1013
                myself.displayPicturePath = filename
988
1014
 
 
1015
            self.updateDisplayPicture()
 
1016
 
989
1017
        if self.status != 'FLN':
990
1018
            self.changeStatus(self.status)
991
1019