mailclientconfig.java
来自「moblie syncml mail javame」· Java 代码 · 共 561 行 · 第 1/2 页
JAVA
561 行
/*
* Funambol is a mobile platform developed by Funambol, Inc.
* Copyright (C) 2003 - 2007 Funambol, Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by
* the Free Software Foundation with the addition of the following permission
* added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
* WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program; if not, see http://www.gnu.org/licenses or write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA.
*
* You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite
* 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License
* version 3, these Appropriate Legal Notices must retain the display of the
* "Powered by Funambol" logo. If the display of the logo is not reasonably
* feasible for technical reasons, the Appropriate Legal Notices must display
* the words "Powered by Funambol".
*/
package com.funambol.mailclient.config;
import com.funambol.util.MailDateFormatter;
import java.io.DataOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.Date;
import com.funambol.mailclient.Account;
import com.funambol.mailclient.MailFilter;
import com.funambol.mail.Store;
import com.funambol.mail.StoreFactory;
import com.funambol.storage.Serializable;
import com.funambol.util.DateUtil;
import com.funambol.util.Log;
/**
* Configuration data for the Mail Client: account, polling time etc.
*
*/
public class MailClientConfig implements Serializable {
//---------------------------------------------------------------- Constants
/** This is the default polling interval*/
private static final int INTERVAL = 10;
/** The name of the config record */
public static final String NAME = "MailConfig" ;
/** ctp status */
public static final int CTP_ENABLED = 0;
public static final int CTP_DISABLED = 1;
/* This field contains the previous versions of the configuration data
* from which the backward compatibility is guaranteed
*/
private static final int VERSION_101 = 101;
private static final int VERSION_102 = 102;
private static final int VERSION_103 = 103;
private static final int VERSION_104 = 104;
// v. 105 adds ctp status settings
private static final int VERSION_105 = 105;
/* This field contains the version of the configuration data */
private static final int VERSION = VERSION_105 ;
//--------------------------------------------------------------- Attributes
/** The configuration version loaded from the store */
private long version ;
/** Mail params */
private Account mailAccount;
/** Mail Filter */
private MailFilter mailFilter;
/** Enable scheduled sync */
private boolean enableScheduler = true;
/** Polling interval, in minutes */
private int pollInterval = INTERVAL;
/** Enable Sms listener */
private boolean enableSmsListener;
/** Enable Delete command propagation*/
private boolean enableDeletePropagation;
/** Log level*/
private int logLevel;
/** Time of daily polling */
private long nextTimeAlarm;
/** Client Server Communications Compress */
private boolean compress;
//--------------------------------- Fields added in version 101
/** Date of First installation */
private long startFilter;
// Number of days to remove for the date of starting for filter
private int DAYS_TO_REMOVE = 3;
private int rmsStoreSize;
//--------------------------------- Fields added in version 102
private String timeZone;
private static boolean timeZoneUpdated; // NOT Serialized
//---------------------------------- Fields added in version 103
private boolean soundNotification;
private boolean vibrateNotification;
private int storeVersion;
private boolean syncOnStartup;
//---------------------------------- Fields added in version 104
private boolean deleteConfirmation;
//---------------------------------- Fields added in version 105
/** ctp push status*/
private int ctpPushStatus = CTP_ENABLED;
//------------------------------------------------------------- Constructors
/**
* Default constructor. Sets default configuration values.
*/
public MailClientConfig() {
version = VERSION;
// Mail parameters
mailAccount = new Account();
Date date = new DateUtil().toMidnight().removeDays(DAYS_TO_REMOVE).getTime();
// Default filter parameters
mailFilter = new MailFilter(2*1024, // size:2K
date, // from date
false, // headers only
false); // without attachments
// Push parameters
enableSmsListener = false;
enableDeletePropagation = false;
logLevel = Log.INFO ;
compress = true;
// Version 101
startFilter = date.getTime();
rmsStoreSize = 0; // XXX: use another default?
timeZoneUpdated = false;
soundNotification = true;
vibrateNotification = true;
// By default we have the latest version of the store version,
// because this is the case when we're not upgrading
storeVersion = Store.LATEST_VERSION;
StoreFactory.getStore().setVersion(storeVersion);
syncOnStartup = true;
deleteConfirmation = true;
}
//----------------------------------------------------------- Public methods
public long getStartFilter() {
return startFilter;
}
public void setStartFilter(long startFilter) {
this.startFilter = startFilter;
}
public Account getMailAccount() {
return this.mailAccount;
}
public void setMailAccount(Account account) {
this.mailAccount = account;
}
/** Return the currently configured mail filter. */
public MailFilter getMailFilter() {
return mailFilter;
}
/** Set a new mail filter. */
public void setMailFilter(MailFilter mailFilter) {
this.mailFilter = mailFilter;
}
/** Returns the current status of the scheduler. */
public boolean isSchedulerEnabled() {
return enableScheduler;
}
/** Enables or disables the scheduler */
public void enableScheduler(boolean enableScheduler) {
this.enableScheduler = enableScheduler;
}
/** This value is not used at the moment by the client. */
public boolean isSmsListenerEnabled() {
return enableSmsListener;
}
/** This value is not used at the moment by the client. */
public void enableSmsListener(boolean enableSmsListener) {
this.enableSmsListener = enableSmsListener;
}
/** Sets the log level. See com.funambol.util.Log for valid levels. */
public void setLogLevel(int logLevel) {
this.logLevel = logLevel;
}
/** Gets the log level. See com.funambol.util.Log for valid levels. */
public int getLogLevel() {
return logLevel;
}
/** Sets the polling interval, in seconds. */
public void setPollInterval(int pollInterval) {
this.pollInterval = pollInterval;
}
/** Returns the polling interval, in seconds. */
public int getPollInterval() {
return this.pollInterval;
}
/** Returns true if the communication with the server is compressed. */
public boolean isCompress() {
return compress;
}
/** Enables or disables compression in the communication with the server */
public void enableCompress(boolean enable) {
compress = enable;
}
/** Enables or disables the date filter */
public void enableDateFilter(boolean enable) {
if(enable) {
mailFilter.setDate(new Date(startFilter));
} else {
mailFilter.setDate(null);
}
}
/** Returns the current status of the delete propagation on server */
public boolean isEnableDeletePropagation() {
return enableDeletePropagation;
}
/** Enables or disables the delete propagation on server */
public void enableDeletePropagation(boolean deletePropagation) {
this.enableDeletePropagation = deletePropagation;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?