Beispiel #1
0
    def OnData(self, x, y, result):
        self.GetData()

        format = self.__compositeDataObject.GetReceivedFormat()

        if format.GetType() in [ wx.DF_TEXT, wx.DF_UNICODETEXT ]:
            if self.__onDropURLCallback:
                self.__onDropURLCallback(x, y, self.__urlDataObject.GetText())
        elif format.GetType() == wx.DF_FILENAME:
            if self.__onDropFileCallback:
                self.__onDropFileCallback(x, y, self.__fileDataObject.GetFilenames())
        elif format.GetId() == 'text/x-moz-message':
            if self.__onDropMailCallback:
                data = self.__thunderbirdMailDataObject.GetData()
                # We expect the data to be encoded with 'unicode_internal',
                # but on Fedora it can also be 'utf-16', be prepared:
                try:
                    data = data.decode('unicode_internal')
                except UnicodeDecodeError:
                    data = data.decode('utf-16')
                self.__onDropMailCallback(x, y, thunderbird.getMail(data))
        elif self.__macThunderbirdMailDataObject.GetData():
            if self.__onDropMailCallback:
                self.__onDropMailCallback(x, y,
                     thunderbird.getMail(self.__macThunderbirdMailDataObject.GetData().decode('unicode_internal')))
        elif format.GetId() == 'Object Descriptor':
            if self.__onDropMailCallback:
                for mail in outlook.getCurrentSelection():
                    self.__onDropMailCallback(x, y, mail)

        self.reinit()
        return wx.DragCopy
Beispiel #2
0
 def OnData(self, x, y, result):
     self.GetData()
     if self.__urlDataObject.GetText():
         if self.__onDropURLCallback:
             self.__onDropURLCallback(x, y, self.__urlDataObject.GetText())
     elif self.__thunderbirdMailDataObject.GetData():
         if self.__onDropMailCallback:
             data = self.__thunderbirdMailDataObject.GetData()
             # We expect the data to be encoded with 'unicode_internal',
             # but on Fedora it can also be 'utf-16', be prepared:
             try:
                 data = data.decode('unicode_internal')
             except UnicodeDecodeError:
                 data = data.decode('utf-16')
             self.__onDropMailCallback(x, y, thunderbird.getMail(data))
     elif self.__macThunderbirdMailDataObject.GetData():
         if self.__onDropMailCallback:
             self.__onDropMailCallback(x, y, thunderbird.getMail(self.__macThunderbirdMailDataObject.GetData().decode('unicode_internal')))
     else:
         files = self.__fileDataObject.GetFilenames()
         if files:
             if self.__onDropFileCallback:
                 self.__onDropFileCallback(x, y, files)
         else:
             if self.__onDropMailCallback:
                 for mail in outlook.getCurrentSelection():
                     self.__onDropMailCallback(x, y, mail)
     self.reinit()
     return wx.DragCopy
Beispiel #3
0
    def OnData(self, x, y, result):  # pylint: disable=W0613
        self.GetData()
        formatType, formatId = self.getReceivedFormatTypeAndId()

        if formatId == 'text/x-moz-message':
            self.onThunderbirdDrop(x, y)
        elif formatId == 'text/uri-list' and formatType == wx.DF_FILENAME:
            urls = self.__urilistDataObject.GetData().strip().split('\n')
            for url in urls:
                url = url.strip()
                if url.startswith('#'):
                    continue
                if self.__tmp_mail_file_url(url) and self.__onDropMailCallback:
                    filename = urllib.unquote(url[len('file://'):])
                    self.__onDropMailCallback(x, y, filename)
                elif self.__onDropURLCallback:
                    if url.startswith('file://'):
                        url = urllib.url2pathname(url[7:])
                    self.__onDropURLCallback(x, y, url)
        elif formatId == 'Object Descriptor':
            self.onOutlookDrop(x, y)
        elif formatId == 'public.url':
            url = self.__macMailObject.GetData()
            if (url.startswith('imap:') or url.startswith('mailbox:')) and self.__onDropMailCallback:
                try:
                    self.__onDropMailCallback(x, y, thunderbird.getMail(url))
                except thunderbird.ThunderbirdCancelled:
                    pass
                except thunderbird.ThunderbirdError, e:
                    wx.MessageBox(unicode(e), _('Error'), wx.OK)
            elif self.__onDropURLCallback:
                self.__onDropURLCallback(x, y, url)
Beispiel #4
0
    def OnData(self, x, y, result):  # pylint: disable=W0613
        self.GetData()
        formatType, formatId = self.getReceivedFormatTypeAndId()

        if formatId == 'text/x-moz-message':
            self.onThunderbirdDrop(x, y)
        elif formatId == 'text/uri-list' and formatType == wx.DF_FILENAME:
            urls = self.__urilistDataObject.GetData().strip().split('\n')
            for url in urls:
                url = url.strip()
                if url.startswith('#'):
                    continue
                if self.__tmp_mail_file_url(url) and self.__onDropMailCallback:
                    filename = urllib.unquote(url[len('file://'):])
                    self.__onDropMailCallback(x, y, filename)
                elif self.__onDropURLCallback:
                    self.__onDropURLCallback(x, y, url)
        elif formatId == 'Object Descriptor':
            self.onOutlookDrop(x, y)
        elif formatId == 'public.url':
            url = self.__macMailObject.GetData()
            if (url.startswith('imap:') or url.startswith('mailbox:')) and self.__onDropMailCallback:
                try:
                    self.__onDropMailCallback(x, y, thunderbird.getMail(url))
                except thunderbird.ThunderbirdCancelled:
                    pass
                except thunderbird.ThunderbirdError, e:
                    wx.MessageBox(unicode(e), _('Error'), wx.OK)
            elif self.__onDropURLCallback:
                self.__onDropURLCallback(x, y, url)
Beispiel #5
0
    def onThunderbirdDrop(self, x, y):
        if self.__onDropMailCallback:
            data = self.__thunderbirdMailDataObject.GetData()
            # We expect the data to be encoded with 'unicode_internal',
            # but on Fedora it can also be 'utf-16', be prepared:
            try:
                data = data.decode('unicode_internal')
            except UnicodeDecodeError:
                data = data.decode('utf-16')

            try:
                email = thunderbird.getMail(data)
            except thunderbird.ThunderbirdCancelled:
                pass
            except thunderbird.ThunderbirdError, e:
                wx.MessageBox(e.args[0], _('Error'), wx.OK|wx.ICON_ERROR)
            else:
                self.__onDropMailCallback(x, y, thunderbird.getMail(data))
Beispiel #6
0
 def onThunderbirdDrop(self, x, y):
     if self.__onDropMailCallback:
         data = self.__thunderbirdMailDataObject.GetData()
         # We expect the data to be encoded with 'unicode_internal',
         # but on Fedora it can also be 'utf-16', be prepared:
         try:
             data = data.decode('unicode_internal')
         except UnicodeDecodeError:
             data = data.decode('utf-16')
         self.__onDropMailCallback(x, y, thunderbird.getMail(data))
Beispiel #7
0
 def OnData(self, x, y, result):
     self.GetData()
     if self.__urlDataObject.GetText():
         if self.__onDropURLCallback:
             self.__onDropURLCallback(x, y, self.__urlDataObject.GetText())
     elif self.__thunderbirdMailDataObject.GetData():
         if self.__onDropMailCallback:
             self.__onDropMailCallback(x, y, thunderbird.getMail(self.__thunderbirdMailDataObject.GetData().decode('unicode_internal')))
     elif self.__macThunderbirdMailDataObject.GetData():
         if self.__onDropMailCallback:
             self.__onDropMailCallback(x, y, thunderbird.getMail(self.__macThunderbirdMailDataObject.GetData().decode('unicode_internal')))
     else:
         files = self.__fileDataObject.GetFilenames()
         if files:
             if self.__onDropFileCallback:
                 self.__onDropFileCallback(x, y, files)
         else:
             if self.__onDropMailCallback:
                 for mail in outlook.getCurrentSelection():
                     self.__onDropMailCallback(x, y, mail)
     self.reinit()
     return wx.DragCopy
Beispiel #8
0
    def OnData(self, x, y, result): # pylint: disable-msg=W0613
        self.GetData()

        format = self.__compositeDataObject.GetReceivedFormat()

        if format.GetType() in [ wx.DF_TEXT, wx.DF_UNICODETEXT ]:
            if self.__onDropURLCallback:
                self.__onDropURLCallback(x, y, self.__urlDataObject.GetText())
        elif format.GetType() == wx.DF_FILENAME:
            if self.__onDropFileCallback:
                self.__onDropFileCallback(x, y, self.__fileDataObject.GetFilenames())
        elif format.GetId() == 'text/x-moz-message':
            if self.__onDropMailCallback:
                data = self.__thunderbirdMailDataObject.GetData()
                # We expect the data to be encoded with 'unicode_internal',
                # but on Fedora it can also be 'utf-16', be prepared:
                try:
                    data = data.decode('unicode_internal')
                except UnicodeDecodeError:
                    data = data.decode('utf-16')
                self.__onDropMailCallback(x, y, thunderbird.getMail(data))
        elif self.__macThunderbirdMailDataObject.GetData():
            if self.__onDropMailCallback:
                self.__onDropMailCallback(x, y,
                     thunderbird.getMail(self.__macThunderbirdMailDataObject.GetData().decode('unicode_internal')))
        elif format.GetId() == 'Object Descriptor':
            if self.__onDropMailCallback:
                for mail in outlook.getCurrentSelection():
                    self.__onDropMailCallback(x, y, mail)
        elif format.GetId() == 'public.url':
            url = self.__macMailObject.GetData()
            if url.startswith('message:') and self.__onDropURLCallback:
                self.__onDropURLCallback(x, y, url)

        self.reinit()
        return wx.DragCopy
Beispiel #9
0
    def onThunderbirdDrop(self, x, y):
        if self.__onDropMailCallback:
            data = self.__thunderbirdMailDataObject.GetData()
            # We expect the data to be encoded with 'unicode_internal',
            # but on Fedora it can also be 'utf-16', be prepared:
            try:
                data = data.decode('unicode_internal')
            except UnicodeDecodeError:
                data = data.decode('utf-16')

            try:
                email = thunderbird.getMail(data)
            except thunderbird.ThunderbirdCancelled:
                pass
            except thunderbird.ThunderbirdError, e:
                wx.MessageBox(e.args[0], _('Error'), wx.OK | wx.ICON_ERROR)
            else:
                self.__onDropMailCallback(x, y, email)
Beispiel #10
0
    def OnData(self, x, y, result): # pylint: disable-msg=W0613
        self.GetData()
        formatType, formatId = self.getReceivedFormatTypeAndId()

        if formatId == 'text/x-moz-message':
            self.onThunderbirdDrop(x, y)
        elif formatId == 'Object Descriptor':
            self.onOutlookDrop(x, y)
        elif formatId == 'public.url':
            url = self.__macMailObject.GetData()
            if url.startswith('message:') and self.__onDropURLCallback:
                self.__onDropURLCallback(x, y, url)
            elif url.startswith('imap:') and self.__onDropMailCallback:
                try:
                    self.__onDropMailCallback(x, y, thunderbird.getMail(url))
                except thunderbird.ThunderbirdCancelled:
                    pass
                except thunderbird.ThunderbirdError, e:
                    wx.MessageBox(unicode(e), _('Error'), wx.OK)
            elif self.__onDropURLCallback:
                wx.MessageBox(_('Unrecognized URL scheme:\n"%s"') % url, _('Error'), wx.OK)