⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 displaymain.java

📁 手机控制邮件以及附件的发送
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package remote.display;// standardimport java.io.ByteArrayInputStream;import java.util.Hashtable;import java.util.Stack;//micro editionimport javax.microedition.lcdui.*;import javax.microedition.lcdui.game.*;import javax.microedition.midlet.*;import javax.microedition.io.*;import javax.microedition.rms.RecordStore;import java.io.*;import java.util.Timer;import java.util.TimerTask;import javax.microedition.media.*;import javax.microedition.media.control.*;// jax-rpcimport java.rmi.RemoteException;// localimport remote.connector.RemoteIF;import remote.connector.RemoteIF_Stub;public class DisplayMain extends MIDlet{    /** Service connector jax-rpc stub for connecting to server. */    private RemoteIF_Stub service;    /** Operation in progress flag. Disables command listener when true. */    private boolean busy = false;    /** Current active screen. */    private Screen screen;    /** Table of commands names. */    private Hashtable commandTypes;    /** Table of alert types names. */    private Hashtable alertTypes;    /** Table of constraints names. */    private Hashtable constraints;    /** Info parameter in request to server. */    private String requestInfo;    /** Command parameter in request to server. */    private String requestCommand;    private boolean status;	private Command exitCommand;	public Command okCommand;	public Command backCommand;	private Command yesCommand;	private Command noCommand;	public Command parentCommand;	public Command previewCommand;	public Command detailCommand;	public Command mycomputerCommand;	private Animation start_screen;	private Animation connection_waiting_screen;	private Animation files_waiting_screen;	private Animation email_waiting_screen;	private Select login_screen;	private Select transfer_screen;	private Message connection_fail_screen;	private Message login_fail_screen;	public Message file_more_screen;	private Message email_fail_screen;	private Message send_sucess_screen;	private Message send_fail_screen;	private Message file_detail_screen;	private Message set_default_ip_screen;	private Message help_screen;	private Message preview_image_screen;	private Message preview_image_fail_screen;	private Message confirm_file_screen;	public Function function_screen;	public FileList file_list_screen;	public Select setting_screen;	public RecordStore rs;	private TextBox tb;	public String ip, ln, pw;	public String default_ip="";	public String default_sound="1";	public String email,title,content;	public String [] file_selected=new String[5];	public String currentpath ="";	public String file_type = "";	public String back_folder = "";	public String CurrentUser = "";	public String [] file_toSend;	byte[] data_ip=new byte[20];	byte[] data_sound=new byte[1];	public String [] file_name ={};	public String [] dir_name ={};	public String [] drive_name ={};	public boolean sound_setting = true;	public int screenWidth;	public int screenHeight;	InputStream success;	Player p;	private Display display = null;	Timer timer = new Timer();	public DisplayMain() {		exitCommand = new Command ("Exit", Command.EXIT,1);		backCommand = new Command ("Back",Command.BACK,4);		okCommand = new Command ("OK", Command.OK,5);		yesCommand = new Command ("Yes",Command.OK ,1);		noCommand = new Command ("No",Command.CANCEL , 2);		parentCommand =new Command ("Parent folder", Command.SCREEN,1);		previewCommand=new Command ("Preview", Command.SCREEN,4);		detailCommand = new Command ("Detail",Command.SCREEN,3);		mycomputerCommand =new Command ("My computer", Command.SCREEN,2);		display=Display.getDisplay(this);		screenWidth=176;		screenHeight=220;	//	try {////		}catch (Exception e){}		try{			rs=RecordStore.openRecordStore("RemoteController11",false);			data_ip=rs.getRecord(1);			default_ip=new String(data_ip);			ip=default_ip;			data_sound=rs.getRecord(2);			String abc =new String(data_sound);			if (abc.equals("1")) {				sound_setting=true;			}else{				sound_setting=false;			}		}catch (Exception e){			System.out.println(e);			try{				rs=RecordStore.openRecordStore("RemoteController11",true);				int temp=rs.addRecord(data_ip,0,20);				rs.addRecord(data_sound,0,1);				default_ip="";				ip=default_ip;				sound_setting=true;			}catch (Exception n){				System.out.println(n);				try{					rs.closeRecordStore();					rs=null;				}catch (Exception f) {}			}		}		ln="";		pw="";		CurrentUser = "";		title = "";		content = "";		email = "";		start_screen();	}	protected void startApp() {		service = new RemoteIF_Stub();        // init command types        commandTypes = new Hashtable(8);        commandTypes.put("back", new Integer(Command.BACK));        commandTypes.put("cancel", new Integer(Command.CANCEL));        commandTypes.put("exit", new Integer(Command.EXIT));        commandTypes.put("help", new Integer(Command.HELP));        commandTypes.put("item", new Integer(Command.ITEM));        commandTypes.put("ok", new Integer(Command.OK));        commandTypes.put("screen", new Integer(Command.SCREEN));        commandTypes.put("stop", new Integer(Command.STOP));        alertTypes = new Hashtable(5);        alertTypes.put("alarm", AlertType.ALARM);        alertTypes.put("confirmation", AlertType.CONFIRMATION);        alertTypes.put("error", AlertType.ERROR);        alertTypes.put("info", AlertType.INFO);        alertTypes.put("warning", AlertType.WARNING);	}	protected void pauseApp(){	}	protected void destroyApp (boolean arg0) {		login_screen.select_pressed =true;	}	private void generateService(String ip){		try{			String serviceURL = "http://" + ip + "/remote/remote";			System.out.println("Service URL: " + ip);			service._setProperty(RemoteIF_Stub.ENDPOINT_ADDRESS_PROPERTY, serviceURL);			service._setProperty(RemoteIF_Stub.SESSION_MAINTAIN_PROPERTY, new Boolean(true));		} catch (Exception e){		}	}	public class checkUser implements Runnable{		public void run(){			try{				boolean UserValid = service.checkUserValid(ln, pw,"remote1");				System.out.println("User status: " + UserValid);				check_login(UserValid);			} catch (Exception e){				e.printStackTrace();				connect_fail_screen();			}		}	}	public void check_login(boolean UserValid){		if (!UserValid){			login_fail_screen();		} else{			function_screen();		}	}	private void verify_login() {		try{			Thread th = new Thread(new checkUser());			th.start();			//checking screen			connection_waiting_screen=new Animation(display, this,1);			display.setCurrent(connection_waiting_screen);		} catch (Exception e){			e.printStackTrace();		}	}	public void update_filelist(int check) {		try{			Thread th = new Thread(new selectFile(check));			th.start();			//checking screen			files_waiting_screen=new Animation(display, this,2);			display.setCurrent(files_waiting_screen);		} catch (Exception e){			e.printStackTrace();		}	}	public String[] decode_char(String[] list){		String namefile = "";		String decoded_name = "";		try{			for (int i=0; i < list.length; i++){				namefile = list[i];				UTF8_Encoder encoder = new UTF8_Encoder();				decoded_name = encoder.decode(namefile);				list[i] = decoded_name;			}		} catch (Exception e){			e.printStackTrace();		}		return list;	}	public String[] encode_char(String[] list){		String namefile = "";		String encoded_name = "";		try{			for (int i=0; i < list.length; i++){				namefile = list[i];				UTF8_Encoder encoder = new UTF8_Encoder();				encoded_name = encoder.encode(namefile);				list[i] = encoded_name;			}		} catch (Exception e){			e.printStackTrace();		}		return list;	}	public String encode_char(String namefile){		String encodedName = "";		try{			UTF8_Encoder encoder = new UTF8_Encoder();			encodedName = encoder.encode(namefile);		} catch (Exception e){			e.printStackTrace();		}		return encodedName;	}	public class selectFile implements Runnable{		int check;		public selectFile(int c){			check =c;		}		public void run(){			if (check ==0 || check == -1){				try {					drive_name = service.getDriveList("remote2");					drive_name = decode_char(drive_name);					if (check == 0){						file_list_screen.draw_choice();						display.setCurrent(file_list_screen);					} else{						file_list_screen();					}				} catch (Exception e){					connect_fail_screen();				}			}			else{				try{					String encoded_path = encode_char(currentpath);					boolean status = service.listingFile(CurrentUser,encoded_path,"remote2");					if (status){						dir_name = service.getDirList(CurrentUser,encoded_path,"remote2");						file_name = service.getFileList(CurrentUser,encoded_path,"remote2");						dir_name = decode_char(dir_name);						file_name = decode_char(file_name);						if (dir_name.length==0){							file_list_screen.addCommand(previewCommand);							file_list_screen.addCommand(detailCommand);						}else{							file_list_screen.removeCommand(previewCommand);							file_list_screen.removeCommand(detailCommand);						}						file_list_screen.draw_choice();						display.setCurrent(file_list_screen);					} else{						connect_fail_screen();					}				} catch (Exception e){					connect_fail_screen();				}			}			return;		}	}	public class displayDetails implements Runnable{		String modifyDate;		long fileSize;		boolean hidden;		public void run(){		try{			String encoded_path = encode_char(currentpath);			service.getFileDetails(encoded_path,"remote3");			modifyDate = service.getModified(encoded_path,"remote3");			fileSize = service.getFileSize(encoded_path,"remote3");			hidden = service.getHidden(encoded_path);			file_detail_screen(modifyDate,fileSize,hidden);		} catch (Exception e){			System.out.println(e);			connect_fail_screen();		}		}	}	public class previewImage implements Runnable{		public void run(){		boolean ready = false;		try{			String encoded_path = encode_char(currentpath);			ready = service.getPreview2(encoded_path,CurrentUser,screenWidth,screenHeight-screenHeight/10,75,"remote4");			display_Image(ready);		} catch (Exception e){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -