summaryrefslogtreecommitdiff
path: root/client/.metadata/.plugins/org.eclipse.core.resources/.history/28
diff options
context:
space:
mode:
Diffstat (limited to 'client/.metadata/.plugins/org.eclipse.core.resources/.history/28')
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/28/005bf7374c0d00131719b896d543f08c103
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/28/a00c947d310d00131249f322b63acde8133
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/28/e0fe6e7a310d00131249f322b63acde876
3 files changed, 0 insertions, 312 deletions
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/005bf7374c0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/005bf7374c0d00131719b896d543f08c
deleted file mode 100644
index a976666..0000000
--- a/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/005bf7374c0d00131719b896d543f08c
+++ /dev/null
@@ -1,103 +0,0 @@
-package com.macaroon.piztor;
-
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.view.Menu;
-import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
-
-public class Login extends PiztorAct {
-
-
- ActMgr actMgr;
- Button btnLogin;
- EditText edtUser, edtPass;
-
- int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
-
- Handler hand = new Handler() {
- @Override
- public void handleMessage(Message m) {
- System.out.println(m.what);
- if (m.what == 0) {
- ResLogin res = (ResLogin) m.obj;
- UserInfo.token = res.t;
- actMgr.trigger(AppMgr.loginSuccess);
- } else if (m.what == 101) {
- actMgr.trigger(loginFailed);
- }
- }
- };
-
- class StartStatus extends ActStatus {
-
- @Override
- void enter(int e) {
- }
-
- @Override
- void leave(int e) {
- }
- }
-
- class LoginStatus extends ActStatus {
-
- @Override
- void enter(int e) {
- String user = edtUser.getText().toString();
- String pass = edtPass.getText().toString();
- long nowtime = System.currentTimeMillis();
- System.out.println(user + " : " + pass + "\n");
- AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
- }
-
- @Override
- void leave(int e) {
-
- }
-
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- id = "login";
- super.onCreate(savedInstanceState);
- ActStatus[] r = new ActStatus[2];
- r[0] = new StartStatus();
- r[1] = new LoginStatus();
- actMgr = new ActMgr(this, r[0], r);
- actMgr.add(r[0], loginButtonClick, r[1]);
- actMgr.add(r[1], loginFailed, r[0]);
- setContentView(R.layout.activity_login);
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- btnLogin = (Button) findViewById(R.id.login_btn_login);
- edtUser = (EditText) findViewById(R.id.user_id);
- edtPass = (EditText) findViewById(R.id.user_pass);
- btnLogin.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View arg0) {
- actMgr.trigger(loginButtonClick);
- }
- });
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.login, menu);
- return true;
- }
-
-}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/a00c947d310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/a00c947d310d00131249f322b63acde8
deleted file mode 100644
index 3ca0dfe..0000000
--- a/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/a00c947d310d00131249f322b63acde8
+++ /dev/null
@@ -1,133 +0,0 @@
-package com.macaroon.piztor;
-
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.LinkedList;
-import java.util.Queue;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import android.annotation.SuppressLint;
-import android.os.Handler;
-import android.os.Message;
-
-public class Transam implements Runnable {
-
- public Timer timer;
- public Timer mtimer;
- public boolean running = false;
- public boolean flag = true;
- public int cnt = 4;
- Res res;
- Req req;
- public int p; //port
- public String i; //ip
- Thread thread;
- Handler core;
- Handler recall; //recall
- Queue<Req> reqtask ; //request task
-
- Transam(String ip, int port,Handler Recall) {
- p = port;
- i = ip;
- recall = Recall;
- reqtask = new LinkedList<Req>();
- }
-
- public void send(Req r){
- reqtask.offer(r);
-
- }
-
- public void run() { //start the main timer
- //TimerTask tmain = new Timertk();
- //mtimer = new Timer();
- //mtimer.schedule(tmain, 100, 100); //check the queue for every 100 msec
-
- while(true){
- if(running == false){
-
- if(!reqtask.isEmpty()){ //poll the head request
- req = reqtask.poll();
- if(req.time + req.alive < System.currentTimeMillis()){ //time out!
- Message ret = new Message();
- ret.obj = "Time out!";
- ret.what = 100;
- recall.sendMessage(ret);
- }
- else{ //run the request
- final thd t = new thd();
- flag = false;
- thread = new Thread(t);
- cnt = 4;
- running = true;
- thread.start();
- timer = new Timer();
- TimerTask task = new Timertk();
- timer.schedule(task, 2000, 2000);
- }
- }
- }
- }
- }
-
- class tmain extends TimerTask {
- public void run() {
-
- }
- };
-
- class thd implements Runnable {
- public void run() {
- try {
- SocketClient client = new SocketClient(i,p);
- client.sendMsg(req,recall);
- Message msg = new Message();
- msg.what = 1;
- handler.sendMessage(msg);
- client.closeSocket();
- } catch (UnknownHostException e) {
- e.printStackTrace();
- System.out.println("UnknownHostException");
- } catch (IOException e) {
- e.printStackTrace();
- System.out.println("IOException");
- }
-
- }
- }
-
- @SuppressLint("HandlerLeak")
- Handler handler = new Handler() {
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case 1:
- flag = true;
- break;
- case 2:
- final thd t = new thd();
- thread = new Thread(t);
- thread.start();
- break;
- }
- super.handleMessage(msg);
- }
- };
-
- class Timertk extends TimerTask {
- public void run() {
- if (flag == false && cnt > 0) {
- cnt--;
- } else if (cnt == 0) {
- Message msg = new Message();
- msg.obj = "connecting failed";
- msg.what = 101;
- recall.sendMessage(msg);
- timer.cancel();
- } else if (flag == true) {
- timer.cancel();
- running = false;
- }
- }
- };
-} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/e0fe6e7a310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/e0fe6e7a310d00131249f322b63acde8
deleted file mode 100644
index 043638e..0000000
--- a/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/e0fe6e7a310d00131249f322b63acde8
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.macaroon.piztor;
-
-import java.util.HashMap;
-
-import android.annotation.SuppressLint;
-import android.content.Intent;
-import android.os.Handler;
-
-@SuppressLint("UseSparseArrays")
-public class AppMgr {
- // Status
- public enum ActivityStatus{
- create, start, resume, restart, stop, pause, destroy
- }
- static ActivityStatus status;
- static PiztorAct nowAct;
- //TODO fix
- static Handler fromTransam, fromGPS;
- //Event
-
- final static int noToken = 101;
-
-
- static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
-
- static void setStatus(ActivityStatus st) {
- status = st;
- }
-
- static void trigger(int event) {
- Intent i = new Intent();
- System.out.println(nowAct.id + " : " + event);
- if (mp.get(nowAct.getClass()) == null)
- System.out.println("first");
- else if (mp.get(nowAct.getClass()) == null)
- System.out.println("second");
- i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
- nowAct.startActivity(i);
- }
-
- static void add(Class<?> a, Integer event, Class<?> b) {
- if (mp.containsKey(a))
- mp.get(a).put(event, b);
- else {
- HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
- h.put(event, b);
- mp.put(a, h);
- }
- }
-
- static void addTransition(Class<?> a, int i, Class<?> b) {
- if (mp.containsKey(a)) {
- HashMap<Integer, Class<?>> h = mp.get(a);
- h.put(i, b);
- mp.put(a, h);
- } else {
- HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
- h.put(i, b);
- mp.put(a, h);
- }
- }
-
- static void addStatus(Class<?> a) {
- mp.put(a, new HashMap<Integer, Class<?>>());
- }
-
- static void init() {
- mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
- fromTransam = new Handler();
- fromGPS = new Handler();
- addStatus(InitAct.class);
- addStatus(Login.class);
- addTransition(InitAct.class, noToken, Login.class);
- }
-
-}