def parse_attachment(self, table_name): """ 'bigTopDataDB.' + ACCOUNT_ID - item_message_attachments FieldName SQLType row_id INTEGER item_messages_row_id INTEGER is_synced INTEGER attachment_url TEXT attachment_cache_key TEXT attachment_file_name TEXT attachment_hash TEXT """ for rec in self._read_table(table_name): if (self._is_empty(rec, 'attachment_file_name', 'row_id') or self._is_duplicate(rec, 'row_id')): continue attachment = model_mail.Attachment() attachment.attachment_id = rec['row_id'].Value attachment.owner_account_id = self.cur_account_id attachment.mail_id = rec['item_messages_row_id'].Value attachment.attachment_name = rec['attachment_file_name'].Value attachment.source = self.cur_db_source attachment.deleted = 1 if rec.IsDeleted else 0 # attachment.attachment_save_dir # attachment.attachment_size # attachment.attachment_download_date try: self.csm.db_insert_table_attachment(attachment) except: exc() try: self.csm.db_commit() except: exc()
def parse_attachment(self, db_path, table_name): ''' imail.db - mailAttachment RecNo FieldName SQLType Size 1 attachmentId INTEGER 2 mailId INTEGER 3 rawType INTEGER 4 contentType TEXT 5 external INTEGER 6 partId TEXT 7 transferEncoding TEXT 8 contentId TEXT 9 name TEXT 10 dispositionName TEXT 11 size INTEGER 12 localPath TEXT 13 wmsvrType INTEGER 14 wmsvrOwnedInfo TEXT 15 wmsvrReferenceInfo TEXT 16 hugeAttachmentInfo TEXT 17 oid TEXT 18 method INTEGER 19 fileReference TEXT 20 contentLocation TEXT 21 createdate INTEGER ''' if not self._read_db(db_path): return for rec in self._read_table(table_name): if canceller.IsCancellationRequested: return if self._is_empty(rec, 'name', 'mailId', 'attachmentId') or self._is_duplicate( rec, 'attachmentId'): continue attach = model_mail.Attachment() attach.attachment_id = rec['attachmentId'].Value # attach.owner_account_id = rec['mailId'].Value attach.mail_id = rec['mailId'].Value attach.attachment_name = rec['name'].Value if not self._is_empty(rec, 'localPath') and isinstance( rec['localPath'].Value, str): attach.attachment_save_dir = self.root.AbsolutePath + '/' + rec[ 'localPath'].Value attach.attachment_size = rec['size'].Value attach.attachment_download_date = rec['createdate'].Value attach.source = self.cur_db_source attach.deleted = 1 if rec.IsDeleted else 0 try: self.csm.db_insert_table_attachment(attach) except: exc() try: self.csm.db_commit() except: exc()
def parse_attachment(self, db_path, table_name): """ EmailProvider - Attachment (xiaomi) RecNo FieldName 1 _id integer 2 fileName text 3 mimeType text 4 size integer 5 contentId text 6 contentUri text 7 messageKey integer 8 location text 9 encoding text 10 content text 11 flags integer 12 content_bytes blob 13 accountKey integer 14 uiState integer 15 uiDestination integer 16 uiDownloadedSize integer 17 cachedFile text ############## 以下字段华为没有 ############ 18 previewTime integer False 19 snapshotPath text 20 isDeleted integer False 21 downloadFailureReason nteger 22 sourceAttId integer """ if not self._read_db(db_path): return for rec in self._read_table(table_name): if canceller.IsCancellationRequested: return if self._is_empty(rec, 'fileName', 'size') or self._is_duplicate( rec, '_id'): continue attach = model_mail.Attachment() attach.attachment_id = rec['_id'].Value attach.mail_id = rec['messageKey'].Value attach.owner_account_id = rec['accountKey'].Value attach.attachment_name = rec['fileName'].Value attach.attachment_save_dir = rec[ 'contentUri'].Value # or location? attach.attachment_size = rec['size'].Value attach.deleted = 1 if rec.IsDeleted else 0 try: attach.attachment_download_date = rec['previewTime'].Value attach.deleted = rec['isDeleted'].Value except: pass attach.source = self.cur_db_source try: self.csm.db_insert_table_attachment(attach) except: exc() self.csm.db_commit()
def parse_attachment(self, table_name): """ mmail - Part_<account_id> RecNo FieldName 1 id UNSIGNED BIG INT 2 messageId UNSIGNED BIG INT 3 localPath TEXT 4 name TEXT 5 filename TEXT 6 serverId TEXT 7 type INTEGER 8 contentType TEXT 9 size UNSIGNED BIG INT 10 previewURL TEXT 11 contentId TEXT 12 flag INTEGER 13 isDownloaded INTEGER 14 downloadTime IUNSIGNED BIG INT 15 charset TEXT 16 encoding TEXT """ table_name = 'Part_' + str(self.cur_account_id) for rec in self._read_table(table_name): if canceller.IsCancellationRequested: return if self._is_empty(rec, 'filename', 'messageId') or self._is_duplicate(rec, 'id'): continue attach = model_mail.Attachment() attach.attachment_id = rec['id'].Value attach.owner_account_id = self.cur_account_id attach.mail_id = rec['messageId'].Value attach.attachment_name = rec['filename'].Value attach.attachment_save_dir = self._convert_nodepath( rec['localPath'].Value) attach.attachment_download_date = rec['downloadTime'].Value attach.attachment_size = rec['size'].Value attach.mail_id = rec['messageId'].Value attach.source = self.cur_db_source attach.deleted = 1 if rec.IsDeleted else 0 try: self.csm.db_insert_table_attachment(attach) except: exc() try: self.csm.db_commit() except: exc()
def parse_model(self): ''' PA Models email Abstract Account Attachments Owner Account Bcc Cc (To: [email protected] cici) Folder From ({From: [email protected] pangu_x02 }) OwnerUser OwnerUserID Size Subject TimeStamp To Deleted ''' for email in self.results_model: account_user = email.Account.Value if account_user not in self.account_list and account_user != 'Default': self.account_id += 1 self.account_list[account_user] = self.account_id mail = model_mail.Mail() mail.mail_id = self.auto_mail_id self.auto_mail_id += 1 mail.owner_account_id = self.account_id mail.mail_group = email.Folder.Value mail.mail_subject = email.Subject.Value mail.mail_abstract = email.Abstract.Value mail.mail_content = email.Body.Value mail.mail_to = self._handle_mutimodel(email.To) mail.mail_cc = self._handle_mutimodel(email.Cc) mail.mail_bcc = self._handle_mutimodel(email.Bcc) mail.mail_sent_date = self._convert_2_timestamp(email.TimeStamp) try: if email.From.Value: if email.From.Value.Name.Value: mail.mail_from = email.From.Value.Identifier.Value + ' ' + email.From.Value.Name.Value else: mail.mail_from = email.From.Value.Identifier.Value except: pass # APPLE_MAIL_READ_STATUS for k, v in APPLE_MAIL_READ_STATUS.items(): if email.Status.Value == v: mail.mail_read_status = k mail.source = email.Source.Value mail.deleted = 0 if email.Deleted == DeletedState.Intact else 1 self.mm.db_insert_table_mail(mail) for Attachment in email.Attachments: attach = model_mail.Attachment() attach.mail_id = mail.mail_id attach.owner_account_id = self.account_id attach.attachment_name = Attachment.Filename.Value attach.attachment_save_dir = Attachment.URL.Value attach.attachment_size = Attachment.Size.Value self.mm.db_insert_table_attachment(attach) for k, v in self.account_list.items(): account = model_mail.Account() account.account_id = v account.account_email = k account.account_user = k self.mm.db_insert_table_account(account)