/*
* Gchecker.java
*
* Created on October 23, 2005, 4:53 PM
*/
package gmailchecker.gui;
import java.applet.Applet;
import java.applet.AudioClip;
import java.net.URL;
import java.util.*;
import gmailchecker.common.GCheckSetting;
import gmailchecker.common.GSettingUtil;
import gmailchecker.common.GmailCountUsage;
import gmailchecker.common.GmailHelper;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.util.RequestProcessor;
import siuying.gm.structure.GMThread;
/**
*
* @author Administrator
*/
public class Gchecker extends javax.swing.JPanel {
/** Creates new form Gchecker */
//
ArrayList eMailsInformation = null;
GmailCountUsage gmcu=null;
GmailHelper gmHelper=null;
GCheckSetting settings =null;
GSettingUtil settingUtil=null;
org.openide.util.RequestProcessor.Task tskGm = null;
int CurrentMailSubject=0;
Timer mailcheckerTimer;//= new java.util.Timer();
Timer ShowSubjectDurationTimer; //= new java.util.Timer();
boolean checkIsUnderGo=false;
private String Connecting_to="Connecting To Gmail...";
private String Retriving_user_count_info="Retrieving Usage and Count Information...";
private String usagePercent = "Usage Percent Is : ";
private String newMailsCount = "Total New Mails Is : ";
private String No_active_connection="No Active Connection or Connection Is Not Usable...";
private String InitiateString ="Gmail checker Module.... Disconnected";
private String ModuletooltipString="GMail Checker Module.....";
private String Retriving_emails_info="Retrieving e-mail Headers...";
//
public boolean DoCheckMail(){
//
Runnable connectRun = new Runnable() {
public void run() {
gmHelper.connect();
}
};
Runnable CheckUsageCount = new Runnable() {
public void run() {
gmcu=gmHelper.getCountUsage();
if (gmcu.getNewMailCount()>0) playSound("receive");
}
};
Runnable GetHeader = new Runnable() {
public void run() {
eMailsInformation=gmHelper.getMailsInfo();
}
};
//
ProgressHandle ProgHandl= ProgressHandleFactory.createHandle(Connecting_to);
jLabel1.setText(Connecting_to);
ProgHandl.start(99);
RequestProcessor.getDefault().post(connectRun).waitFinished();
jLabel1.setText(Retriving_user_count_info);
ProgHandl.progress(Retriving_user_count_info,33);
RequestProcessor.getDefault().post(CheckUsageCount).waitFinished();
if(gmcu.getNewMailCount()==-1 && gmcu.getUsage()==-1 && gmcu.isProblematic()){
jLabel1.setText(No_active_connection);
ProgHandl.finish();
return false;
}else{
jLabel1.setText(Retriving_emails_info);
ProgHandl.progress(Retriving_emails_info,33);
RequestProcessor.getDefault().post(GetHeader).waitFinished();
ProgHandl.progress(33);
ProgHandl.finish();
return true;
}
}
private void setUsageCount(int count,int usage){
this.jLabel1.setText(newMailsCount+" "+count+" , "+usagePercent+usage+"% ");
}
private void ShowInfoAuto(){
setUsageCount(gmcu.getNewMailCount(),gmcu.getUsage());
ShowSubjectDurationTimer = new java.util.Timer();
ShowSubjectDurationTimer.scheduleAtFixedRate(new TimerTask() {
public void run() {
if(CurrentMailSubject"+""+(CurrentMailSubject+1)+" :"+getSubject(CurrentMailSubject)+"