欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    k9mail源码分析Word格式文档下载.docx

    • 资源ID:6445492       资源大小:398.51KB        全文页数:31页
    • 资源格式: DOCX        下载积分:3金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    k9mail源码分析Word格式文档下载.docx

    1、 + passwordEnc, incomingUriTemplate.getHost(), incomingUriTemplate.getPort(), null,null, null); String outgoingUsername = mProvider.outgoingUsernameTemplate; URI outgoingUriTemplate = mProvider.outgoingUriTemplate;if (outgoingUsername != null) outgoingUsername = outgoingUsername.replaceAll(outgoingU

    2、ri = new URI(outgoingUriTemplate.getScheme(), outgoingUsername + + passwordEnc, outgoingUriTemplate.getHost(), outgoingUriTemplate.getPort(), null, else outgoingUri = new URI(outgoingUriTemplate.getScheme(),null, outgoingUriTemplate.getHost(), outgoingUriTemplate.getPort(), null, if (mAccount = null

    3、) mAccount = Preferences.getPreferences(this).newAccount();mAccount.setName(getOwnerName();mAccount.setEmail(email);mAccount.setStoreUri(incomingUri.toString();mAccount.setTransportUri(outgoingUri.toString();mAccount.setDraftsFolderName(getString(R.string.special_mailbox_name_drafts);mAccount.setTra

    4、shFolderName(getString(R.string.special_mailbox_name_trash);mAccount.setArchiveFolderName(getString(R.string.special_mailbox_name_archive);/ Yahoo! has a special folder for Spam, called Bulk Mail.if (incomingUriTemplate.getHost().toLowerCase().endsWith() mAccount.setSpamFolderName(mAccount.setSpamFo

    5、lderName(getString(R.string.special_mailbox_name_spam);mAccount.setSentFolderName(getString(R.string.special_mailbox_name_sent);if (incomingUri.toString().startsWith(imapmAccount.setDeletePolicy(Account.DELETE_POLICY_ON_DELETE); elseif (incomingUri.toString().startsWith(pop3mAccount.setDeletePolicy(

    6、Account.DELETE_POLICY_NEVER);/ Check incoming here. Then check outgoing in onActivityResult()AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.INCOMING); catch (UnsupportedEncodingExceptionenc) / This really shouldnt happen since the encoding is hardcoded to UTF-8Log.e(K9.

    7、LOG_TAG, Couldnt urlencode username or password., enc); catch (URISyntaxException use) /* * If there is some problem with the URI we give up and go on to * manual setup. */onManualSetup();MIME邮件的构成MIME消息(邮件,对应 k9mail 的MimeMessage类),由消息头(对应 k9mai的MimeHeader类)和消息体(body对应k9mail的Body 接口)两大部分组成。邮件头中不允许出现

    8、空行。邮件头包含了发件人、收件人、主题、时间、MIME 版本、邮件内容的类型等重要信息。每条信息称为一个域,由域名后加“: ”和信息的内容构成,可以是一行,较长的也可以占用多行。域的首行必须“顶头”写,即左边不能有空白字符(空格和制表符);续行则必须以空白字符打头,且第一个空白字符不是信息本身固有的,解码时要过滤掉。邮件头信息中各个字段及其含义的说明如下表:邮件体(body)指的是邮件的内容,它的类型由邮件头的“Content-Type”域指出,常见的简单类型有 text/plain(纯文本)和 text/html(超文本)。multipart 类型是 MIME 邮件的精髓,对应 k9mail

    9、 的MultiPart类。邮件体被分为多个段或者多个部分,对应 k9mail 的 Part 接口,每个段又包含段头和段体两部分,这两部分之间也以空行分隔。常见的 multipart 类型有三种: multipart/mixed, multipart/related 和multipart/alternative。从它们的名称,不难推知这些类型各自的含义和用处。它们之间的层次关系如下图所示,从中可以看出,如果在邮件中要添加附件,必须定义 multipart/mixed 段;如果存在内嵌资源,至少要定义 multipart/related 段;如果纯文本与超文本共存,至少要定义 multipart/

    10、alternative 段。为什么说是“至少”?举个例子说,如果只有纯文本与超文本正文,那么在邮件头中将类型扩大化,定义为 multipart/related,甚至 multipart/mixed,都是允许的。k-9-4.804srccomfsckk9mail地址:address.java地址和通讯录名字之间的转换身份认证:Authentication.java函数作用:计算对CRAM-MD5认证机制的响应,给用户提供认证信息和服务器提供随机数。package com.fsck.k9.mail;importjava.security.MessageDigest;import com.fsck.

    11、k9.mail.filter.Base64;import com.fsck.k9.mail.filter.Hex;publicclassAuthentication privatestaticfinalStringUS_ASCII = US-ASCII;/* * Computes the response for CRAM-MD5 authentication mechanism given the user credentials and * the server-provided nonce. * * param username Theusername. * param password

    12、 The password. * param b64Nonce Thenonce as base64-encoded string.* return The CRAM-MD5 response. * throwsAuthenticationFailedExceptionIf something went wrong. * see Authentication#computeCramMd5Bytes(String, String, byte)publicstaticString computeCramMd5(String username, String password, String b64

    13、Nonce)throwsAuthenticationFailedException byte b64NonceBytes = b64Nonce.getBytes(US_ASCII);byte b64CRAM = computeCramMd5Bytes(username, password, b64NonceBytes);returnnewString(b64CRAM, US_ASCII); catch (AuthenticationFailedException e) throwe; catch (Exception e) thrownewAuthenticationFailedExcepti

    14、on(This shouldnt happen, e); * param b64Nonce Thenonce as base64-encoded byte array.* return The CRAM-MD5 response as byte array. * seeRFC 2195publicstaticbyte computeCramMd5Bytes(String username, String password, byte b64Nonce)byte nonce = Base64.decodeBase64(b64Nonce);byte secretBytes = password.g

    15、etBytes(US_ASCII);MessageDigest md = MessageDigest.getInstance(MD5if (secretBytes.length 64) secretBytes = md.digest(secretBytes);byte ipad = newbyte64;byte opad = newbyte64;System.arraycopy(secretBytes, 0, ipad, 0, secretBytes.length);System.arraycopy(secretBytes, 0, opad, 0, secretBytes.length);fo

    16、r (inti = 0; iipad.length; i+) ipadi = 0x36;opad.length; i+) opadi = 0x5c;md.update(ipad);byte firstPass = md.digest(nonce);md.update(opad);byte result = md.digest(firstPass);StringplainCRAM = username + + newString(Hex.encodeHex(result);byte b64CRAM = Base64.encodeBase64(plainCRAM.getBytes(US_ASCII

    17、);return b64CRAM;Something went wrong during CRAM-MD5 computationk-9-.fsck.k9.mail.transport;SmtpTransport.javaWebDavTransport.javak-9-4.804srccomfsckk9mailtransportimapImapSettings.javacom.fsck.k9:Account.java这是个实体类,也是 android 平台上 MVC 模式中的 Model 类,它除了封装Email 账户的信息外,还被设计用于保存账户的各种设置,包括账户身份认证设置 Identi

    18、ty、字体设置FontSizes、通知设置NotificationSetting和邮件收发地址、草稿箱、垃圾箱、总是密送到的账户、反垃圾用的文件夹、各种网络(3g、WiFi等)连接下是否启用压缩等,这些数据使用android平台的SharedPreferences保存,SharedPreferences是平台下除了SQLite 外另外一种方便好用的数据持久化方式,应该是 android 平台上最简单的读写外部数据的方法,特别适用于保存客户端不同用户的个性化设置信息。一个账户用一个 UUID 定义,可以通过mUuid属性的值来区分两个账户。Accou类实现了接口BaseAccount,这个接口定

    19、义了获取、设置 Email 账户的及其描述的 String 类型的数据,还定义了获取账户 UUID 值的方法。通过 Account 可以获得账户对应的LocalStore实例,然后可以进一步获得该账户在 SQLite 数据库里面保存的一切信息,包括邮件文件夹、邮件等,还可以获得远程邮件服务器的代理(RemoteStore,包括ImapStore、 Pop3Store 和WebDavStore,这些组件封装了对远程服务器的访问),并进一步获得其内部类(例如ImapStore的内部类ImapFolder),实现对远程服务器上相应对象的操作。Account 的类型怎么区分的?通过 Account 类

    20、的属性mStoreUri,不同类型的 Account 的mStoreUri的值以不同的前缀开头,k9mail 分别使用 pop3、imap和webdav表示相应的三种 Email 账户类型,该属性的值的形式如下:imap:/PLAIN:帐号:密码:143/1%7C这些数据变化后,k9mail会调用Account 类的save方法通过SharedPreferences.Editor把这些数据保存到 xml 配置文件中。该类存储了一个账号的所有信息。Account stores all of the settings for a single account defined by the user

    21、. It is able to saveand delete itself given a Preferences to work with. Each account is defined by a UUID.(1)Account的默认信息:收发件箱、删除策略、网络类型、消息类型、键值、颜色、排序类、数据库ID等等(2)protectedAccount(Context context)设置账户的基本信息:(3)private intpickColor(Context context)* Pick a nice Android guidelines color if we havent use

    22、d them all yet.(4)protectedAccount(Preferences preferences, String uuid)this.mUuid = uuid;loadAccount(preferences);(5)private synchronized voidloadAccount(Preferences preferences)* Load stored settings for this account.(6)protected synchronized voiddelete(Preferences preferences)删除一个账户(7)publicstati

    23、cintfindNewAccountNumber(ListaccountNumbers) 为新账户建立一个AccountNumber(8)publicstatic ListgetExistingAccountNumbers(Preferencespreferences)获得存在的所有帐户的AccountNumber列表(9)publicstaticintgenerateAccountNumber(Preferences preferences) 生成一个AccountNumber(10)publicvoid move(Preferences preferences, booleanmoveUp

    24、) 移动账户的位置,上移或下移一位(11)publicsynchronizedvoid save(Preferences preferences)保存账户的配置信息。当账户被创建时,我们会为其分配一个唯一的AccountNumber(12)public voidresetVisibleLimits()重置可以显示的账户的个数(13)publicAccountStatsgetStats(Context context) throwsMessagingException获得帐户状态(14)颜色相关的函数publicsynchronizedvoidsetChipColor(int color) pu

    25、blicsynchronizedvoidcacheChips()publicColorChipgetCheckmarkChip() returnmCheckmarkChip;publicsynchronizedintgetChipColor() returnmChipColor;publicColorChipgenerateColorChip(booleanmessageRead, booleantoMe, booleanccMe, booleanfromMe, booleanmessageFlagged)publicColorChipgenerateColorChip() returnnew

    26、ColorChip(mChipColor, false, ColorChip.CIRCULAR);(15)public String getUuid() returnmUuid;获得当前账户的Uuid(16)public Uri getContentUri() returnUri.parse(content:/accounts/ + getUuid();获得当前账户的ContentUri(16)publicsynchronized String getStoreUri() returnmStoreUri;获得当前账户的StoreUri(17)publicsynchronizedvoidsetStoreUri(String storeUri) this.mStoreUri = storeUri;设置当前账户的Store


    注意事项

    本文(k9mail源码分析Word格式文档下载.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开