Ver código fonte

-- kneet2.0 적용

Jason Lee 10 anos atrás
pai
commit
8343055c65

+ 37 - 1
kneet2.xcodeproj/project.pbxproj

@@ -59,6 +59,12 @@
 		A12BBCDC1BA9527300DE1B94 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = A12BBCAF1BA9527300DE1B94 /* Reachability.m */; };
 		A12BBCE11BA9532800DE1B94 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A12BBCDF1BA9532800DE1B94 /* Localizable.strings */; };
 		A12BBCE81BA9580A00DE1B94 /* IntroViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A12BBCE71BA9580A00DE1B94 /* IntroViewController.m */; };
+		A163663D1BBD1178009A1A16 /* LoginModel.m in Sources */ = {isa = PBXBuildFile; fileRef = A163663C1BBD1178009A1A16 /* LoginModel.m */; settings = {ASSET_TAGS = (); }; };
+		A16366401BBD11CF009A1A16 /* ModeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = A163663F1BBD11CF009A1A16 /* ModeModel.m */; settings = {ASSET_TAGS = (); }; };
+		A16366491BBD11FD009A1A16 /* DeviceModel.m in Sources */ = {isa = PBXBuildFile; fileRef = A16366421BBD11FC009A1A16 /* DeviceModel.m */; settings = {ASSET_TAGS = (); }; };
+		A163664A1BBD11FD009A1A16 /* ItemModel.m in Sources */ = {isa = PBXBuildFile; fileRef = A16366441BBD11FC009A1A16 /* ItemModel.m */; settings = {ASSET_TAGS = (); }; };
+		A163664B1BBD11FD009A1A16 /* RuleModel.m in Sources */ = {isa = PBXBuildFile; fileRef = A16366461BBD11FC009A1A16 /* RuleModel.m */; settings = {ASSET_TAGS = (); }; };
+		A163664C1BBD11FD009A1A16 /* SceneModel.m in Sources */ = {isa = PBXBuildFile; fileRef = A16366481BBD11FC009A1A16 /* SceneModel.m */; settings = {ASSET_TAGS = (); }; };
 		BD7BCC1DC2D16F522F054AB1 /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6B1A9CF6F5E71320D607201 /* Pods.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
 /* End PBXBuildFile section */
 
@@ -181,6 +187,18 @@
 		A12BBCE41BA9534900DE1B94 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
 		A12BBCE61BA9580A00DE1B94 /* IntroViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IntroViewController.h; path = MainScreens/IntroViewController.h; sourceTree = "<group>"; };
 		A12BBCE71BA9580A00DE1B94 /* IntroViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IntroViewController.m; path = MainScreens/IntroViewController.m; sourceTree = "<group>"; };
+		A163663B1BBD1178009A1A16 /* LoginModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginModel.h; sourceTree = "<group>"; };
+		A163663C1BBD1178009A1A16 /* LoginModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginModel.m; sourceTree = "<group>"; };
+		A163663E1BBD11CF009A1A16 /* ModeModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModeModel.h; sourceTree = "<group>"; };
+		A163663F1BBD11CF009A1A16 /* ModeModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ModeModel.m; sourceTree = "<group>"; };
+		A16366411BBD11FC009A1A16 /* DeviceModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceModel.h; sourceTree = "<group>"; };
+		A16366421BBD11FC009A1A16 /* DeviceModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DeviceModel.m; sourceTree = "<group>"; };
+		A16366431BBD11FC009A1A16 /* ItemModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ItemModel.h; sourceTree = "<group>"; };
+		A16366441BBD11FC009A1A16 /* ItemModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ItemModel.m; sourceTree = "<group>"; };
+		A16366451BBD11FC009A1A16 /* RuleModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleModel.h; sourceTree = "<group>"; };
+		A16366461BBD11FC009A1A16 /* RuleModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RuleModel.m; sourceTree = "<group>"; };
+		A16366471BBD11FC009A1A16 /* SceneModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SceneModel.h; sourceTree = "<group>"; };
+		A16366481BBD11FC009A1A16 /* SceneModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SceneModel.m; sourceTree = "<group>"; };
 		D6B1A9CF6F5E71320D607201 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		E193FE221ED4C201DC0AAB83 /* Pods.product.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.product.xcconfig; path = "Pods/Target Support Files/Pods/Pods.product.xcconfig"; sourceTree = "<group>"; };
 /* End PBXFileReference section */
@@ -389,6 +407,18 @@
 			children = (
 				A12BBC951BA9527300DE1B94 /* JDJSONModel.h */,
 				A12BBC961BA9527300DE1B94 /* JDJSONModel.m */,
+				A163663B1BBD1178009A1A16 /* LoginModel.h */,
+				A163663C1BBD1178009A1A16 /* LoginModel.m */,
+				A163663E1BBD11CF009A1A16 /* ModeModel.h */,
+				A163663F1BBD11CF009A1A16 /* ModeModel.m */,
+				A16366411BBD11FC009A1A16 /* DeviceModel.h */,
+				A16366421BBD11FC009A1A16 /* DeviceModel.m */,
+				A16366431BBD11FC009A1A16 /* ItemModel.h */,
+				A16366441BBD11FC009A1A16 /* ItemModel.m */,
+				A16366451BBD11FC009A1A16 /* RuleModel.h */,
+				A16366461BBD11FC009A1A16 /* RuleModel.m */,
+				A16366471BBD11FC009A1A16 /* SceneModel.h */,
+				A16366481BBD11FC009A1A16 /* SceneModel.m */,
 			);
 			path = Model;
 			sourceTree = "<group>";
@@ -527,7 +557,7 @@
 			isa = PBXProject;
 			attributes = {
 				LastUpgradeCheck = 0700;
-				ORGANIZATIONNAME = "Jason Lee";
+				ORGANIZATIONNAME = ntels;
 				TargetAttributes = {
 					A12BBC201BA94FAE00DE1B94 = {
 						CreatedOnToolsVersion = 6.4;
@@ -640,6 +670,7 @@
 				A12BBCB61BA9527300DE1B94 /* NSString-Addtions.m in Sources */,
 				A12BBCB91BA9527300DE1B94 /* UIImage+Addtions.m in Sources */,
 				A12BBCB81BA9527300DE1B94 /* UIDevice-Reachability.m in Sources */,
+				A163664A1BBD11FD009A1A16 /* ItemModel.m in Sources */,
 				A12BBCD81BA9527300DE1B94 /* JDTableViewController.m in Sources */,
 				A12BBCD11BA9527300DE1B94 /* JDObject.m in Sources */,
 				A12BBCCD1BA9527300DE1B94 /* SelectButton.m in Sources */,
@@ -662,14 +693,19 @@
 				A12BBCBC1BA9527300DE1B94 /* UIView+Toast.m in Sources */,
 				A12BBCD21BA9527300DE1B94 /* JDJSONModel.m in Sources */,
 				A12BBCD31BA9527300DE1B94 /* CommonUtil.m in Sources */,
+				A16366401BBD11CF009A1A16 /* ModeModel.m in Sources */,
 				A12BBCC71BA9527300DE1B94 /* CustomShapeButton.m in Sources */,
+				A16366491BBD11FD009A1A16 /* DeviceModel.m in Sources */,
 				A12BBCBA1BA9527300DE1B94 /* UITableView+EnumarateCells.m in Sources */,
 				A12BBCBD1BA9527300DE1B94 /* UIViewController-ActionSheetSimulation.m in Sources */,
 				A12BBCB21BA9527300DE1B94 /* NSArray-Addtions.m in Sources */,
 				A12BBCC51BA9527300DE1B94 /* CustomPicker.m in Sources */,
 				A12BBCCB1BA9527300DE1B94 /* CustomTextView.m in Sources */,
+				A163663D1BBD1178009A1A16 /* LoginModel.m in Sources */,
+				A163664C1BBD11FD009A1A16 /* SceneModel.m in Sources */,
 				A12BBCC81BA9527300DE1B94 /* CustomSwitch.m in Sources */,
 				A12BBCB51BA9527300DE1B94 /* NSDictionary-Additions.m in Sources */,
+				A163664B1BBD11FD009A1A16 /* RuleModel.m in Sources */,
 				A12BBCCC1BA9527300DE1B94 /* DatePickerButton.m in Sources */,
 				A12BBC271BA94FAE00DE1B94 /* main.m in Sources */,
 				A12BBCB31BA9527300DE1B94 /* NSData+AESCrypt.m in Sources */,

+ 5 - 5
kneet2.xcworkspace/xcshareddata/kneet2.xcscmblueprint

@@ -1,16 +1,16 @@
 {
-  "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "900caed9-67a6-4b99-a2bb-6cc4e51cbd2b++3327",
+  "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "3C920A7C95504F9E87D3DB985D41CDC739C22D19",
   "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
-    "900caed9-67a6-4b99-a2bb-6cc4e51cbd2b++3327" : {
+    "3C920A7C95504F9E87D3DB985D41CDC739C22D19" : {
 
     }
   },
   "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
-    "900caed9-67a6-4b99-a2bb-6cc4e51cbd2b++3327" : 0
+    "3C920A7C95504F9E87D3DB985D41CDC739C22D19" : 0
   },
   "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "A517F8A6-9524-41BB-BF99-B6DAE4701A04",
   "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
-    "900caed9-67a6-4b99-a2bb-6cc4e51cbd2b++3327" : "kneet2\/"
+    "3C920A7C95504F9E87D3DB985D41CDC739C22D19" : "kneet2\/"
   },
   "DVTSourceControlWorkspaceBlueprintNameKey" : "kneet2",
   "DVTSourceControlWorkspaceBlueprintVersion" : 204,
@@ -19,7 +19,7 @@
     {
       "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "http:\/\/61.40.220.132:18080\/svn\/wotplatform",
       "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Subversion",
-      "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "900caed9-67a6-4b99-a2bb-6cc4e51cbd2b++3327"
+      "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "3C920A7C95504F9E87D3DB985D41CDC739C22D19"
     }
   ]
 }

+ 3 - 3
kneet2/Classes/AppDelegate.h

@@ -1,9 +1,9 @@
 //
 //  AppDelegate.h
-//  ___PROJECTNAME___
+//  kneet2
 //
-//  Created by ___FULLUSERNAME___ on ___DATE___.
-//  Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
+//  Created by Created by Jason Lee on 10/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
 //
 
 @import UIKit;

+ 3 - 3
kneet2/Classes/AppDelegate.m

@@ -1,9 +1,9 @@
 //
 //  AppDelegate.m
-//  ___PROJECTNAME___
+//  kneet2
 //
-//  Created by ___FULLUSERNAME___ on ___DATE___.
-//  Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
+//  Created by Created by Jason Lee on 10/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
 //
 
 #import "AppDelegate.h"

+ 5 - 5
kneet2/Classes/Common.h

@@ -1,13 +1,13 @@
 //
 //  Common.h
-//  ___PROJECTNAME___
+//  kneet2
 //
-//  Created by ___FULLUSERNAME___ on ___DATE___.
-//  Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
+//  Created by Created by Jason Lee on 10/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
 //
 
-#ifndef ___PROJECTNAME____Common_h
-#define ___PROJECTNAME____Common_h
+#ifndef kneet2_Common_h
+#define kneet2_Common_h
 
 //iphone window
 //320 x 480 pts	320 x 568 pts	375 x 667 pts	414 x 736 pts

+ 164 - 45
kneet2/Classes/Definitions.h

@@ -1,39 +1,157 @@
 //
 //  Definitions.h
-//  ___PROJECTNAME___
+//  kneet2
 //
-//  Created by ___FULLUSERNAME___ on ___DATE___.
-//  Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
+//  Created by Created by Jason Lee on 10/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
 //
 
-#ifndef ___PROJECTNAME____Definitions_h
-#define ___PROJECTNAME____Definitions_h
+#ifndef kneet2_Definitions_h
+#define kneet2_Definitions_h
 
-#define SIGNIFINCANT_LOCATION_USE
+#ifndef PRODUCT_MODE
 
-#ifdef DEBUG_MODE
-    #define API_SERVER      @"http://128.199.125.12:8080"        //개발서버 - 0.7
+NSString *kAPIServer;// = @"http://61.40.220.132:5007";
+NSString *kNISCServer;// = @"http://61.40.220.132:5001";
 
-#else //운영
-    #define API_SERVER      @"http://128.199.125.12:8080"        //개발서버 - 0.7
-#endif
+//static NSString *kAPIServer = @"https://home-api.allofthings.com";
+//static NSString *kNISCServer = @"https://home-api.allofthings.com:5003";
+
+//    #define API_SERVER      @"http://61.40.220.132:5008"      //개발서버 old
+//    #define API_SERVER      @"http://61.40.220.132:5009"      //개발서버 - 0.6
+
+//    #define API_SERVER      @"http://61.40.220.132:5007"        //개발서버 - 0.7
+//    #define NISC_SERVER     @"http://61.40.220.132:5001"        //개발 센서 데이터 등록 (Geofencing)
+
+//상용서버
+//    #define API_SERVER      @"https://home-api.allofthings.com"       //상용서버
+//    #define NISC_SERVER     @"https://home-api.allofthings.com:5003"  //N-MAS REST (Geofencing)
+
+#else //운영모드
+
+static NSString *kAPIServer = @"https://home-api.allofthings.com";
+static NSString *kNISCServer = @"https://home-api.allofthings.com:5003";
+
+//    #define API_SERVER      @"http://61.40.220.132:5008"      //개발서버 old
+//    #define API_SERVER      @"http://61.40.220.132:5009"       //개발서버 - 0.6
+
+//개발
+//    #define API_SERVER      @"http://61.40.220.132:5007"        //개발서버 - 0.7
+//    #define NISC_SERVER     @"http://61.40.220.132:5001"        //개발 센서 데이터 등록 (Geofencing)
 
+//상용서버
+//    #define API_SERVER      @"https://home-api.allofthings.com"       //상용서버
+//    #define NISC_SERVER     @"https://home-api.allofthings.com:5003"  //N-MAS REST (Geofencing)
+
+#endif
 
 //Network Constants
-#define API_ROOT_PATH       @"/yo"
+#define API_ROOT_PATH       @"/v1"
 
 //1 - 공통
 #define API_GET_APP_VERSION     @"/app_version"
 //#define API_GET_CODE_LIST   @"/getCodeList"
 
+#define API_GET_MOBILE          @"/mobile_device/%@"
+#define API_POST_MOBILE         @"/mobile_device"
+#define API_POST_MOBILE_TOKEN   @"/mobile_device/%@/push_token"
+
 //10 - 회원
-#define API_POST_SIGN_UP        @"/join.do"             //signup
 #define API_POST_SIGN_IN        @"/member/login"        //로그인
 #define API_GET_SIGN_IN_AUTO    @"/member"              //자동로그인
 #define API_POST_SIGN_OUT       @"/member/logout"       //로그아웃
 
-//20 - Friends
-#define API_POST_FRIENDS        @"/friendList.do"       //friends
+#define API_POST_SIGN_UP        @"/member"              //회원가입
+#define API_POST_MEMBER_UPDATE  @"/member/%@/%@"        //회원정보 수정
+#define API_POST_AUTH_MAIL      @"/member/auth_mail"    //이메일 인증 재발송
+#define API_POST_RESET_PWD      @"/member/password"     //비밀번호 재설정
+#define API_GET_MOBILE_DEVICES  @"/member/devices"      //단말 목록
+#define API_POST_NEW_MOBILE_DEVICE @"/member/new_mobile_device" //새 단말 인증
+#define API_POST_REPLACE_MOBILE_DEVICE  @"/member/replace_device"   //단말 교체
+#define API_DELETE_MOBILE_DEVICE    @"/member/device"           //단말 등록 해제
+
+#define API_GET_CHECK_PWD       @"/member/%@"               //비밀번호 확인
+#define API_DELETE_ACCOUNT      @"/member/%@"               //계정삭제
+#define API_GET_MEMBER_ICONS    @"/member/icons"            //멤버아이콘 리스트
+
+#define API_POST_HOMEGROUP          @"/member/homegrp"      //홈 생성
+#define API_POST_HOMEGROUP_RENAME   @"/homegrp/name"        //홈 이름 변경
+#define API_POST_HOMEGROUP_LOCATION @"/homegrp/location"    //홈 위치 변경
+#define API_DELETE_HOMEGROUP        @"/homegrp/%@"          //홈그룹 삭제
+#define API_GET_HOMEGROUP           @"/homegrps"            //홈그룹 리스트
+
+
+//#define API_POST_HOMEGROUP_LOCATION @"/member/homegrp/location" //홈 위치 등록
+
+//12 - 초대
+#define API_POST_HOMEGROUP_MEMBER_STAT      @"/homegrp_members/status"  //홈그룹 초대 알림.
+#define API_GET_HOMEGROUP_MEMBERS           @"/homegrp_members"         //홈그룹 멤버 목록
+#define API_POST_HOMEGROUP_MEMBER_INVITE    @"/homegrp_members"         //홈멤버 초대
+#define API_POST_HOMEGROUP_MEMBER_UPDATE    @"/homegrp_members/%@"      //홈멤버 업데이트
+
+//20 - dashboard
+#define API_GET_DASHBOARD                   @"/dashboard"       //대시보드
+#define API_GET_DASHBOARD_MODE_LIST         @"/modes"                   //대시보드 모드 조회
+#define API_POST_DASHBOARD_MODE_CHANGE      @"/modes/%@/current_mode"   //대시보드 모드 변경
+#define API_GET_HOMELOG                     @"/homelog"
+
+//30 - Things
+#define API_GET_GROUPS_DEVICES  @"/groups/devices"      //그룹 리스트 조회
+#define API_POST_GROUP          @"/groups"              //그룹 생성
+#define API_POST_GROUP_ADD      @"/groups/devices/%@"   //그룹에 장치 추가
+#define API_POST_GROUP_UPDATE   @"/groups/%@"           //그룹 수정
+#define API_DELETE_GROUP        @"/groups/%@"           //그룹 삭제
+#define API_POST_GROUP_DELETE   @"/groups/devices/%@"   //그룹 내 디바이스 삭제
+
+#define API_PARAM_PAGING        @"?paging_datetime=%@&paging_type=%@"
+//#define API_GET_DEVICE_LIST     @"/devices"
+#define API_GET_DEVICE_DETAIL   @"/devices/%@"
+#define API_POST_NODE_COMMAND   @"/devices/%@/nodes/%@/commands"
+#define API_GET_DEVICE_ICONS    @"/devices/icons/%@"       //디바이스 아이콘
+#define API_GET_DEVICE_UPDATE   @"/devices/property/%@" //디바이스 수정
+#define API_DELETE_DEVICE       @"/devices/%@"            //디바이스 삭제
+
+#define API_POST_CAMERA         @"/devices/camera"          //카메라 등록
+#define API_POST_CAMERA_UPDATE  @"/devices/camera/%@"          //카메라 수정
+
+#define API_POST_SMARTPHONE     @"/devices/smart_phone"         //스마트폰 등록
+#define API_POST_PARTNER_QR     @"/devices/partner_device/qr"   //QR 인증
+#define API_POST_PARTNER_PASSWD @"/devices/partner_device/password"   //QR 인증
+
+#define API_POST_DEVICE_COMMAND     @"/devices/%@/commands/status"   //장치 상태(등록) 제어 명령 실행
+#define API_DELETE_DEVICE_COMMAND   @"/devices/%@/commands/status"   //장치 상태(삭제) 제어 명령 실행
+#define API_GET_DEVICE_COMMAND      @"/devices/%@/commands/status"   //장치 상태(Polling) 제어 명령 조회
+#define API_GET_DEVICE_TYPES        @"/devices/device_class/%@"  //장치 유형 조회(Device Class)
+#define API_POST_DEVICE_TYPES       @"/devices/device_class/%@"  //장치 유형 변경(Device Class)
+
+//40 - Rules
+#define API_GET_RULE            @"/rules"
+#define API_GET_RULE_DETAIL     @"/rules/%@"
+#define API_POST_RULE_STATUS    @"/rules/%@/status"
+#define API_POST_RULE           @"/rules"
+#define API_DELETE_RULE         @"/rules/%@"
+#define API_POST_RULE_MODIFY    @"/rules/%@"
+#define API_GET_RULE_CMDCLS     @"/rules/cmdcls/%@"
+#define API_GET_RULE_MOBILE     @"/rules/mobile_devices"
+#define API_GET_RULE_MEMBERS    @"/rules/mobile_members"
+
+
+#define API_GET_PRERULE_LIST    @"/predefined_rules"
+#define API_GET_PRERULE_DETAIL  @"/predefined_rules/%@"
+#define API_GET_PRERULE_DEVICES @"/predefined_rules/%@/devices/%@"
+
+//50 - Scenes
+#define API_GET_SCENE           @"/scenes"
+#define API_GET_SCENE_DETAIL    @"/scenes/%@"
+#define API_POST_SCENE_EXECUTE  @"/scenes/%@/execution"
+#define API_POST_SCENE          @"/scenes"
+#define API_DELETE_SCENE        @"/scenes/%@"
+#define API_POST_SCENE_MODIFY   @"/scenes/%@"
+#define API_GET_SCENE_CMDCLS    @"/scenes/cmdcls"
+
+#define API_GET_PRESCENE_LIST    @"/predefined_scenes"
+#define API_GET_PRESCENE_DETAIL  @"/predefined_scenes/%@"
+#define API_GET_PRESCENE_DEVICES @"/predefined_scenes/%@/devices/%@"
 
 //60 - 기타
 #define API_GET_LOCATION_CODES   @"/common/weather_location_codes"
@@ -45,8 +163,8 @@
 #define URL_PATH_HELP           @"/html/page_app/app_help_01.html"
 
 //앱스토어 링크
-#define URL_APP_UPDATE          @"https://itunes.apple.com/kr/app/kneet/id932743659?mt=8"
-
+#define URL_APP_UPDATE          @"https://itunes.apple.com/kr/app/kneet/id1042171198?mt=8"
+#define URL_DAWON_UPDATE        @"https://itunes.apple.com/kr/app/pm-b300w/id698046076?l=en&mt=8"
 
 //Global Menu Id
 //메뉴 이름, 메뉴 아이디, 부모-자식,
@@ -68,10 +186,11 @@ typedef NS_ENUM(NSInteger, KNMenuId) {
 #define MOBILE_SERVICE_ID       @"10001"     //for kneet
 #define MOBILE_DEVICE_TYPE      @"MI"        //디바이스 타입
 
-#define APPSTORE_TYPE           @"I"
+#define APPSTORE_TYPE           @"A"
 #define KNEET_DEVICE_CHECKIN    @"TRUE"
 #define KNEET_DEVICE_CHECKOUT   @"FALSE"
 
+
 #define KNEET_MEMBER_MASTER     @"MAS"
 #define KNEET_MEMBER_POWER      @"POW"
 #define KNEET_MEMBER_SIMPLE     @"SIM"
@@ -84,25 +203,25 @@ typedef NS_ENUM(NSInteger, KNMenuId) {
 #define API_RESPONSE_MOBILES_OVER           @"401-105"
 
 //UserDefaults
-#define USER_DEF_EMAIL          @"HeyLetsEmail"
-#define USER_DEF_APPINIT        @"HeyLetsAppInit"
-#define USER_DEF_AGREEMENT      @"HeyLetsAgreement"
-#define USER_DEF_TUTORIAL_DONE  @"HeyLetsHasDoneTutorial"
-#define USER_DEF_AUTO_LOGIN     @"HeyLetsAutoLogin"
-
-#define USER_DEF_USERID_LIST    @"HeyLetsUserIdList"
-#define USER_DEF_MOBILE_ID      @"HeyLetsMobileDeviceId"
-#define USER_DEF_MOBILE_AUTHOR  @"HeyLetsMobileDeviceAuthorization"
-#define USER_DEF_GEOFENCE       @"HeyLetsMobileDeviceGeoFence"
-#define USER_DEF_GEOFENCE_SENSORS       @"HeyLetsMobileDeviceGeoFence"
-
-#define USER_DEF_POPUP_URL      @"HeyLetsIntroPopUpURL"
-#define USER_DEF_POPUP_SHOW     @"HeyLetsIntroPopUpShow"
-#define USER_DEF_TMP_EMAIL      @"HeyLetsTempUserEmail"
-#define USER_DEF_NEW_EMAIL      @"HeyLetsNewUserEmail"
-#define USER_DEF_MODE_CHANGE    @"HeyLetsModeChange"
-
-#define USER_DEF_HOMEGRP_ID     @"HeyLetsHomeGrpId"
+#define USER_DEF_APPINIT        @"KneetAppInit"
+#define USER_DEF_AGREEMENT      @"KneetAgreement"
+#define USER_DEF_TUTORIAL_DONE  @"KneetHasDoneTutorial"
+#define USER_DEF_AUTO_LOGIN     @"KneetAutoLogin"
+#define USER_DEF_LOGO_ANIMATION @"KneetLogoAnimationWasPlaying"
+
+#define USER_DEF_USERID_LIST    @"KneetUserIdList"
+#define USER_DEF_MOBILE_ID      @"KneetMobileDeviceId"
+#define USER_DEF_MOBILE_AUTHOR  @"KneetMobileDeviceAuthorization"
+#define USER_DEF_GEOFENCE       @"KneetMobileDeviceGeoFence"
+#define USER_DEF_GEOFENCE_SENSORS       @"KneetMobileDeviceGeoFence"
+
+#define USER_DEF_POPUP_URL      @"KneetIntroPopUpURL"
+#define USER_DEF_POPUP_SHOW     @"KneetIntroPopUpShow"
+#define USER_DEF_TMP_EMAIL      @"KneetTempUserEmail"
+#define USER_DEF_NEW_EMAIL      @"KneetNewUserEmail"
+#define USER_DEF_MODE_CHANGE    @"KneetModeChange"
+
+#define USER_DEF_HOMEGRP_ID     @"KneetHomeGrpId"
 
 #define USER_DEF_AUTOTOKEN      @"LoginAuthToken"
 
@@ -181,14 +300,14 @@ typedef NS_ENUM(NSInteger, KNMenuId) {
 
 
 //메시지 정의
-#define MSG_ALERT_APP_UPDATE            @"새로운 업데이트 버전이 출시되었습니다.\n확인을 누르시면 업데이트 페이지로\n이동합니다."
-#define MSG_ALERT_ERROR_CRITICAL        @"사용할수 없습니다.\n앱 종료 후 다시 시도하세요."
-#define MSG_ALERT_SERVER_FAIL           @"서버에 연결할 수 없습니다.\n다시 시도하세요."
-#define MSG_LOCATION_DISABLE            @"[설정 > 개인정보보호 > 위치서비스]에서 AoT@Home앱이 활성화되어 있을 때에만 위치센서가 동작합니다."
-#define MSG_NOT_WIFI_STREAM             @"WiFi 미연결 상태에서는\n데이터 통화료가 과도하게\n부과될 수 있으니 주의하세요"
-//
-//#define MSG_ALERT_SNS_GOOGLEPLUS_ERROR @"구글 플러스 정보를 읽어오는 중\n오류가 발생했습니다.\n다시 시도해 주세요."
+#define MSG_ALERT_APP_UPDATE            NSLocalizedString(@"새로운 업데이트 버전이 출시되었습니다.\n확인을 누르시면 업데이트 페이지로\n이동합니다.", @"새로운 업데이트 버전이 출시되었습니다.\n확인을 누르시면 업데이트 페이지로\n이동합니다.")
+#define MSG_ALERT_ERROR_CRITICAL        NSLocalizedString(@"사용할수 없습니다.\n앱 종료 후 다시 시도하세요.", @"사용할수 없습니다.\n앱 종료 후 다시 시도하세요.")
+#define MSG_ALERT_SERVER_FAIL           NSLocalizedString(@"서버에 연결할 수 없습니다.\n다시 시도하세요.", @"서버에 연결할 수 없습니다.\n다시 시도하세요.")
+#define MSG_LOCATION_DISABLE            NSLocalizedString(@"[설정 > 개인정보보호 > 위치서비스]에서\nAoT@Home앱이 활성화되어\n있을 때에만 위치센서가 동작합니다", @"[설정 > 개인정보보호 > 위치서비스]에서\nAoT@Home앱이 활성화되어\n있을 때에만 위치센서가 동작합니다")
+#define MSG_CAMERA_DISABLE            NSLocalizedString(@"[설정 > 개인정보보호 > 카메라]에서\nAoT@Home앱이 활성화되어\n있을 때에만 QR등록이 동작합니다", @"[설정 > 개인정보보호 > 카메라]에서\nAoT@Home앱이 활성화되어\n있을 때에만 QR등록이 동작합니다")
+
+#define MSG_NOT_WIFI_STREAM             NSLocalizedString(@"WiFi 미연결 상태에서는\n데이터 통화료가 과도하게\n부과될 수 있으니 주의하세요", @"WiFi 미연결 상태에서는\n데이터 통화료가 과도하게\n부과될 수 있으니 주의하세요")
 
 
-//___PROJECTNAME____Definitions_h
+//kneet2_Definitions_h
 #endif

+ 1 - 1
kneet2/Classes/Handler/RequestHandler.h

@@ -1,6 +1,6 @@
 //
 //  RequestHandler.h
-//  JSDevelop
+//  Giwa
 //
 //  Created by Jason Lee on 12/16/14.
 //  Copyright (c) jasondevelop. All rights reserved.

+ 86 - 54
kneet2/Classes/Handler/RequestHandler.m

@@ -1,11 +1,10 @@
 //
 //  RequestHandler.m
-//  JSDevelop
+//  Giwa
 //
 //  Created by Jason Lee on 12/16/14.
 //  Copyright (c) jasondevelop. All rights reserved.
 //
-
 #import "JDObject.h"
 #import "AFHTTPRequestOperation.h"
 
@@ -40,17 +39,17 @@
 //    return encodedString;
 }
 
-- (NSString*)URLDecodedString:(NSString *)string
-{
-
-
-
-	NSString *result = (__bridge NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
-                                                                                                    (CFStringRef)string,
-                                                                                                    CFSTR(""),
-                                                                                                    kCFStringEncodingUTF8);
-	return result;
-}
+//- (NSString*)URLDecodedString:(NSString *)string
+//{
+//
+//
+//
+//	NSString *result = (__bridge NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
+//                                                                                                    (CFStringRef)string,
+//                                                                                                    CFSTR(""),
+//                                                                                                    kCFStringEncodingUTF8);
+//	return result;
+//}
 
 #pragma mark - Prepare Request
 - (void)sendRequest {
@@ -164,49 +163,71 @@
 
     NSString *rootPath = API_ROOT_PATH;
 
-    NSString *pathURL = [self URLEncodedString:[NSString stringWithFormat:@"%@%@%@", API_SERVER, rootPath, apiPath]];
+    NSString *pathURL = [self URLEncodedString:[NSString stringWithFormat:@"%@%@%@", kAPIServer, rootPath, apiPath]];
 
     NSLog(@"PATH=%@", pathURL);
     NSLog(@"PARAM=%@", parameters);
 
     NSError *error = nil;
     BOOL hasFile = NO, isDataImage = NO, isMultipartForm = parameters[ksHTTPMultipartForm] && [parameters[ksHTTPRequestPOST] boolValue] ? YES : NO;
-    NSData *dataToUpload = nil;
-    NSString *dataParameter = nil;
+    NSMutableArray *fileArray = nil;
+    NSMutableArray *fileParams = nil;
 
-    NSInteger i = 0;
+    NSInteger index = 0;
     for (NSObject *obj in parameters.allValues) {//파일형식이 있는지 체크,
-        
-        if (!hasFile && ([obj isKindOfClass:[UIImage class]] || [obj isKindOfClass:[NSData class]])) {
+
+        if (([obj isKindOfClass:[UIImage class]] || [obj isKindOfClass:[NSData class]])) {
+            if (!fileArray) {
+                fileArray = [[NSMutableArray alloc] init];
+                fileParams = [[NSMutableArray alloc] init];
+                hasFile = YES;
+            }
+
             isDataImage = [obj isKindOfClass:[UIImage class]];
-            dataToUpload = isDataImage ? UIImageJPEGRepresentation((UIImage *)obj, 1.0) : (NSData *)obj;
-            dataParameter = parameters.allKeys[i];
-            hasFile = YES;
-            break;
+            [fileArray addObject:isDataImage ? UIImageJPEGRepresentation((UIImage *)obj, 1.0) : (NSData *)obj];
+            [fileParams addObject:parameters.allKeys[index]];
         }
-        i++;
+        index++;
     }
 
+
     NSMutableURLRequest *request = nil;
 
-    if (!hasFile && !isMultipartForm) {//no image
-        request = [[AFHTTPRequestSerializer serializer] requestWithMethod:method URLString:pathURL parameters:parameters error:&error];
+    if (!hasFile && !isMultipartForm) {//no file
+
+        request = [[AFJSONRequestSerializer serializer] requestWithMethod:method URLString:pathURL parameters:parameters error:&error];
+        [request setHTTPMethod:method];
         [request setTimeoutInterval:kDefaultTimeOut];
+        [request setValue:@"application/json;charset=UTF-8" forHTTPHeaderField:@"Content-Type"];
         
+        NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0];
+        //FIXME : when production
+#ifdef DEBUG_MODE
+        language = @"ko";
+#endif
+        [request setValue:language forHTTPHeaderField:@"Accept-Language"];
+
     } else {//Multipart-form
-        
+
         NSMutableDictionary *tmpParams = [NSMutableDictionary dictionaryWithDictionary:parameters];
-        [tmpParams removeObjectForKey:dataParameter];
-        
-        request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:method URLString:pathURL parameters:tmpParams constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
-            NSString *fileName = isDataImage ? @"tmp.jpg" : @"tmp.txt";
-            NSString *mimeType = isDataImage ? @"image/jpeg" : @"application/json"; //text/plain
-            
-            [formData appendPartWithFileData:dataToUpload name:dataParameter fileName:fileName mimeType:mimeType];
-            
+        [tmpParams removeObjectForKey:fileParams];
+
+        request = [[AFJSONRequestSerializer serializer] multipartFormRequestWithMethod:method URLString:pathURL parameters:tmpParams constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
+                NSString *mimeType = isDataImage ? @"image/jpeg" : @"text/plain";
+                NSInteger i = 0;
+                NSString *name = [fileParams[i] substringToIndex:[fileParams[i] rangeOfString:@"_"].location];
+                for (NSData *dataToUpload in fileArray) {
+
+                    NSString *fileName = isDataImage ? [NSString stringWithFormat:@"tmp_%zd.jpg", i+1] : [NSString stringWithFormat:@"tmp_%zd.txt", i+1];
+                    [formData appendPartWithFileData:dataToUpload name:name fileName:fileName mimeType:mimeType];
+                }
+
         } error:&error];
     }
 
+    [request setValue:self.authorization ? self.authorization : ksEmptyString forHTTPHeaderField:@"Authorization"];
+    [request setValue:self.homegrpId ? self.homegrpId : ksEmptyString forHTTPHeaderField:@"X-kneet-homegrp"];
+
     AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
     op.responseSerializer = [AFHTTPResponseSerializer serializer];
 
@@ -236,24 +257,26 @@
             JSONModel = rawJSON;
         }
 
-        if ([JSONModel isKindOfClass:[JDJSONModel class]]) {
-            if ([((JDJSONModel *)JSONModel).result isEqualToString:@"0000"]) {
-                //쿠키 설정
-                NSArray* cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:[operation.response allHeaderFields] forURL:operation.request.URL];
-                if (cookies && cookies.count > 0) {
-                    [self setCookies:cookies];
-                }
-                
-                if (completion) {
-                    completion(JSONModel);
-                }
-            } else {//오류
-                if (failure) {
-                    failure(JSONModel);
-                }
-            }
+
+        if (error) {//오류 처리
+//            JSONModel *result = [[JSONModel alloc] initWithString:JSONString error:nil];
+//
+//            NSString *resultMsg = result.resultMsg ? result.resultMsg : MSG_ALERT_API_FAIL;
+//            [[GWFacade facade] alert:resultMsg];
+            JSONModel = nil;
+        }
+
+        //쿠키 설정
+        NSArray* cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:[operation.response allHeaderFields] forURL:operation.request.URL];
+        if (cookies && cookies.count > 0) {
+            [self setCookies:cookies];
+        }
+
+        if (completion) {
+            completion(JSONModel);
         }
 
+
     } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
         [self finishRequest];
         NSLog(@"HTTPStatus=%zd\n%@", operation.response.statusCode, error.localizedDescription);
@@ -263,11 +286,20 @@
 #ifndef PRODUCT_MODE
         NSLog(@"\n\nERROR=%@\n\n", JSONString);
 #endif
-        JDJSONModel *jerror = [[JDJSONModel alloc] initWithString:JSONString error:&error];
 
-        if (failure && jerror) {
+        JDErrorModel *jerror = [[JDErrorModel alloc] initWithString:JSONString error:&error];
+
+        BOOL isLoginView = [[JDFacade facade].currentViewController isKindOfClass:[NSClassFromString(@"LoginViewController") class]];
+        if (!isLoginView && [jerror.errorCode isEqualToString:API_RESPONSE_UNAUTHORIZED_TOKEN]) {//인증토큰이 만료된 경우, 로그인 이동
+            [[JDFacade facade] gotoLoginViewWithExpiring];
+
+        } else if ([jerror.errorCode isEqualToString:API_RESPONSE_UNAUTHORIZED_HOME]) {//홈그룹 아이디가 만료된 경우, 로그인 이동
+            [[JDFacade facade] checkDefaultHome];
+
+        } else if (failure && jerror) {
             failure(jerror);
         }
+
     }];
 
     [[NSOperationQueue mainQueue] addOperation:op];
@@ -284,7 +316,7 @@
 
     NSString *rootPath = API_ROOT_PATH;
 
-    NSString *pathURL = [self URLEncodedString:[NSString stringWithFormat:@"%@%@%@", API_SERVER, rootPath, apiPath]];
+    NSString *pathURL = [self URLEncodedString:[NSString stringWithFormat:@"%@%@%@", kAPIServer, rootPath, apiPath]];
 
     NSLog(@"PATH=%@", pathURL);
     NSLog(@"PARAM=%@", parameters);

+ 36 - 8
kneet2/Classes/JDFacade.h

@@ -1,9 +1,9 @@
 //
 //  JSFacade.h
-//  ___PROJECTNAME___
+//  kneet2
 //
-//  Created by ___FULLUSERNAME___ on ___DATE___.
-//  Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
+//  Created by Created by Jason Lee on 10/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
 //
 
 #import <Foundation/Foundation.h>
@@ -22,6 +22,9 @@
 //OpenSource
 //#import "ReactiveCocoa.h"
 
+#import "LoginModel.h"
+#import "ModeModel.h"
+
 #import "AppDelegate.h"
 
 typedef void(^completionCallBackHandler)(void);
@@ -29,13 +32,24 @@ typedef void(^failureCallBackHandler)(void);
 
 @interface JDFacade : NSObject
 
+@property (strong, nonatomic) NSString *deviceUUID;   //local uuid
+@property (strong, nonatomic) NSString *APNSToken;          //APNS 토큰
 
-@property (strong, nonatomic) NSMutableArray *geofencingSensors;
 
-@property (strong, nonatomic) NSString *deviceUUID;   //local uuid
+@property (strong, nonatomic) LoginModel *loginUser;
+@property (strong, nonatomic) HomeGroupModel *loginHomeGroup;
+
+@property (strong, nonatomic) NSArray<ModeModel> *modeList;
+@property (assign, nonatomic) KNMenuId wishMenuId;
+
+@property (assign, nonatomic) BOOL hasLoggedIn;
+
+//Local Temporary Variables
+@property (strong, nonatomic) NSString *tmpHomegrpName;
+@property (strong, nonatomic) NSString *tmpEmailId;
+@property (strong, nonatomic) NSString *tmpPassword;
+
 
-@property (strong, nonatomic) NSString *cypherKey;
-@property (strong, nonatomic) NSString *APNSToken;          //APNS 토큰
 
 //Local Temporary Variables
 
@@ -74,9 +88,23 @@ typedef void(^failureCallBackHandler)(void);
 - (void)dismissViewControllerByPush:(UIViewController *)vc completion:(completionCallBackHandler)completion;
 
 //UI Flow
-- (void)gotoMain;
+- (void)gotoLoginView;
+- (void)gotoLoginViewWithExpiring;
+- (void)logout;
+- (void)loadInvitationView;
+
+- (void)checkDefaultHome;
+- (void)gotoStartHome:(BOOL)canGoBack;
+//- (void)gotoTutorial:(BOOL)isCalledFromMenu;
+
+- (void)gotoWishMenu:(KNMenuId)menuId;
+- (void)gotoWishMenu:(KNMenuId)menuId completion:(completionCallBackHandler)completion;
+- (void)updateHomegrpListForLoginUser:(completionCallBackHandler)completion;
+- (void)updateLoginInfo:(completionCallBackHandler)completion;
+
 
 - (void)alertLocationServiceDisabled;
+- (void)alertCameraPermissionDisabled;
 
 //Debug
 - (BOOL)redirectNSLog;

+ 154 - 7
kneet2/Classes/JDFacade.m

@@ -1,9 +1,9 @@
 //
 //  JDFacade.m
-//  ___PROJECTNAME___
+//  kneet2
 //
-//  Created by ___FULLUSERNAME___ on ___DATE___.
-//  Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
+//  Created by Created by Jason Lee on 10/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
 //
 
 @import ObjectiveC.runtime;
@@ -298,10 +298,157 @@
 }
 
 #pragma mark - UI Flow
-- (void)gotoMain {
-    UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ListViewController" storyboardName:@"Main"];
-    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc];
-    self.appDelegate.window.rootViewController = nc;
+- (void)gotoLoginView {
+    UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"LoginViewController" storyboardName:@"Main"];
+    [JDFacade facade].appDelegate.window.rootViewController = vc;
+}
+
+//- (void)gotoLoginViewWithExpiring {
+//    LoginViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"LoginViewController" storyboardName:@"Main"];
+//    [vc actionAfterLogout];
+//}
+//
+//- (void)logout {
+//    LoginViewController *lvc = (LoginViewController *)[CommonUtil instantiateViewControllerWithIdentifier:@"LoginViewController" storyboardName:@"Main"];
+//    [lvc requestLogout];
+//}
+//
+//- (void)loadInvitationView {
+//    UIViewController *pvc = [JDFacade facade].currentViewController.presentedViewController;
+//    if (!pvc) {
+//        pvc = [JDFacade facade].currentViewController;
+//    }
+//    
+//    UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"InvitationListViewController" storyboardName:@"Main"];
+//    [[JDFacade facade] presentViewControllerByPush:vc pvc:pvc];
+//}
+//
+//- (void)checkDefaultHome {
+//    if (!self.loginUser) {//로그인이 안된 경우, 불필요함.
+//        return;
+//    }
+//    
+//    [self updateHomegrpListForLoginUser:^{
+//        //1. 다른 홈이 있는지 확인 - 정렬순서대로 기본홈을 설정 - currentHome
+//        if (self.loginUser.homegrpList && self.loginUser.homegrpList.count) {
+//            self.loginHomeGroup = self.loginUser.homegrpList[0];
+//            [self gotoWishMenu:KNMenuIdDashboard];
+//            return;
+//        }
+//        
+//        //2. 다른 홈이 없는 경우, - 홈만들기로 이동함.
+//        NotifyAlertView *alert = [[NotifyAlertView alloc] initWithTitle:NSLocalizedString(@"알림", @"알림") message:NSLocalizedString(@"현재 참여 중인 홈이 없습니다\n새로운 홈 만들기를 시작할까요?", @"현재 참여 중인 홈이 없습니다\n새로운 홈 만들기를 시작할까요?") delegate:nil OKButtonTitle:NSLocalizedString(@"확인", @"확인") cancelButtonTitle:NSLocalizedString(@"취소", @"취소")];
+//        [alert showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
+//            if (buttonIndex == 0) {//OK
+//                [self gotoStartHome:NO];
+//            } else {
+//                [self logout];
+//            }
+//        }];
+//    }];
+//}
+
+- (void)gotoStartHome:(BOOL)canGoBack {
+//    StartHomeViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"StartHomeViewController" storyboardName:@"SignUp"];
+//    vc.canGoBack = canGoBack;
+//    [[JDFacade facade] presentViewControllerByPush:vc pvc:self.currentViewController];
+}
+
+
+- (void)gotoWishMenu:(KNMenuId)menuId {
+    [self gotoWishMenu:menuId completion:nil];
+}
+
+
+- (void)gotoWishMenu:(KNMenuId)menuId completion:(completionCallBackHandler)completion {
+    self.wishMenuId = menuId;
+    
+    UIViewController *vc = self.appDelegate.window.rootViewController;
+    if (vc.presentedViewController || (vc.presentingViewController && (vc.modalPresentationStyle == UIModalPresentationFullScreen))){
+        [vc dismissViewControllerAnimated:YES completion:nil];
+    }
+    
+    MenuViewController *mvc = [JDFacade facade].menuViewController;
+    [mvc gotoWishMenu:self.wishMenuId completion:completion];
+}
+
+- (void)updateHomegrpListForLoginUser:(completionCallBackHandler)completion {
+    
+    NSDictionary *parameter = @{@"device_sn": [JDFacade facade].deviceUUID};
+    
+    dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{//RUN to background thread
+        HomeGroupListModel *homegrpList = [[RequestHandler handler] sendSyncGetRequestAPIPath:API_GET_HOMEGROUP parameters:parameter
+                                                                                   modelClass:[HomeGroupListModel class] showLoadingView:YES];
+        
+        
+        //        NSLog(@"%s\n %@", __PRETTY_FUNCTION__, homegrpList);
+        //홈그룹을 설정함.
+        self.loginUser.homegrpList = homegrpList && homegrpList.homegrpList ? homegrpList.homegrpList : nil;
+        
+        //로그인 홈을 지정함.
+        for (HomeGroupModel *homegrp in self.loginUser.homegrpList) {
+            if ([self.loginUser.homegrpId isEqualToString:homegrp.homegrpId]) {
+                self.loginHomeGroup = homegrp;
+                break;
+            }
+        }
+        
+        [[LocationHandler handler] resetAllMonitoredRegions];   //현재 앱이 구동 중이면, 위치 센서를 다시 등록해야함.
+        [[LocationHandler handler] registerGeofencingForHomeGroupIndex:0];  //모든 홈 그룹을 다시 모니터링 등록 - 루프
+        
+        if (completion) {
+            completion();
+        }
+    });
+}
+
+- (void)updateLoginInfo:(completionCallBackHandler)completion {
+    NSLog(@"%s\n %@", __PRETTY_FUNCTION__, [JDFacade facade].deviceUUID);
+    
+    NSDictionary *parameter = @{@"device_sn": [JDFacade facade].deviceUUID,
+                                @"device_token": [JDFacade facade].APNSToken ? [JDFacade facade].APNSToken : ksEmptyString,
+                                @"os_type": MOBILE_DEVICE_TYPE};
+    
+    NSString *path = [NSString stringWithFormat:API_GET_SIGN_IN_AUTO];
+    
+    dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{//RUN to background thread
+        LoginModel *loginInfo = [[RequestHandler handler] sendSyncGetRequestAPIPath:path parameters:parameter
+                                                                         modelClass:[LoginModel class] showLoadingView:YES];
+        if (loginInfo) {
+            [JDFacade facade].loginUser = loginInfo;
+        }
+        
+        if (completion) {
+            completion();
+        }
+    });
+}
+
+
+
+- (void)alertLocationServiceDisabled {
+    NSString *message = MSG_LOCATION_DISABLE;
+    
+    CustomAlertView *alert = [[CustomAlertView alloc] initWithTitle:NSLocalizedString(@"알림", @"알림") delegate:nil OKButtonTitle:NSLocalizedString(@"설정", @"설정") cancelButtonTitle:NSLocalizedString(@"취소", @"취소") message:message, nil];
+    [alert showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
+        if (buttonIndex == 0) {//OK
+            NSURL *settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
+            [[UIApplication sharedApplication]openURL:settingsURL];
+        }
+    }];
+}
+
+
+- (void)alertCameraPermissionDisabled {
+    NSString *message = MSG_CAMERA_DISABLE;
+    
+    CustomAlertView *alert = [[CustomAlertView alloc] initWithTitle:NSLocalizedString(@"알림", @"알림") delegate:nil OKButtonTitle:NSLocalizedString(@"설정", @"설정") cancelButtonTitle:NSLocalizedString(@"취소", @"취소") message:message, nil];
+    [alert showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
+        if (buttonIndex == 0) {//OK
+            NSURL *settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
+            [[UIApplication sharedApplication]openURL:settingsURL];
+        }
+    }];
 }
 
 

+ 3 - 3
kneet2/Classes/JDObject.h

@@ -1,9 +1,9 @@
 //
 //  JDObject.h
-//  ___PROJECTNAME___
+//  kneet2
 //
-//  Created by ___FULLUSERNAME___ on ___DATE___.
-//  Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
+//  Created by Created by Jason Lee on 10/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
 //
 
 #import "JDFacade.h"

+ 3 - 3
kneet2/Classes/JDObject.m

@@ -1,9 +1,9 @@
 //
 //  MLObject.m
-//  ___PROJECTNAME___
+//  kneet2
 //
-//  Created by ___FULLUSERNAME___ on ___DATE___.
-//  Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
+//  Created by Created by Jason Lee on 10/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
 //
 
 #import "JDObject.h"

+ 178 - 0
kneet2/Classes/Model/DeviceModel.h

@@ -0,0 +1,178 @@
+// Generated by json_to_model
+
+@import Foundation;
+
+
+#import "JDJSONModel.h"
+#import "ItemModel.h"
+
+typedef NS_ENUM(NSInteger, CmdClsType) {
+    CmdClsTypeFirmwareVersion = 0,
+    CmdClsTypeSwitchBinary,
+    CmdClsTypeSwitchMultiLevel,
+    CmdClsTypeSwitchColor,
+    CmdClsTypeSensorBinary,
+    CmdClsTypeSensorMultiLevel,
+    CmdClsTypeThermostatMode,
+    CmdClsTypeThermostatFanMode,
+    CmdClsTypeThermostatSetPoint,   //hold
+    CmdClsTypeLock,
+    CmdClsTypeMeterCurrent,
+    CmdClsTypeMeterTotal,
+    CmdClsTypeAVControlPlayback,   //12
+    CmdClsTypeHomeMode,
+    CmdClsTypeCameraStream,
+    CmdClsTypeCameraPT,
+    CmdClsTypeSpeedControl,
+    CmdClsTypeMeterCurrentForDAWON, //17
+    CmdClsTypeMeterTotalForDAWON,
+};
+
+#define ksDeviceTypeControllerPrimary @"CONTROLLER_PRIMARY"
+#define ksDeviceTypeSlave @"SLAVE"
+
+#define ksDeviceProfileIdUnknown @"20001"
+
+@protocol CmdClsValueModel;
+@interface CmdClsValueModel : JDJSONModel
+
+@property (copy, nonatomic) NSString *cmdclsValue;
+@property (copy, nonatomic) NSString *cmdclsValueMsg;
+
+@end
+
+
+@protocol DeviceModel;
+@interface DeviceModel : ItemSubModel
+
+@property (copy, nonatomic) NSString *deviceId;
+@property (copy, nonatomic) NSString *deviceName;
+@property (copy, nonatomic) NSString *deviceProfileId;
+@property (copy, nonatomic) NSString *profileName;
+@property (copy, nonatomic) NSString *imageFileName;
+@property (copy, nonatomic) NSString *nodeId;
+@property (copy, nonatomic) NSString *nodeName;
+@property (copy, nonatomic) NSString *cmdclsTypeId;
+@property (copy, nonatomic) NSString *cmdclsTypeName;
+@property (copy, nonatomic) NSString *cmdclsTypeSystemName;
+@property (copy, nonatomic) NSString *createDatetime;
+@property (copy, nonatomic) NSString *updateDatetime;
+@property (copy, nonatomic) NSString *cmdclsCode;
+@property (copy, nonatomic) NSString *cmdclsCount;
+@property (copy, nonatomic) NSString *contentValue;
+@property (copy, nonatomic) NSString *networkYn;
+@property (copy, nonatomic) NSString *deviceType;
+
+
+//detail
+@property (copy, nonatomic) NSString *prdName;
+@property (copy, nonatomic) NSString *deviceModelId;
+@property (copy, nonatomic) NSString *deviceMfId;
+@property (copy, nonatomic) NSString *firmwareVersion;
+@property (copy, nonatomic) NSString *deviceProtocolType;   //연결타입
+@property (copy, nonatomic) NSString *removableYn;          //장치삭제 가능 여부
+@property (copy, nonatomic) NSString *activationCode;       //장치 인증 코드
+
+//predefine devices property
+@property (copy, nonatomic) NSString *controlMinValue;
+@property (copy, nonatomic) NSString *controlMaxValue;
+@property (copy, nonatomic) NSString *controlStep;
+@property (copy, nonatomic) NSString *unit;
+
+//camera
+@property (copy, nonatomic) NSString *ip;
+@property (copy, nonatomic) NSString *port;
+@property (copy, nonatomic) NSString *cameraId;
+@property (copy, nonatomic) NSString *cameraPassword;
+
+//Command
+@property (copy, nonatomic) NSString *commandId;
+@property (copy, nonatomic) NSString *status;
+
+
+@property (copy, nonatomic) NSArray<CmdClsValueModel> *cmdclsValueList;
+
+@property (assign, nonatomic) CmdClsType cmdclsType;
+@property (assign, nonatomic) BOOL enable;
+@property (assign, nonatomic, readonly) NSInteger cmdclsValueMsgLength;
+@property (strong, nonatomic) NSString<Ignore> *cmdclsValueMsgLongest;
+
+- (instancetype)initWithSubItem:(ItemSubModel *)subItem;
+
+@end
+
+@interface DeviceListModel : JDJSONModel
+@property (copy, nonatomic) NSArray<DeviceModel> *list;
+@end
+
+@interface NodeModel : DeviceModel
+//@property (copy, nonatomic) NSString *deviceId;
+//@property (copy, nonatomic) NSString *nodeId;
+//@property (copy, nonatomic) NSString *nodeName;
+//@property (copy, nonatomic) NSString *cmdclsTypeId;
+//@property (copy, nonatomic) NSString *cmdclsTypeName;
+//@property (copy, nonatomic) NSString *cmdclsTypeSystemName;
+//@property (copy, nonatomic) NSString *createDatetime;
+//@property (copy, nonatomic) NSString *cmdclsCode;
+//
+//@property (assign, nonatomic) CmdClsType cmdclsType;
+
+@end
+
+@interface DeviceDetailModel : DeviceModel
+
+@property (copy, nonatomic) NSArray<DeviceModel> *nodes;
+@property (copy, nonatomic) NSArray<DeviceModel> *relateDevice;
+
+@end
+
+
+@protocol ItemModel;
+@protocol PredefinedDeviceModel;
+@interface PredefinedDeviceModel : DeviceModel
+
+- (instancetype)initWithSubItem:(ItemSubModel *)subItem;
+@end
+
+@interface PredefinedDeviceListModel : JDJSONModel
+
+@property (strong, nonatomic) NSArray<PredefinedDeviceModel> *list;
+
+@end
+
+
+@protocol GroupsModel;
+@interface GroupsModel : JDJSONModel
+
+@property (copy, nonatomic) NSString *dvcgrpId;
+@property (copy, nonatomic) NSString *dvcgrpName;
+@property (copy, nonatomic) NSString *deviceCount;
+@property (copy, nonatomic) NSString *defaultYn;
+
+@property (copy, nonatomic) NSArray<DeviceModel> *devices;
+
+//UI용으로 사용
+@property (assign, nonatomic) BOOL expanded;
+@property (assign, nonatomic) BOOL unfold;
+
+@end
+
+
+@interface GroupsListModel : JDJSONModel
+
+@property (copy, nonatomic) NSArray<GroupsModel> *groups;
+@end
+
+@protocol DeviceIconModel;
+@interface DeviceIconModel : JDJSONModel
+
+@property (copy, nonatomic) NSString *imageSequence;
+@property (copy, nonatomic) NSString *imageFileName;
+
+@end
+
+@interface DeviceIconListModel : JDJSONModel
+
+@property (copy, nonatomic) NSArray<DeviceIconModel> *list;
+
+@end

+ 627 - 0
kneet2/Classes/Model/DeviceModel.m

@@ -0,0 +1,627 @@
+// Generated by json_to_model
+
+#import "JDObject.h"
+#import "DeviceModel.h"
+#import "CustomRadioGroup.h"
+#import "CustomCheckBox.h"
+
+@implementation DeviceModel
+
+//FIRMWARE_VERSION
+//SWITCH_BINARY
+//SWITCH_MULTILEVEL
+//SWITCH_COLOR
+//SENSOR_BINARY
+//SENSOR_MULTILEVEL
+//THERMOSTAT_MODE
+//THERMOSTAT_FAN_MODE
+//THERMOSTAT_SETPOINT
+//LOCK
+//METER
+//AV_CONTROL_PLAYBACK
+//HOME_MODE
+
+#define ksCmdClassTypeFirmwareVersion @"FIRMWARE_VERSION"
+#define ksCmdClassTypeSwitchBinary @"SWITCH_BINARY"
+#define ksCmdClassTypeSwitchMultiLevel @"SWITCH_MULTILEVEL"
+#define ksCmdClassTypeSwitchColor @"SWITCH_COLOR"
+#define ksCmdClassTypeSensorBinary @"SENSOR_BINARY"
+#define ksCmdClassTypeSensorMultiLevel @"SENSOR_MULTILEVEL"
+#define ksCmdClassTypeThermostatMode @"THERMOSTAT_MODE"
+#define ksCmdClassTypeThermostatFanMode @"THERMOSTAT_FAN_MODE"
+#define ksCmdClassTypeThermostatSetPoint @"THERMOSTAT_SETPOINT"
+#define ksCmdClassTypeLock @"LOCK"
+#define ksCmdClassTypeMeterCurrent @"METER_CURRENT"
+#define ksCmdClassTypeMeterTotal @"METER_TOTAL"
+#define ksCmdClassTypeAVControlPlayback @"AV_CONTROL_PLAYBACK"
+#define ksCmdClassTypeHomeMode @"HOME_MODE"
+#define ksCmdClassTypeCameraStream  @"CAMERA_STREAM"
+#define ksCmdClassTypeCameraPT      @"CAMERA_PT"
+#define ksCmdClassTypeSpeedControl      @"SPEED_CONTROL"
+
+
+
+
+//+ (JSONKeyMapper *)keyMapper {
+//
+//    NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
+//
+//    //self
+//    [dictionary setValue:@"cmdclsTypeSystemName" forKey:@"cmdcls_type_system_name"];
+//    [dictionary setValue:@"cmdclsTypeId" forKey:@"cmdcls_type_id"];
+//    [dictionary setValue:@"cmdclsCode" forKey:@"cmdcls_code"];
+//    [dictionary setValue:@"deviceProfileId" forKey:@"device_profile_id"];
+//    [dictionary setValue:@"createDatetime" forKey:@"create_datetime"];
+//    [dictionary setValue:@"cmdclsTypeName" forKey:@"cmdcls_type_name"];
+//    [dictionary setValue:@"deviceName" forKey:@"device_name"];
+//    [dictionary setValue:@"profileName" forKey:@"profile_name"];
+//    [dictionary setValue:@"imageFileName" forKey:@"image_file_name"];
+//    [dictionary setValue:@"contentValue" forKey:@"content_value"];
+//    [dictionary setValue:@"nodeName" forKey:@"node_name"];
+//    [dictionary setValue:@"cmdclsCount" forKey:@"cmdcls_count"];
+//    [dictionary setValue:@"nodeId" forKey:@"node_id"];
+//    [dictionary setValue:@"deviceId" forKey:@"device_id"];
+//
+//    return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
+//}
+
++ (CmdClsType)cmdclsTypeForCode:(NSString *)code {
+    CmdClsType type = -1;
+    if ([code isEqualToString:ksCmdClassTypeFirmwareVersion]) {
+        type = CmdClsTypeFirmwareVersion;
+
+    } else if ([code isEqualToString:ksCmdClassTypeSwitchBinary]) {
+        type = CmdClsTypeSwitchBinary;
+
+    } else if ([code isEqualToString:ksCmdClassTypeSwitchMultiLevel]) {
+        type = CmdClsTypeSwitchMultiLevel;
+
+    } else if ([code isEqualToString:ksCmdClassTypeSwitchColor]) {
+        type = CmdClsTypeSwitchColor;
+
+    } else if ([code isEqualToString:ksCmdClassTypeSensorBinary]) {
+        type = CmdClsTypeSensorBinary;
+
+    } else if ([code isEqualToString:ksCmdClassTypeSensorMultiLevel]) {
+        type = CmdClsTypeSensorMultiLevel;
+
+    } else if ([code isEqualToString:ksCmdClassTypeThermostatMode]) {
+        type = CmdClsTypeThermostatMode;
+
+    } else if ([code isEqualToString:ksCmdClassTypeThermostatFanMode]) {
+        type = CmdClsTypeThermostatFanMode;
+
+    } else if ([code isEqualToString:ksCmdClassTypeThermostatSetPoint]) {
+        type = CmdClsTypeThermostatSetPoint;
+
+    } else if ([code isEqualToString:ksCmdClassTypeLock]) {
+        type = CmdClsTypeLock;
+
+    } else if ([code isEqualToString:ksCmdClassTypeMeterCurrent]) {
+        type = CmdClsTypeMeterCurrent;
+
+    } else if ([code isEqualToString:ksCmdClassTypeMeterTotal]) {
+        type = CmdClsTypeMeterTotal;
+
+    } else if ([code isEqualToString:ksCmdClassTypeAVControlPlayback]) {
+        type = CmdClsTypeAVControlPlayback;
+
+    } else if ([code isEqualToString:ksCmdClassTypeHomeMode]) {
+        type = CmdClsTypeHomeMode;
+
+    } else if ([code isEqualToString:ksCmdClassTypeCameraStream]) {
+        type = CmdClsTypeCameraStream;
+
+    } else if ([code isEqualToString:ksCmdClassTypeCameraPT]) {
+        type = CmdClsTypeCameraPT;
+
+    } else if ([code isEqualToString:ksCmdClassTypeSpeedControl]) {
+        type = CmdClsTypeSpeedControl;
+
+    }
+    return type;
+}
+
+- (CmdClsType)cmdclsType {
+    return [DeviceModel cmdclsTypeForCode:_cmdclsCode];
+}
+
+
+- (NSInteger)cmdclsValueMsgLength {
+    NSInteger length = 0;
+    NSArray<CmdClsValueModel> *array = nil;
+
+    switch ([self cmdclsType]) {
+        case CmdClsTypeLock:
+            array = [self cmdclsValueListOfLock];
+            break;
+        default:
+            break;
+    }
+
+    for (CmdClsValueModel *tmpCmdclsValue in array) {
+        if (tmpCmdclsValue.cmdclsValueMsg.length > length) {
+            length = tmpCmdclsValue.cmdclsValueMsg.length;
+        }
+    }
+
+    return length;
+}
+
+
+- (NSString *)cmdclsValueMsgLongest {
+    NSString *hstring = nil;
+    NSArray<CmdClsValueModel> *array = nil;
+
+    switch ([self cmdclsType]) {
+        case CmdClsTypeSwitchBinary:
+            array = [self cmdclsValueListOfSwitchBinary];
+            break;
+        case CmdClsTypeLock:
+            array = [self cmdclsValueListOfLock];
+            break;
+        default:
+            break;
+    }
+
+    NSUInteger highest = 0;
+    for (CmdClsValueModel *tmpCmdclsValue in array) {
+        if (tmpCmdclsValue.cmdclsValueMsg.length > highest) {
+            highest = tmpCmdclsValue.cmdclsValueMsg.length;
+            hstring = tmpCmdclsValue.cmdclsValueMsg;
+        }
+    }
+
+    return hstring;
+}
+
+- (NSString *)cmdclsValueMsg {
+
+    switch ([self cmdclsType]) {
+        case CmdClsTypeSensorBinary:
+            _cmdclsValueMsg = [self cmdclsValueMsgOfSensorBinary];
+            break;
+        case CmdClsTypeThermostatMode:
+            _cmdclsValueMsg = [self cmdclsValueMsgOfThermostatMode];
+            break;
+        case CmdClsTypeLock:
+            _cmdclsValueMsg = [self cmdclsValueMsgOfLock];
+            break;
+        case CmdClsTypeSwitchBinary:
+            _cmdclsValueMsg = [self cmdclsValueMsgOfSwitchBinary];
+            break;
+        case CmdClsTypeSpeedControl:
+            _cmdclsValueMsg = [self cmdclsValueMsgOfSpeedControl];
+            break;
+        case CmdClsTypeAVControlPlayback:
+            _cmdclsValueMsg = [self cmdclsValueMsgOfAVPlayback];
+            break;
+        default:
+            break;
+    }
+    return _cmdclsValueMsg;
+}
+
+- (NSArray<CmdClsValueModel> *)cmdclsValueList {
+    switch ([self cmdclsType]) {
+        case CmdClsTypeThermostatMode:
+            _cmdclsValueList = [self cmdclsValueListOfThermostatMode];
+            break;
+        case CmdClsTypeLock:
+            _cmdclsValueList = [self cmdclsValueListOfLock];
+            break;
+        case CmdClsTypeSpeedControl:
+            _cmdclsValueList = [self cmdclsValueListOfSpeedControl];
+            break;
+        default:
+            break;
+    }
+    return _cmdclsValueList;
+}
+
+- (NSArray<CmdClsValueModel> *)cmdclsValueListOfThermostatMode {
+
+    NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
+    NSInteger typeId = [_cmdclsTypeId integerValue];
+    switch (typeId) {
+        case 13001: {
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"COOL",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"냉방", @"냉방")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HEAT",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"난방", @"난방")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AUTO",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"자동", @"자동")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"FAN_ONLY",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"환기", @"환기")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"DRY_AIR",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"제습", @"제습")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AWAY",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"외출", @"외출")} error:nil]];
+        }
+            break;
+        case 13002: {
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"COOL",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"냉방", @"냉방")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HEAT",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"난방", @"난방")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AUTO",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"자동", @"자동")} error:nil]];
+        }
+            break;
+        case 13003: {
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HEAT",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"난방", @"난방")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AWAY",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"외출", @"외출")} error:nil]];
+        }
+            break;
+        case 13004: {
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"COOL",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"냉방", @"냉방")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"FAN_ONLY",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"환기", @"환기")} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"DRY_AIR",
+                                                                            @"cmdcls_value_msg": NSLocalizedString(@"제습", @"제습")} error:nil]];
+        }
+            break;
+    }
+    return array;
+}
+
+- (NSArray<CmdClsValueModel> *)cmdclsValueListOfSwitchBinary {
+    NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
+    NSInteger typeId = [_cmdclsTypeId integerValue];
+    switch (typeId) {
+        case 17001: {
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"ON",
+                                                                            @"cmdcls_value_msg": @"켜짐"} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
+                                                                            @"cmdcls_value_msg": @"꺼짐"} error:nil]];
+            break;
+        }
+    }
+    return array;
+}
+
+- (NSArray<CmdClsValueModel> *)cmdclsValueListOfLock {
+
+    NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
+    NSInteger typeId = [_cmdclsTypeId integerValue];
+    switch (typeId) {
+        case 14001: {
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"LOCKED",
+                                                                            @"cmdcls_value_msg": @"잠김"} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"UNCLOCKED",
+                                                                            @"cmdcls_value_msg": @"열림"} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"JAMMED",
+                                                                            @"cmdcls_value_msg": @"걸림"} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"FORCED_OPEN",
+                                                                            @"cmdcls_value_msg": @"수동"} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"UNSPECIFIED",
+                                                                            @"cmdcls_value_msg": @"오류"} error:nil]];
+        }
+            break;
+        case 14002:
+        case 14003:
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"LOCKED",
+                                                                            @"cmdcls_value_msg": @"잠김"} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"UNCLOCKED",
+                                                                            @"cmdcls_value_msg": @"열림"} error:nil]];
+            break;
+    }
+    return array;
+}
+
+
+- (NSArray<CmdClsValueModel> *)cmdclsValueListOfSpeedControl {
+
+    NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
+    NSInteger typeId = [_cmdclsTypeId integerValue];
+    switch (typeId) {
+        case 20001: {
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
+                                                                            @"cmdcls_value_msg": @"꺼짐"} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"LOW",
+                                                                            @"cmdcls_value_msg": @"약"} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"MEDIUM",
+                                                                            @"cmdcls_value_msg": @"중"} error:nil]];
+            [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HIGH",
+                                                                            @"cmdcls_value_msg": @"강"} error:nil]];
+        }
+            break;
+    }
+    return array;
+}
+
+- (NSString *)cmdclsValueMsgOfSensorBinary {
+    NSInteger typeId = [_cmdclsTypeId integerValue];
+    NSString *msg = ksEmptyString;
+    switch (typeId) {
+        case 11001:
+        case 11002:
+        case 11003:
+        case 11004:
+        case 11005:
+        case 11006:
+        case 11007:
+        case 11008:
+        case 11009:
+        case 11010:
+        case 11012:
+        case 11013:
+        case 11014:
+        case 11016:
+            if ([self.contentValue isEqualToString:@"TRUE"]) {
+                msg = NSLocalizedString(@"감지됨", @"감지됨");
+            } else if ([self.contentValue isEqualToString:@"FALSE"]) {
+                msg = NSLocalizedString(@"정상", @"정상");
+            } else {
+                msg = @"-";
+            }
+            break;
+        case 11011:
+            if ([self.contentValue isEqualToString:@"TRUE"]) {
+                msg = NSLocalizedString(@"열림", @"열림");
+            } else if ([self.contentValue isEqualToString:@"FALSE"]) {
+                msg = NSLocalizedString(@"닫힘", @"닫힘");
+            } else {
+                msg = @"-";
+            }
+        case 11015:
+            if ([self.contentValue isEqualToString:@"TRUE"]) {
+                msg = NSLocalizedString(@"들어옴", @"들어옴");
+            } else if ([self.contentValue isEqualToString:@"FALSE"]) {
+                msg = NSLocalizedString(@"나감", @"나감");
+            } else {
+                msg = @"-";
+            }
+            break;
+    }
+    return msg;
+}
+
+- (NSString *)cmdclsValueMsgOfThermostatMode {
+    NSInteger typeId = [_cmdclsTypeId integerValue];
+    NSString *msg = ksEmptyString;
+    switch (typeId) {
+        case 13001:
+        case 13002:
+        case 13003:
+        case 13004:
+            if ([self.contentValue isEqualToString:@"OFF"]) {
+                msg = NSLocalizedString(@"꺼짐", @"꺼짐");
+            } else if ([self.contentValue isEqualToString:@"COOL"]) {
+                msg = NSLocalizedString(@"냉방", @"냉방");
+            } else if ([self.contentValue isEqualToString:@"HEAT"]) {
+                msg = NSLocalizedString(@"난방", @"난방");
+            } else if ([self.contentValue isEqualToString:@"AUTO"]) {
+                msg = NSLocalizedString(@"자동", @"자동");
+            } else if ([self.contentValue isEqualToString:@"FAN_ONLY"]) {
+                msg = NSLocalizedString(@"환기", @"환기");
+            } else if ([self.contentValue isEqualToString:@"DRY_AIR"]) {
+                msg = NSLocalizedString(@"제습", @"제습");
+            } else if ([self.contentValue isEqualToString:@"AWAY"]) {
+                msg = NSLocalizedString(@"외출", @"외출");
+            } else {
+                msg = @"-";
+            }
+            break;
+    }
+    return msg;
+}
+
+- (NSString *)cmdclsValueMsgOfLock {
+    NSInteger typeId = [_cmdclsTypeId integerValue];
+    NSString *msg = ksEmptyString;
+    switch (typeId) {
+        case 14001:
+            if ([self.contentValue isEqualToString:@"LOCKED"]) {
+                msg = NSLocalizedString(@"잠김", @"잠김");
+            } else if ([self.contentValue isEqualToString:@"UNLOCKED"]) {
+                msg = NSLocalizedString(@"열림", @"열림");
+            } else if ([self.contentValue isEqualToString:@"JAMMED"]) {
+                msg = NSLocalizedString(@"걸림", @"걸림");
+            } else if ([self.contentValue isEqualToString:@"FORCED_OPEN"]) {
+                msg = NSLocalizedString(@"수동", @"수동");
+            } else if ([self.contentValue isEqualToString:@"UNSPECIFIED"]) {
+                msg = NSLocalizedString(@"오류", @"오류");
+            } else {
+                msg = @"-";
+            }
+            break;
+        case 14002:
+        case 14003:
+            if ([self.contentValue isEqualToString:@"LOCKED"]) {
+                msg = @"잠김";
+            } else if ([self.contentValue isEqualToString:@"UNLOCKED"]) {
+                msg = @"열림";
+            } else {
+                msg = @"-";
+            }
+            break;
+    }
+    return msg;
+}
+
+- (NSString *)cmdclsValueMsgOfSwitchBinary {
+    NSInteger typeId = [_cmdclsTypeId integerValue];
+    NSString *msg = ksEmptyString;
+    switch (typeId) {
+        case 17001:
+            if ([self.contentValue isEqualToString:@"ON"]) {
+                msg = NSLocalizedString(@"켜짐", @"켜짐");
+            } else if ([self.contentValue isEqualToString:@"OFF"]) {
+                msg = NSLocalizedString(@"꺼짐", @"꺼짐");
+            } else {
+                msg = @"-";
+            }
+            break;
+    }
+    return msg;
+}
+
+- (NSString *)cmdclsValueMsgOfSpeedControl {
+    NSInteger typeId = [_cmdclsTypeId integerValue];
+    NSString *msg = ksEmptyString;
+    switch (typeId) {
+        case 20001:
+            if ([self.contentValue isEqualToString:@"OFF"]) {
+                msg = NSLocalizedString(@"꺼짐", @"꺼짐");
+            } else if ([self.contentValue isEqualToString:@"LOW"]) {
+                msg = NSLocalizedString(@"약", @"약");
+            } else if ([self.contentValue isEqualToString:@"MEDIUM"]) {
+                msg = NSLocalizedString(@"중", @"중");
+            } else if ([self.contentValue isEqualToString:@"HIGH"]) {
+                msg = NSLocalizedString(@"강", @"강");
+            } else {
+                msg = @"-";
+            }
+            break;
+    }
+    return msg;
+}
+
+- (NSString *)cmdclsValueMsgOfAVPlayback {
+    NSInteger typeId = [_cmdclsTypeId integerValue];
+    NSString *msg = ksEmptyString;
+    switch (typeId) {
+        case 21001:
+            if ([self.contentValue isEqualToString:@"PLAYING"]) {
+                msg = NSLocalizedString(@"재생 중", @"재생 중");
+            } else if ([self.contentValue isEqualToString:@"PAUSED"]) {
+                msg = NSLocalizedString(@"정지 됨", @"정지 됨");
+            } else {
+                msg = @"-";
+            }
+            break;
+    }
+    return msg;
+}
+
+
+- (instancetype)initWithSubItem:(ItemSubModel *)subItem {//mobile devices.
+    if (self = [super init]) {
+        self.deviceId = subItem.sourceId;
+        self.deviceName = subItem.sourceName;
+        self.nodeId = subItem.sourceSubId;
+        self.nodeName = subItem.sourceSubName;
+        self.conditionTypeCode = subItem.conditionTypeCode;
+        self.dataTypeCode = subItem.dataTypeCode;
+        self.cmdclsValue = subItem.cmdclsValue;
+        self.nickname = subItem.nickname;
+        self.deleteYn = subItem.deleteYn;
+
+//        objc_setAssociatedObject(self, @"CHECK_STATUS", @YES, OBJC_ASSOCIATION_COPY_NONATOMIC); //for checkbox
+        [[JDFacade facade] setRadioButtonStatus:@YES object:self];  //for radio box
+    }
+    return self;
+}
+
+- (NSString *)unit {
+    if ([_unit isEqualToString:@"\\"]) {
+        _unit = @"₩";
+    }
+    return _unit;
+}
+
+@end
+
+@implementation DeviceListModel
+
+@end
+
+@implementation NodeModel
+
+//- (CmdClsType)cmdclsType {
+//    return [DeviceModel cmdclsTypeForCode:_cmdclsCode];
+//}
+@end
+
+
+@implementation DeviceDetailModel
+
+@end
+
+@implementation PredefinedDeviceModel
+
+//+ (JSONKeyMapper *)keyMapper {
+//
+//    NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
+//
+//    //self
+//    [dictionary setValue:@"cmdclsTypeSystemName" forKey:@"cmdcls_type_system_name"];
+//    [dictionary setValue:@"cmdclsTypeId" forKey:@"cmdcls_type_id"];
+//    [dictionary setValue:@"cmdclsCode" forKey:@"cmdcls_code"];
+//    [dictionary setValue:@"deviceProfileId" forKey:@"device_profile_id"];
+//    [dictionary setValue:@"createDatetime" forKey:@"create_datetime"];
+//    [dictionary setValue:@"cmdclsTypeName" forKey:@"cmdcls_type_name"];
+//    [dictionary setValue:@"deviceName" forKey:@"device_name"];
+//    [dictionary setValue:@"profileName" forKey:@"profile_name"];
+//    [dictionary setValue:@"imageFileName" forKey:@"image_file_name"];
+//    [dictionary setValue:@"contentValue" forKey:@"content_value"];
+//    [dictionary setValue:@"nodeName" forKey:@"node_name"];
+//    [dictionary setValue:@"cmdclsCount" forKey:@"cmdcls_count"];
+//    [dictionary setValue:@"nodeId" forKey:@"node_id"];
+//    [dictionary setValue:@"deviceId" forKey:@"device_id"];
+//    [dictionary setValue:@"cmdclsValue" forKey:@"cmdcls_value"];
+//    [dictionary setValue:@"conditionTypeCode" forKey:@"condition_type_code"];
+//    [dictionary setValue:@"dataTypeCode" forKey:@"data_type_code"];
+//
+//    return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
+//}
+
+- (instancetype)initWithSubItem:(ItemSubModel *)subItem {
+    if (self = [super init]) {
+        self.deviceId = subItem.sourceId;
+        self.deviceName = subItem.sourceName;
+        self.nodeId = subItem.sourceSubId;
+        self.nodeName = subItem.sourceSubName;
+        self.conditionTypeCode = subItem.conditionTypeCode;
+        self.dataTypeCode = subItem.dataTypeCode;
+        self.cmdclsValue = subItem.cmdclsValue;
+        self.predCmdclsValue = subItem.predCmdclsValue;
+        self.deleteYn = subItem.deleteYn;
+
+        [[JDFacade facade] setCheckBoxStatus:@YES object:self];  //for check box
+        [[JDFacade facade] setRadioButtonStatus:@YES object:self];  //for radio box
+    }
+    return self;
+}
+
+@end
+
+@implementation PredefinedDeviceListModel
+
+@end
+
+
+@implementation GroupsModel
+
+@end
+
+
+@implementation GroupsListModel
+
+@end
+
+@implementation CmdClsValueModel
+
+
+@end
+
+@implementation DeviceIconModel
+
+@end
+
+
+@implementation DeviceIconListModel
+
+@end

+ 104 - 0
kneet2/Classes/Model/ItemModel.h

@@ -0,0 +1,104 @@
+//
+//  ItemModel.h
+//  kneet
+//
+//  Created by Jason Lee on 4/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
+//
+#import "JDJSONModel.h"
+
+#define ksItemSubTypeCodeDevice     @"01"
+#define ksItemSubTypeCodeMode       @"02"
+#define ksItemSubTypeCodeAppPush    @"03"
+#define ksItemSubTypeCodeTimer      @"05"
+#define ksItemSubTypeCodeGeoFencing @"06"
+
+#define ksItemTypeCodeTrigger       @"01"
+#define ksItemTypeCodeAction        @"02"
+#define ksItemTypeCodeCondition     @"03"
+
+#define ksConditionSubTypeCodeDueDate       @"21"
+#define ksConditionSubTypeCodeDaysOfWeek    @"22"
+#define ksConditionSubTypeCodeDueTime       @"23"
+#define ksConditionSubTypeCodeHomeMode      @"02"
+#define ksConditionSubTypeCodeExternHeat    @"31"
+
+@protocol ItemModel;
+@protocol ItemSubModel;
+@protocol ModeModel;
+@protocol DeviceModel;
+
+@interface ItemSubModel : JDJSONModel {//subCondition
+@protected
+    NSString *_cmdclsValueMsg;
+}
+
+//@property (copy, nonatomic) NSString *itemSubTypeCode;
+@property (copy, nonatomic) NSString *subSequence;
+@property (copy, nonatomic) NSString *sourceId;
+@property (copy, nonatomic) NSString *sourceSubId;
+@property (copy, nonatomic) NSString *conditionTypeCode;
+@property (copy, nonatomic) NSString *cmdclsValue;
+@property (copy, nonatomic) NSString *cmdclsValueMsg;
+@property (copy, nonatomic) NSString *dataTypeCode;
+@property (copy, nonatomic) NSString *sourceName;
+@property (copy, nonatomic) NSString *sourceSubName;
+@property (copy, nonatomic) NSString *actionTypeCode;
+@property (copy, nonatomic) NSString *deleteYn;
+
+@property (copy, nonatomic) NSString *hour;
+@property (copy, nonatomic) NSString *minute;
+@property (copy, nonatomic) NSString *nickname;
+@property (copy, nonatomic) NSString *predCmdclsValue;
+
+@property (strong, nonatomic) NSMutableArray<ItemModel> *conditions;
+
+//flash
+@property (copy, nonatomic) NSString<Ignore> *dueDate;
+@property (copy, nonatomic) NSString<Ignore> *daysOfWeek;
+@property (copy, nonatomic) NSString<Ignore> *dueTime;
+@property (copy, nonatomic) NSString<Ignore> *homeModes;
+@property (copy, nonatomic) NSString<Ignore> *externHeat;
+
+
+@end
+
+@protocol PredefinedDeviceModel;
+@interface ItemModel : JDJSONModel  //condition
+
+@property (copy, nonatomic) NSString *predItemSequence;
+@property (copy, nonatomic) NSString *itemTypeCode;
+@property (copy, nonatomic) NSString *itemSubTypeCode;
+@property (copy, nonatomic) NSString *itemName;
+
+@property (copy, nonatomic) NSString *predRuleId;
+
+@property (copy, nonatomic) NSString *predSceneId;
+@property (copy, nonatomic) NSString *predActionSequence;
+@property (copy, nonatomic) NSString *cnt;
+@property (copy, nonatomic) NSString *totalCnt;
+@property (copy, nonatomic) NSString *imageFileName;
+
+
+
+@property (strong, nonatomic) NSMutableArray<ItemSubModel> *subItems;
+
+//for register
+@property (strong, nonatomic) NSMutableArray<PredefinedDeviceModel> *predDevices;
+@property (strong, nonatomic) NSMutableArray<ModeModel> *modes;
+@property (strong, nonatomic) NSMutableArray<ItemSubModel> *pushes;
+@property (strong, nonatomic) NSMutableArray<ItemSubModel> *timers;
+@property (strong, nonatomic) NSMutableArray<DeviceModel> *mobileDevices;
+
+//fuction
+@property (assign, nonatomic, readonly) NSInteger sumPredDeviceCount;
+@property (assign, nonatomic, readonly) NSInteger sumModesCount;
+@property (assign, nonatomic, readonly) NSInteger sumPushesCount;
+
++ (NSString *)itemSubTypeString:(NSString *)itemSubTypeCode;
+
+@end
+
+@interface ItemListModel : JDJSONModel
+@property (copy, nonatomic) NSMutableArray<ItemModel> *list;
+@end

+ 139 - 0
kneet2/Classes/Model/ItemModel.m

@@ -0,0 +1,139 @@
+//
+//  ItemModel.m
+//  kneet
+//
+//  Created by Jason Lee on 4/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
+//
+
+#import "ItemModel.h"
+#import "JDObject.h"
+
+@implementation ItemSubModel
+
++ (JSONKeyMapper *)keyMapper {
+    return [JSONKeyMapper mapperFromUnderscoreCaseToCamelCase];
+}
+
+
+- (NSString *)localStringOfDay:(NSString *)day {
+    NSString *lstr = nil;
+    if ([day isEqualToString:ksDayOfWeekMON]) {
+        lstr = NSLocalizedString(@"월", @"월");
+    } else if ([day isEqualToString:ksDayOfWeekTUE]) {
+        lstr = NSLocalizedString(@"화", @"화");
+    } else if ([day isEqualToString:ksDayOfWeekWED]) {
+        lstr = NSLocalizedString(@"수", @"수");
+    } else if ([day isEqualToString:ksDayOfWeekTHU]) {
+        lstr = NSLocalizedString(@"목", @"목");
+    } else if ([day isEqualToString:ksDayOfWeekFRI]) {
+        lstr = NSLocalizedString(@"금", @"금");
+    } else if ([day isEqualToString:ksDayOfWeekSAT]) {
+        lstr = NSLocalizedString(@"토", @"토");
+    } else if ([day isEqualToString:ksDayOfWeekSUN]) {
+        lstr = NSLocalizedString(@"일", @"일");
+    }
+    return lstr;
+}
+
+- (NSString *)daysOfWeek {
+
+    NSMutableString *days = [[NSMutableString alloc] init];
+    if (_cmdclsValue && ![_cmdclsValue isEmptyString]) {
+        NSArray *darray = [_cmdclsValue componentsSeparatedByString:@","];
+
+        for (NSString *day in darray) {
+
+            NSString *prefix = [days isEmptyString] ? ksEmptyString : @", ";
+            [days appendFormat:@"%@%@", prefix, [self localStringOfDay:day]];
+        }
+    }
+    return days;
+}
+
+
+- (NSString *)cmdclsValueMsg {
+//    if (!_cmdclsValueMsg || [_cmdclsValueMsg isEmptyString]) {
+        if (_dueDate && ![_dueDate isEmptyString]) {
+            _cmdclsValueMsg = _dueDate;
+        } else if (_daysOfWeek && ![_daysOfWeek isEmptyString]) {
+            _cmdclsValueMsg = _daysOfWeek;
+        } else if (_dueTime && ![_dueTime isEmptyString]) {
+            _cmdclsValueMsg = _dueTime;
+        } else if (_homeModes && ![_homeModes isEmptyString]) {
+            _cmdclsValueMsg = _homeModes;
+        } else if (_externHeat && ![_externHeat isEmptyString]) {
+            _cmdclsValueMsg = _externHeat;
+        }
+//    }
+    return _cmdclsValueMsg;
+
+//    if (_dueDate && ![_dueDate isEmptyString]) {
+//        self.cmdclsValueMsg = _dueDate;
+//
+//    } else if (_daysOfWeek && ![_daysOfWeek isEmptyString]) {
+//        self.cmdclsValueMsg = _daysOfWeek;
+//
+//    } else if (_dueTime && ![_dueTime isEmptyString]) {
+//        self.cmdclsValueMsg = _dueTime;
+//
+//    } else if (_homeModes && ![_homeModes isEmptyString]) {
+//        self.cmdclsValueMsg = _homeModes;
+//
+//    } else if (_externHeat && ![_externHeat isEmptyString]) {
+//        self.cmdclsValueMsg = _externHeat;
+//
+//    }
+}
+
+@end
+
+@implementation ItemModel
+
++ (JSONKeyMapper *)keyMapper {
+
+    return [[JSONKeyMapper alloc] initWithDictionary:@{@"pred_item_sequence": @"predItemSequence",
+                                                       @"item_type_code": @"itemTypeCode",
+                                                       @"item_sub_type_code": @"itemSubTypeCode",
+                                                       @"item_name": @"itemName",
+                                                       @"item_sub": @"subItems",
+                                                       @"pred_action_sequence": @"predActionSequence",
+                                                       @"pred_scene_id": @"predSceneId",
+                                                       @"pred_rule_id": @"predRuleId",
+                                                       @"cnt" : @"cnt",
+                                                       @"total_cnt" : @"totalCnt",
+                                                       @"image_file_name": @"imageFileName"}];
+}
+
++ (NSString *)itemSubTypeString:(NSString *)itemSubTypeCode {
+    NSString *string = ksEmptyString;
+
+    if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeDevice]) {
+        string = @"Choose your things & action";
+    } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeMode]) {
+        string = @"Choose home mode";
+    } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeAppPush]) {
+        string = @"Choose your things & action";
+    }  else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeTimer]) {
+        string = @"Choose your things & action";
+    }
+    return string;
+}
+
+- (NSInteger)sumPredDeviceCount {
+    return _predDevices.count + [_cnt integerValue];
+}
+
+- (NSInteger)sumModesCount {
+    return _modes.count + [_cnt integerValue];
+}
+
+- (NSInteger)sumPushesCount {
+    return _pushes.count + [_cnt integerValue];
+}
+
+@end
+
+@implementation ItemListModel
+
+@end

+ 48 - 2
kneet2/Classes/Model/JDJSONModel.h

@@ -12,8 +12,54 @@
 @protocol CommonCode;
 
 @interface JDJSONModel : JSONModel
+@property (copy, nonatomic) NSString *resultCode;
+@property (copy, nonatomic) NSString *msg;
 
-@property (copy, nonatomic) NSString *result;
-@property (copy, nonatomic) NSString *resultmsg;
+@end
+
+
+@protocol MobileDeviceModel;
+@interface MobileDeviceModel : JDJSONModel
+
+@property (copy, nonatomic) NSString *deviceName;
+@property (copy, nonatomic) NSString *deviceSn;
+@property (copy, nonatomic) NSString *createDatetime;
+@property (copy, nonatomic) NSString *loginStatus;  //A:활성화 C:비활성
+
+@end
+
+
+@interface JDErrorModel : JDJSONModel
+
+@property (copy, nonatomic) NSString *errorCode;
+@property (copy, nonatomic) NSString *errorMessage;
+@property (copy, nonatomic) NSString *errorDescription;
+@property (copy, nonatomic) NSString *errorCount;
+
+//로그인 요청 시 사용,
+@property (copy, nonatomic) NSString *nickname;
+@property (copy, nonatomic) NSArray<MobileDeviceModel> *deviceList;
+
+@end
+
+
+@interface CommonCode : JDJSONModel
+
+@property (copy, nonatomic) NSString *commonCode;
+@property (copy, nonatomic) NSString *commonCodeName;
+
+@end
+
+@interface CommonCodeList : JDJSONModel
+
+@property (copy, nonatomic) NSArray<CommonCode> *list;
+
+@end
+
+
+@interface QRAuthModel : JDJSONModel
+
+@property (copy, nonatomic) NSString *deviceId;
+@property (copy, nonatomic) NSString *passwordYn;
 
 @end

+ 49 - 0
kneet2/Classes/Model/JDJSONModel.m

@@ -21,3 +21,52 @@
 
 @end
 
+@implementation MobileDeviceModel
+
+- (NSString *)createDatetime {
+    NSDateFormatter *df = [CommonUtil dateFormatter];
+    [df setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
+    [df setDateFormat:@"yyyy-MM-dd"];
+    NSDate *utcDate = [df dateFromString:_createDatetime];
+    
+    NSDateFormatter* df_local = [[CommonUtil dateFormatter] copy];
+    [df_local setTimeZone:[NSTimeZone systemTimeZone]];
+    [df_local setDateFormat:@"yyyy년 MM월 dd일"];
+    return [df_local stringFromDate:utcDate];;
+}
+
+@end
+
+@implementation JDErrorModel
+
++ (JSONKeyMapper *)keyMapper {
+    return [[JSONKeyMapper alloc] initWithDictionary:@{@"err_code": @"errorCode",
+                                                       @"err_msg" : @"errorMessage",
+                                                       @"description": @"errorDescription",
+                                                       @"nickname": @"nickname",
+                                                       @"device_list": @"deviceList",
+                                                       @"error_count": @"errorCount"}];
+}
+
+@end
+
+
+@implementation CommonCode
+
+@end
+
+@implementation CommonCodeList
+
+@end
+
+
+@implementation QRAuthModel
+
++ (JSONKeyMapper *)keyMapper {
+    return [[JSONKeyMapper alloc] initWithDictionary:@{@"result_code": @"resultCode",
+                                                       @"msg" : @"msg",
+                                                       @"device_id": @"deviceId",
+                                                       @"init_password_yn": @"passwordYn"}];
+}
+
+@end

+ 145 - 0
kneet2/Classes/Model/LoginModel.h

@@ -0,0 +1,145 @@
+//
+//  JDJSONModel.h
+//  kneet
+//
+//  Created by Jason Lee on 2/9/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
+
+#import "JDJSONModel.h"
+
+@protocol HomeGroupModel;
+@interface HomeGroupModel : JDJSONModel
+@property (nonatomic, copy) NSString *homegrpId;
+@property (nonatomic, copy) NSString *homegrpName;
+@property (nonatomic, copy) NSString *locationCoordinate;
+@property (nonatomic, copy) NSString *locationRadius;
+@property (nonatomic, copy) NSString *deviceId;
+@property (nonatomic, copy) NSString *deviceKey;
+@property (nonatomic, copy) NSString *deviceAuthorization;
+@property (nonatomic, copy) NSString *locationAddr;
+@property (nonatomic, copy) NSString *imageFileName;
+@property (nonatomic, copy) NSString *gradeCode;
+
+//util
+@property (nonatomic, assign) NSInteger level;
+@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
+
+@end
+
+@interface HomeGroupListModel : JDJSONModel
+
+@property (nonatomic, strong) NSMutableArray<HomeGroupModel> *homegrpList;
+
+@end
+
+@protocol InvitationModel;
+@interface InvitationModel : JDJSONModel
+
+@property (nonatomic, copy) NSString *homegrpId;
+@property (nonatomic, copy) NSString *homegrpName;
+@property (nonatomic, copy) NSString *nickname;
+@property (nonatomic, copy) NSString *authorizationQuestion;
+@property (nonatomic, copy) NSString *targetEmail;
+@property (nonatomic, copy) NSString *imageFileName;
+
+//temp
+@property (nonatomic, copy) NSString *sdate;
+
+@end
+
+@protocol HomeMemberModel;
+@interface HomeMemberModel : JDJSONModel
+
+@property (nonatomic, copy) NSString *invitation;
+@property (nonatomic, copy) NSString *nickname;
+@property (nonatomic, copy) NSString *gradeCode;
+@property (nonatomic, copy) NSString *gradeCodeName;
+@property (nonatomic, copy) NSString *targetEmail;
+@property (nonatomic, copy) NSString *imageFileName;
+
+@end
+
+@interface HomeMemberListModel : JDJSONModel
+
+@property (nonatomic, copy) NSArray<HomeMemberModel> *homegrpMemberList;
+
+@end
+
+@protocol MemberIconModel;
+@interface MemberIconModel : JDJSONModel
+
+@property (copy, nonatomic) NSString *imageFileName;
+@property (copy, nonatomic) NSString *imageFilePath;
+
+@end
+
+@interface MemberIconListModel : JDJSONModel
+
+@property (copy, nonatomic) NSArray<MemberIconModel> *iconList;
+
+@end
+
+@interface MobileDeviceListModel : JDJSONModel
+
+@property (strong, nonatomic) NSMutableArray<MobileDeviceModel> *deviceList;
+
+@end
+
+@interface LoginModel : JDJSONModel
+
+//회원 번호
+//이메일 ID
+//서비스 ID
+//국가 코드 (ex: KR)
+//타임존 ID
+//타임존 시간 (ex: +09:00)
+//언어 코드 (ex: en)
+//인증 토큰
+//회원 여부
+//회원 이미지
+//회원 닉네임
+@property (nonatomic, copy) NSString *memberId;
+@property (nonatomic, copy) NSString *emailId;
+@property (nonatomic, copy) NSString *serviceId;
+@property (nonatomic, copy) NSString *countryCode;
+@property (nonatomic, copy) NSString *timezoneId;
+@property (nonatomic, copy) NSString *timezone;
+@property (nonatomic, copy) NSString *lang;
+@property (nonatomic, copy) NSString *authToken;
+@property (nonatomic, copy) NSString *member;
+@property (nonatomic, copy) NSString *imageFileName;
+@property (nonatomic, copy) NSString *nickname;
+@property (nonatomic, copy) NSString *key;
+@property (nonatomic, copy) NSString *tempPasswordYn;
+
+
+@property (nonatomic, strong) NSMutableArray<HomeGroupModel> *homegrpList;
+@property (nonatomic, strong) NSMutableArray<InvitationModel> *invitationList;
+
+
+//local store
+@property (strong, nonatomic) NSMutableDictionary *localStorage;
+
+@property (nonatomic, strong) NSString *homegrpId;  //로컬에 저장
+@property (strong, nonatomic) NSString *newEmailId; //로컬에 저장 - 임시 이메일
+@property (strong, nonatomic) NSString *modeChange; //로컬에 저장 - 모드 최초 실행 여부
+
+
+//디바이스
+@property (strong, nonatomic) NSString *mobileDeviceId; //FIXME : delete
+@property (strong, nonatomic) NSString *mobileDeviceAuthorization;
+@property (strong, nonatomic) NSString *hasRegisterMobileDevice;
+
+
+- (void)addHomegrp:(HomeGroupModel *)homegrp;
+
+//지오펜스 정보
+//@property (strong, nonatomic) NSMutableArray *mobileDeviceGeoFenceSensors;    //Dictionary - 타이틀, 주소, 위도, 경도, 반경, 실행 여부, 체크인?
+//- (void)saveMobileDeviceGeoFenceSensors;
+
+@end
+

+ 222 - 0
kneet2/Classes/Model/LoginModel.m

@@ -0,0 +1,222 @@
+//
+//  JDJSONModel.h
+//  kneet
+//
+//  Created by Jason Lee on 2/9/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
+//
+#import "JDObject.h"
+#import "LoginModel.h"
+#import "CypherUtil.h"
+
+@implementation HomeGroupModel
+
+- (CLLocationCoordinate2D)coordinate {
+    CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(0, 0);
+    if (_locationCoordinate && ![_locationCoordinate isEmptyString]) {
+
+        NSArray *geos = [_locationCoordinate componentsSeparatedByString:@","];
+        coordinate.latitude = [geos[0] doubleValue];
+        coordinate.longitude = [geos[1] doubleValue];
+    }
+    return coordinate;
+}
+
+- (NSInteger)level {
+
+    _level = 0;
+    if ([_gradeCode isEqualToString:KNEET_MEMBER_MASTER]) {
+        _level = 90;
+    } else if ([_gradeCode isEqualToString:KNEET_MEMBER_POWER]) {
+        _level = 80;
+    } else if ([_gradeCode isEqualToString:KNEET_MEMBER_SIMPLE]) {
+        _level = 10;
+    }
+    return _level;
+}
+
+@end
+
+@implementation HomeGroupListModel
+
+@end
+
+@implementation InvitationModel
+
+@end
+
+@implementation HomeMemberModel
+
+@end
+
+@implementation HomeMemberListModel
+
+@end
+
+@implementation MemberIconModel
+
+@end
+
+@implementation MemberIconListModel
+
+@end
+
+@implementation MobileDeviceListModel
+
+@end
+
+@implementation LoginModel
+
+@synthesize memberId = _memberId, mobileDeviceId = _mobileDeviceId, mobileDeviceAuthorization = _mobileDeviceAuthorization, homegrpId = _homegrpId, newEmailId = _newEmailId, modeChange = _modeChange;
+
+
+//+ (JSONKeyMapper *)keyMapper {
+//
+//    NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
+//
+//    //Self
+//    [dictionary setValue:@"lang" forKey:@"lang"];
+//    [dictionary setValue:@"emailId" forKey:@"email_id"];
+//    [dictionary setValue:@"authToken" forKey:@"auth_token"];
+//
+//    [dictionary setValue:@"lang" forKey:@"lang"];
+//    [dictionary setValue:@"emailId" forKey:@"email_id"];
+//    [dictionary setValue:@"authToken" forKey:@"auth_token"];
+//    [dictionary setValue:@"member" forKey:@"member"];
+//    [dictionary setValue:@"timezoneId" forKey:@"timezone_id"];
+//    [dictionary setValue:@"timezone" forKey:@"timezone"];
+//    [dictionary setValue:@"countryCode" forKey:@"country_code"];
+//    [dictionary setValue:@"memberId" forKey:@"member_id"];
+//    [dictionary setValue:@"serviceId" forKey:@"service_id"];
+//    [dictionary setValue:@"imageFileName" forKey:@"image_file_name"];
+//    [dictionary setValue:@"nickname" forKey:@"nickname"];
+//    [dictionary setValue:@"key" forKey:@"key"];
+//    [dictionary setValue:@"homegrpId" forKey:@"homegrp_id"];
+//    [dictionary setValue:@"homegrpList" forKey:@"homegrp_list"];
+//
+//    return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
+//}
+
+- (void)setMemberId:(NSString *)memberId {
+    _memberId = memberId;
+
+    //사용자 아이디 리스트
+    NSMutableArray *userList = [[JDFacade facade] objectForKeyFromUserDefaults:USER_DEF_USERID_LIST];
+
+    BOOL isExist = NO;
+    if (!userList) {
+        userList = [[NSMutableArray alloc] init];
+
+    } else {
+        for (NSString *memberId in userList) {
+            isExist = [_memberId isEqualToString:memberId];
+            if (isExist) {
+                break;
+            }
+        }
+    }
+
+    if (!isExist) {//기존에 없으면 추가함.
+        [userList addObject:_memberId];
+    }
+
+    [[JDFacade facade] storeObjectToUserDefaults:userList forKey:USER_DEF_USERID_LIST];
+}
+
+- (NSString *)emailId {
+    if (!_emailId || [_emailId isEmptyString]) {
+        _emailId = [JDFacade facade].tmpEmailId;
+    }
+    return _emailId;
+}
+
+#pragma mark - HomeGrp
+- (NSString *)homegrpId {
+    if (!_homegrpId) {
+        _homegrpId = [self.localStorage objectForKey:USER_DEF_HOMEGRP_ID];
+    }
+    return _homegrpId ? _homegrpId : nil;
+}
+
+- (void)setHomegrpId:(NSString *)homegrpId {
+    _homegrpId = homegrpId;
+
+    //로컬 저장소에 저장
+    [self.localStorage setObject:_homegrpId forKey:USER_DEF_HOMEGRP_ID];
+    [self synchronizeLocalStorage];
+}
+
+
+- (NSString *)newEmailId {
+    if (!_newEmailId) {
+        _newEmailId = [self.localStorage objectForKey:USER_DEF_NEW_EMAIL];
+    }
+    return _newEmailId ? _newEmailId : nil;
+}
+
+- (void)setNewEmailId:(NSString *)newEmailId {
+    _newEmailId = newEmailId;
+
+    //로컬 저장소에 저장
+    [self.localStorage setObject:_newEmailId forKey:USER_DEF_NEW_EMAIL];
+    [self synchronizeLocalStorage];
+}
+
+- (NSString *)modeChange {
+    if (!_modeChange) {
+        _modeChange = [self.localStorage objectForKey:USER_DEF_MODE_CHANGE];
+    }
+    return _modeChange ? _modeChange : nil;
+}
+
+- (void)setModeChange:(NSString *)modeChange {
+    _modeChange = modeChange;
+
+    //로컬 저장소에 저장
+    [self.localStorage setObject:_modeChange forKey:USER_DEF_MODE_CHANGE];
+    [self synchronizeLocalStorage];
+}
+
+
+
+#pragma mark - about Location Settings
+//로컬 저장소
+- (NSMutableDictionary *)localStorage {
+    if (!self.memberId)
+        return nil;
+
+    if (!_localStorage) {
+        NSString *encryptedKey = [CypherUtil AES128Encrypt:self.memberId WithKey:self.memberId];
+        _localStorage = [[JDFacade facade] objectForKeyFromUserDefaults:encryptedKey];
+
+        if (!_localStorage) {//저장된 정보가 없을 경우,
+            _localStorage = [[NSMutableDictionary alloc] init];
+        }
+    }
+    return _localStorage;
+}
+
+- (void)synchronizeLocalStorage {
+
+    if (!self.memberId)
+        return;
+
+    NSString *encryptedKey = [CypherUtil AES128Encrypt:self.memberId WithKey:self.memberId];
+    [[JDFacade facade] storeObjectToUserDefaults:self.localStorage forKey:encryptedKey];
+}
+
+
+- (void)addHomegrp:(HomeGroupModel *)homegrp {
+    if (!self.homegrpList) {
+        self.homegrpList = (NSMutableArray<HomeGroupModel> *)[[NSMutableArray alloc] init];
+    }
+
+    for (HomeGroupModel *lhomegrp in self.homegrpList) {
+        [[JDFacade facade] setRadioButtonStatus:@NO object:lhomegrp];
+    }
+
+    [self.homegrpList insertObject:homegrp atIndex:0];
+
+    [JDFacade facade].loginHomeGroup = homegrp;
+}
+@end

+ 61 - 0
kneet2/Classes/Model/ModeModel.h

@@ -0,0 +1,61 @@
+// Generated by json_to_model
+
+#import "JDJSONModel.h"
+#import "ItemModel.h"
+
+@interface ModeModel : ItemSubModel
+
+@property (copy, nonatomic) NSString *modeId;
+@property (copy, nonatomic) NSString *modeName;
+@property (copy, nonatomic) NSString *basicModeCode;
+@property (copy, nonatomic) NSString *useYn;
+@property (copy, nonatomic) NSString *imageFileName;
+@property (copy, nonatomic) NSString *imageFileActiveName;
+
+- (instancetype)initWithSubItem:(ItemSubModel *)subItem;
+
+@end
+
+@interface ModeListModel : JDJSONModel
+
+@property (copy, nonatomic) NSArray<ModeModel> *list;
+
+@end
+
+@protocol HomeLogModel;
+@interface HomeLogModel : JDJSONModel
+@property (copy, nonatomic) NSString *createDate;
+@property (copy, nonatomic) NSString *homelogType;
+@property (copy, nonatomic) NSString *homelogTitle;
+@property (copy, nonatomic) NSString *homelogMsg;
+@property (copy, nonatomic) NSString *imageFileName;
+@property (copy, nonatomic) NSString *createDatetime;
+@property (copy, nonatomic) NSString *createTime;
+
+@end
+
+
+@interface HomeLogListModel : JDJSONModel
+@property (copy, nonatomic) NSArray<HomeLogModel> *homelogList;
+@end
+
+@protocol CameraModel;
+@interface CameraModel : JDJSONModel
+@property (copy, nonatomic) NSString *deviceId;
+@property (copy, nonatomic) NSString *deviceName;
+@property (copy, nonatomic) NSString *controlUrl;
+
+@end
+
+@interface DashboardModel : JDJSONModel
+
+@property (copy, nonatomic) NSString *homegrpName;
+@property (copy, nonatomic) NSString *imageFileName;
+@property (copy, nonatomic) NSString *serviceInformation;
+
+@property (copy, nonatomic) NSArray<ModeModel> *modeList;
+@property (copy, nonatomic) NSArray<HomeLogModel> *homelogList;
+@property (copy, nonatomic) NSArray<CameraModel> *camList;
+
+@end
+

+ 86 - 0
kneet2/Classes/Model/ModeModel.m

@@ -0,0 +1,86 @@
+// Generated by json_to_model
+
+#import "JDObject.h"
+#import "ModeModel.h"
+#import "CommonUtil.h"
+#import "CustomRadioGroup.h"
+
+@implementation ModeModel
+
+//+ (JSONKeyMapper *)keyMapper {
+//
+//    NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
+//
+//    //self
+//    [dictionary setValue:@"modeId" forKey:@"mode_id"];
+//    [dictionary setValue:@"basicModeCode" forKey:@"basic_mode_code"];
+//    [dictionary setValue:@"useYn" forKey:@"use_yn"];
+//    [dictionary setValue:@"imageFileName" forKey:@"image_file_name"];
+//    [dictionary setValue:@"modeName" forKey:@"mode_name"];
+//
+//    return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
+//}
+
+- (instancetype)initWithSubItem:(ItemSubModel *)subItem {
+    if (self = [super init]) {
+        self.modeId = subItem.cmdclsValue;
+        self.modeName = subItem.sourceSubName;
+        self.deleteYn = subItem.deleteYn;
+
+        [[JDFacade facade] setRadioButtonStatus:@YES object:self];
+    }
+    return self;
+}
+
+@end
+
+
+@implementation ModeListModel
+
+@end
+
+
+@implementation HomeLogModel
+
+- (NSString *)createDate {
+    NSDateFormatter *df = [CommonUtil dateFormatter];
+    [df setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
+    [df setDateFormat:@"yyyyMMddHHmmss"];
+    NSDate *utcDate = [df dateFromString:_createDatetime];
+
+    NSDateFormatter* df_local = [[CommonUtil dateFormatter] copy];
+    [df_local setTimeZone:[NSTimeZone systemTimeZone]];
+    [df_local setDateFormat:@"yyyy.MM.dd"];
+
+    NSString* localString = [utcDate isToday] ? @"오늘" : [df_local stringFromDate:utcDate];
+    localString = [utcDate isYesterday] ? @"어제" : localString;
+    return localString;
+}
+
+- (NSString *)createTime {
+    NSDateFormatter *df = [CommonUtil dateFormatter];
+    [df setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
+    [df setDateFormat:@"yyyyMMddHHmmss"];
+    NSDate *utcDate = [df dateFromString:_createDatetime];
+
+    NSDateFormatter* df_local = [[CommonUtil dateFormatter] copy];
+    [df_local setTimeZone:[NSTimeZone systemTimeZone]];
+    [df_local setDateFormat:@"HH:mm"];
+
+    NSString* localString = [df_local stringFromDate:utcDate];
+    return localString;
+}
+
+@end
+
+@implementation HomeLogListModel
+
+@end
+
+@implementation CameraModel
+
+@end
+
+@implementation DashboardModel
+
+@end

+ 65 - 0
kneet2/Classes/Model/RuleModel.h

@@ -0,0 +1,65 @@
+// Generated by json_to_model
+
+@import Foundation;
+
+#import "JDJSONModel.h"
+#import "ItemModel.h"
+
+
+@protocol RuleModel;
+
+@interface RuleModel : JDJSONModel
+
+@property (copy, nonatomic) NSString *homegrpRuleId;
+@property (copy, nonatomic) NSString *ruleId;
+@property (copy, nonatomic) NSString *ruleName;
+@property (copy, nonatomic) NSString *useYn;
+@property (copy, nonatomic) NSString *predRuleId;
+@property (copy, nonatomic) NSString *createDatetime;
+@property (copy, nonatomic) NSString *imageFileName;
+@property (copy, nonatomic) NSString *nickname;
+
+@end
+
+
+@interface RuleListModel : JDJSONModel
+
+@property (copy, nonatomic) NSMutableArray<RuleModel> *list;
+
+@end
+
+
+
+@interface PredefinedRuleDetailModel : JDJSONModel
+
+@property (copy, nonatomic) NSArray<ItemModel> *triggers;
+@property (copy, nonatomic) NSArray<ItemModel> *actions;
+@property (copy, nonatomic) NSArray<ItemModel> *conditions;
+
+@end
+
+
+@interface RuleDetailModel : RuleModel
+
+@property (copy, nonatomic) NSArray<ItemModel> *triggers;
+@property (copy, nonatomic) NSArray<ItemModel> *actions;
+@property (copy, nonatomic) NSArray<ItemModel> *conditions;
+
+@end
+
+@protocol RulePushMemberModel;
+
+@interface RulePushMemberModel : JDJSONModel
+
+@property (nonatomic, copy) NSString *memberId;
+@property (nonatomic, copy) NSString *nickname;
+@property (nonatomic, copy) NSString *targetEmail;
+
+@end
+
+
+@interface RulePushMemberListModel : JDJSONModel
+
+@property (copy, nonatomic) NSArray<RulePushMemberModel> *list;
+
+@end

+ 39 - 0
kneet2/Classes/Model/RuleModel.m

@@ -0,0 +1,39 @@
+// Generated by json_to_model
+
+#import "RuleModel.h"
+
+@implementation RuleModel
+
+
+@end
+
+
+
+@implementation RuleListModel
+
+@end
+
+
+
+@implementation PredefinedRuleDetailModel
+
+@end
+
+
+
+
+@implementation RuleDetailModel
+
+
+@end
+
+
+@implementation RulePushMemberModel
+
+
+@end
+
+
+@implementation RulePushMemberListModel
+
+@end

+ 41 - 0
kneet2/Classes/Model/SceneModel.h

@@ -0,0 +1,41 @@
+// Generated by json_to_model
+
+@import Foundation;
+
+#import "JDJSONModel.h"
+
+#import "DeviceModel.h"
+#import "ModeModel.h"
+#import "ItemModel.h"
+
+@protocol SceneModel;
+@interface SceneModel : JDJSONModel
+
+@property (copy, nonatomic) NSString *homegrpSceneId;
+@property (copy, nonatomic) NSString *sceneName;
+@property (copy, nonatomic) NSString *createDatetime;
+@property (copy, nonatomic) NSString *predSceneId;
+@property (copy, nonatomic) NSString *imageFileName;
+@property (copy, nonatomic) NSString *deleteCnt;  //삭제된 디바이스 카운트
+
+@end
+
+@interface SceneListModel : JDJSONModel
+
+@property (copy, nonatomic) NSArray<SceneModel> *list;
+
+@end
+
+
+@interface SceneDetailModel : SceneModel
+
+@property (copy, nonatomic) NSArray<ItemModel> *actions;
+
+@end
+
+
+@interface PredefinedSceneDetailModel : JDJSONModel
+
+@property (copy, nonatomic) NSArray<ItemModel> *actions;
+
+@end

+ 36 - 0
kneet2/Classes/Model/SceneModel.m

@@ -0,0 +1,36 @@
+// Generated by json_to_model
+
+#import "SceneModel.h"
+
+@implementation SceneModel
+
+//+ (JSONKeyMapper *)keyMapper {
+//
+//    NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
+//
+//    //self
+//    [dictionary setValue:@"sceneName" forKey:@"scene_name"];
+//    [dictionary setValue:@"createDatetime" forKey:@"create_datetime"];
+//    [dictionary setValue:@"memberSceneId" forKey:@"member_scene_id"];
+//    [dictionary setValue:@"predSceneId" forKey:@"pred_scene_id"];
+//
+//    return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
+//}
+//
+//@end
+
+@end
+
+@implementation SceneListModel
+
+@end
+
+@implementation SceneDetailModel
+
+
+@end
+
+@implementation PredefinedSceneDetailModel
+
+
+@end

+ 31 - 14
kneet2/Classes/Util/CommonUtil.m

@@ -76,7 +76,7 @@
     return identifier;
 }
 
-+ (NSString *)deviceName {
++ (NSString *)deviceName {//////////////////
     return [UIDevice currentDevice].name;
 }
 
@@ -237,6 +237,18 @@
 + (UIView *)topView
 {
     UIView *topView = [[[[UIApplication sharedApplication] keyWindow] subviews] lastObject];
+    
+    if ([topView isKindOfClass:NSClassFromString(@"UITransitionView")]) {
+        topView = [[topView subviews] lastObject];
+    }
+    
+    if ([topView isKindOfClass:NSClassFromString(@"CustomLoadingView")]) {
+        
+        topView = [[[[UIApplication sharedApplication] keyWindow] subviews] lastObject];
+        topView = [topView subviews][topView.subviews.count - 2];
+    }
+    
+    topView = topView == nil ? [[UIApplication sharedApplication] keyWindow] : topView;
     return topView;
 }
 
@@ -586,7 +598,12 @@
                                         CGImageGetDataProvider(maskRef), NULL, false);
     
     CGImageRef masked = CGImageCreateWithMask([srcImage CGImage], mask);
-    return [UIImage imageWithCGImage:masked];
+    CGImageRelease(mask);
+    
+    UIImage *imageMask = [UIImage imageWithCGImage:masked];
+    CGImageRelease(masked);
+    
+    return imageMask;
 }
 
 + (UIImage *)imageToGrayScale:(UIImage *)image {
@@ -685,12 +702,12 @@
 + (NSDateComponents *)dateComponents:(NSDate *)date {
     
     NSCalendar *calendar = [CommonUtil calendar];
-    NSDateComponents *components = [calendar components:(NSYearCalendarUnit  |
-                                                         NSMonthCalendarUnit |
-                                                         NSDayCalendarUnit   |
-                                                         NSHourCalendarUnit  |
-                                                         NSMinuteCalendarUnit|
-                                                         NSSecondCalendarUnit|
+    NSDateComponents *components = [calendar components:(NSCalendarUnitYear |
+                                                         NSCalendarUnitMonth |
+                                                         NSCalendarUnitDay   |
+                                                         NSCalendarUnitHour  |
+                                                         NSCalendarUnitMinute|
+                                                         NSCalendarUnitSecond|
                                                          NSCalendarUnitTimeZone) fromDate:date];
     return components;
 }
@@ -699,12 +716,12 @@
     
     NSCalendar *calendar = [CommonUtil calendar];
     [calendar setTimeZone:timezone];
-    NSDateComponents *components = [calendar components:(NSYearCalendarUnit  |
-                                                         NSMonthCalendarUnit |
-                                                         NSDayCalendarUnit   |
-                                                         NSHourCalendarUnit  |
-                                                         NSMinuteCalendarUnit|
-                                                         NSSecondCalendarUnit|
+    NSDateComponents *components = [calendar components:(NSCalendarUnitYear |
+                                                         NSCalendarUnitMonth |
+                                                         NSCalendarUnitDay   |
+                                                         NSCalendarUnitHour  |
+                                                         NSCalendarUnitMinute|
+                                                         NSCalendarUnitSecond|
                                                          NSCalendarUnitTimeZone) fromDate:date];
     return components;
 }

+ 3 - 3
kneet2/Classes/ViewControllers/JDTableViewController.h

@@ -1,9 +1,9 @@
 //
 //  JDTableViewController.h
-//  ___PROJECTNAME___
+//  kneet2
 //
-//  Created by ___FULLUSERNAME___ on ___DATE___.
-//  Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
+//  Created by Created by Jason Lee on 10/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
 //
 
 #import "JDObject.h"

+ 3 - 3
kneet2/Classes/ViewControllers/JDTableViewController.m

@@ -1,9 +1,9 @@
 //
 //  JDTableViewController.m
-//  ___PROJECTNAME___
+//  kneet2
 //
-//  Created by ___FULLUSERNAME___ on ___DATE___.
-//  Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
+//  Created by Created by Jason Lee on 10/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
 //
 
 #import "CustomTableView.h"

+ 3 - 3
kneet2/Classes/ViewControllers/JDViewController.h

@@ -1,9 +1,9 @@
 //
 //  JDViewController.h
-//  ___PROJECTNAME___
+//  kneet2
 //
-//  Created by ___FULLUSERNAME___ on ___DATE___.
-//  Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
+//  Created by Created by Jason Lee on 10/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
 //
 
 #import "JDObject.h"

+ 3 - 3
kneet2/Classes/ViewControllers/JDViewController.m

@@ -1,9 +1,9 @@
 //
 //  JDViewController.m
-//  ___PROJECTNAME___
+//  kneet2
 //
-//  Created by ___FULLUSERNAME___ on ___DATE___.
-//  Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
+//  Created by Created by Jason Lee on 10/1/15.
+//  Copyright (c) 2015 ntels. All rights reserved.
 //
 
 #import "JDViewController.h"