def removeFileHandle(self, data): db = DB_Accesser() sessionid = data["sessionID"] freerestr = db.Get_Session({"sessionID": sessionid}) freerestr = freerestr["SessionConfig"]["permissions"] owner = db.Get_File(data["File"]) owner = owner["owneremail"] admin = db.Get_SessionAdmin({"sessionID": sessionid}) admin = admin["email"] if (permissions == RESTRICTED) and (self.user is not admin) or ( self.user is not owner): self.returnInsucess( LOAD_FILE_SESSION, "You dont have permissions to share or you are not owner") return result = db.Remove_FileFromSession(data) if result is True: self.updateFiles(sessionid) self.returnSuccess(LOAD_FILE_SESSION, None) else: self.returnInsucess(LOAD_FILE_SESSION) return
def loadFileHandle(self, data): print "load file: " + self.user + " in session " + chr( data["sessionID"]) db = DB_Accesser() sessionid = data["sessionID"] permissions = db.Get_Session({"sessionID": sessionid}) permissions = permissions["SessionConfig"]["permissions"] admin = db.Get_SessionAdmin({"sessionID": sessionid}) #admin = admin["email"] if permissions == RESTRICTED and self.user is not admin: self.returnInsucess(LOAD_FILE_SESSION, "You dont have permissions to share") return db.Insert_File(data["File"]) result = db.Insert_FileInSession(data) if result is True: self.updateFiles(sessionid) self.returnSuccess(LOAD_FILE_SESSION, None) else: self.returnInsucess(LOAD_FILE_SESSION) return
def joinSessionHandle(self, data): print "join session: " + self.user + " in session " + chr( data["sessionID"]) db = DB_Accesser() sessionid = data["sessionID"] pubpriv = db.Get_Session({"sessionID": sessionid}) pubpriv = pubpriv["SessionConfig"]["type"] if (pubpriv == PRIVATE): admin = db.Get_SessionAdmin({"sessionID": sessionid}) admin = admin["email"] self.sendSharinfFrame(REQUESTJOINSESSION, { "sessionID": sessionid, "email": self.user }, usr=admin) responseframe = self.getSharinfFrame(admin) if responseframe.data == INSUCESS: self.returnInsucess(JOIN_SESSION, "Administrar didnt accept") return result = db.Insert_UserInSession({ "email": self.user, "sessionID": sessionid }) if result is True: self.sessionIDi = sessionid self.updateUsers(sessionid) self.returnSuccess(JOIN_SESSION) else: self.returnInsucess( JOIN_SESSION, "It was not possible to join sesion probably beacause session does not exists or you are already there..." ) return
def beaconDetectedHandle(self, data): print "Beacon detected: " + self.user db = DB_Accesser() beaconlist = [] sessionlist = [] for beacon in data: location = db.Get_Location(beacon) while (location == None): db.Insert_Location(beacon) location = db.Get_Location(beacon) print location db.Insert_UserInLocation({ "email": self.user, "localizationID": location["BeaconState"]["localizationID"] }) beaconlist.append(location) tempsessid = db.Get_ActiveSessionFromLocal( {"localizationID": location["BeaconState"]["localizationID"]}) if (tempsessid is not None): sessionlist.append(db.Get_Session(tempsessid)) else: sessionlist.append(None) self.returnSuccess(BEACON_DETECTED, { "BeaconList": beaconlist, "SessionList": sessionlist }) return
"activeFlag": True, "localizationID": 1, "s_type": 1, "s_name": "Sharinf_123" } sCreated = myReqHandler.Insert_Session(sess) print(sCreated) newConfig = {"sessionID": 1, "permissions": 0} #} #print(myReqHandler.Get_Session({"sessionID":1})) #print(myReqHandler.Update_SessionConfig(newConfig)) #print(myReqHandler.Get_Session({"sessionID":1})) #print(myReqHandler.End_Session({"sessionID" : 1})) in_UserSess = {"sessionID": 2, "email": m_user["email"]} #rint(myReqHandler.Get_UserInSession(in_UserSess)) #print(myReqHandler.Get_User(m_user)) print(myReqHandler.Get_Session({"sessionID": in_UserSess["sessionID"]})) #print(myReqHandler.Insert_UserInSession(in_UserSess)) #print(myReqHandler.Set_SessionAdmin(in_UserSess)) #print(myReqHandler.Get_AllUsersInSession({"sessionID":1})) #print(myReqHandler.Insert_FileInSession({"sessionID":1,"File":m_file})) #print(myReqHandler.Get_AllFilesFromSession({"sessionID":1})) #print(myReqHandler.Get_FileFromSession({"sessionID":1,"File":m_file})) #print(myReqHandler.Get_SessionAdmin({"sessionID":1})) #print(myReqHandler.Remove_FileFromSession({"sessionID":1,"File":m_file})) #print(myReqHandler.Remove_UserFromSession({"email":m_user["email"], "sessionID": 1}))