|
@@ -0,0 +1,153 @@
|
|
|
+package kr.co.icontrols.wallpadcall.imap;
|
|
|
+
|
|
|
+import android.content.Context;
|
|
|
+import android.util.Log;
|
|
|
+
|
|
|
+import com.artncore.WallPadDataMgr.WallpadStatusData;
|
|
|
+import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
|
|
|
+import com.artncore.wallpadimap.RetProci;
|
|
|
+import com.artncore.wallpadimap.WallPadiMAPClient;
|
|
|
+import com.util.LogUtil;
|
|
|
+
|
|
|
+public class Request_call_history_save extends WallPadiMAPClient {
|
|
|
+ String TAG = "Request_call_history_save";
|
|
|
+ String DeviceIP = "NONE";
|
|
|
+ String DeviceDong = "NONE";
|
|
|
+ String DeviceHo = "NONE";
|
|
|
+
|
|
|
+ Context mContext;
|
|
|
+ RetProci Proc;
|
|
|
+ String XMLHeader;
|
|
|
+ WallpadStatusData DBMGR = null;
|
|
|
+
|
|
|
+ String svrIP = "10.0.1.1";
|
|
|
+ int svrPort = 10000;
|
|
|
+ int RequestWork = 0;
|
|
|
+
|
|
|
+ public Request_call_history_save(Context context) {
|
|
|
+ super.setContext(context);
|
|
|
+ try {
|
|
|
+ mContext = context;
|
|
|
+ super.setContext(mContext);
|
|
|
+ DBMGR = new WallpadStatusData(mContext);
|
|
|
+ AddressSet Address = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
|
|
|
+ DBMGR.closeDB();
|
|
|
+ //동, 호, ip 정보 저장
|
|
|
+ DeviceIP = Address.IPAddress;
|
|
|
+ DeviceDong = Address.Dong;
|
|
|
+ DeviceHo = Address.Ho;
|
|
|
+
|
|
|
+ //타임아웃 설정
|
|
|
+ SetSocketWaitCount(2000);
|
|
|
+
|
|
|
+ //XML Header 생성
|
|
|
+ XMLHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
|
|
|
+ "<imap ver = \"1.0\" address = \"" + DeviceIP + "\" sender = \"" + DeviceDong + "동 " + DeviceHo + "호" + "\">\r\n";
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[Exception] Request_call_history_save(Context context)");
|
|
|
+ //e.printStackTrace();
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String makeXMLMsg(String strDong, String strHo, String strType, String time) {
|
|
|
+ try {
|
|
|
+ //<homeaddr name = "homedev" id_high = "102" id_low = "301" />
|
|
|
+ //<call_type> "all" </call_type>
|
|
|
+ //<count> "30" </count >
|
|
|
+
|
|
|
+ String strResult = XMLHeader +
|
|
|
+ " <service type=\"request\" name=\"call_history_save\">\r\n" +
|
|
|
+ //" <visitor_info dong=\"" + strDong + "\" ho=\"" + strHo + "\" distinct=\"" + strType + "\" time=\"" + strTime + "\" filename=\"" + strFileName + "\" message=\"" + strMessage + "\"/>\r\n" +
|
|
|
+ " <homeaddr name = \"homedev\" id_high = \"" + DeviceDong + "\" id_low = \"" + DeviceHo + "\" />\r\n" +
|
|
|
+ " <call_type> \"" + strType + "\" </call_type>\r\n" +
|
|
|
+ " <params event_time = \"" + time + "\" device=\"homedev\" id_high=\"" + strDong + "\" id_low=\"" + strHo + "\" />\r\n" +
|
|
|
+ " </service>\r\n" +
|
|
|
+ "</imap>";
|
|
|
+ return strResult;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[Exception] makeXMLMsg(String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
|
|
|
+ //e.printStackTrace();
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setServerInfo(String strIPAddress, int nPort) {
|
|
|
+ try {
|
|
|
+ svrIP = strIPAddress;
|
|
|
+ svrPort = nPort;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[Exception] setServerInfo(String strIPAddress, int nPort)");
|
|
|
+ //e.printStackTrace();
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setResultCtrl(RetProci retProci) {
|
|
|
+ try {
|
|
|
+ Proc = retProci;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[Exception] setResultCtrl(RetProci retProci)");
|
|
|
+ //e.printStackTrace();
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void ProcComplite() {
|
|
|
+ try {
|
|
|
+ if (Proc != null) {
|
|
|
+ SetItem("service");
|
|
|
+ String result = GetAttributeVal(0, "result");
|
|
|
+ if (result != null) {
|
|
|
+ if (result.equalsIgnoreCase("ok")) {
|
|
|
+ String name= GetAttributeVal(0, "name");
|
|
|
+ String type = GetAttributeVal(0, "type");
|
|
|
+ if ((name!=null && name.equalsIgnoreCase("call_history_save")) && (type!=null && type.equalsIgnoreCase("reply"))) {
|
|
|
+ Proc.ProcSuccess();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Proc.ProcError();
|
|
|
+ } else {
|
|
|
+ if(Proc!=null) Proc.ProcError();
|
|
|
+ }
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[Exception] ProcComplite()");
|
|
|
+ //e.printStackTrace();
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void ProcError() {
|
|
|
+ Proc.ProcError();
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean send_call_history_save(String strDong, String strHo, String strPage, String strTime) {
|
|
|
+ try {
|
|
|
+ SetServerIPConfig(svrIP, svrPort);
|
|
|
+ SendXMLDoc(makeXMLMsg(strDong, strHo, strPage, strTime), true);
|
|
|
+ return true;
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return false;
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log.e(TAG, "[Exception] Request_call_history_save(String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
|
|
|
+ //e.printStackTrace();
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|