From 83dfe9663ebef66267fcb955834b861fb43ef69f Mon Sep 17 00:00:00 2001 From: benceszasz Date: Sun, 14 May 2023 14:45:57 +0200 Subject: [PATCH] Multi follow server with 7xxG --- .../carelinkfollow/client/CareLinkClient.java | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/cgm/carelinkfollow/client/CareLinkClient.java b/app/src/main/java/com/eveningoutpost/dexdrip/cgm/carelinkfollow/client/CareLinkClient.java index 7c0d731..9b90d2d 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/cgm/carelinkfollow/client/CareLinkClient.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/cgm/carelinkfollow/client/CareLinkClient.java @@ -122,7 +122,18 @@ public RecentData getRecentData(String patientUsername) { if (getAuthorizationToken() != null) { // M2M if (this.sessionM2MEnabled) - return this.getM2MPatientData(patientUsername); + // Care Partner + if(this.sessionUser.isCarePartner()) + return this.getM2MPatientData(patientUsername); + // Patient + else + // 7xxG + if(sessionMonitorData.isBle()) + return this.getConnectDisplayMessage(this.sessionProfile.username, this.sessionUser.getUserRole(), + sessionCountrySettings.blePereodicDataEndpoint); + // Standalone CGM + else + return this.getLast24Hours(); // Non M2M (old logic) else if (sessionMonitorData.isBle()) return this.getConnectDisplayMessage(this.sessionProfile.username, this.sessionUser.getUserRole(), @@ -172,14 +183,8 @@ protected boolean executeLoginProcedure() { lastErrorMessage = ""; try { - // Clear cookies - ((SimpleOkHttpCookieJar) this.httpClient.cookieJar()).deleteAllCookies(); - // Clear basic infos - this.sessionUser = null; - this.sessionProfile = null; - this.sessionCountrySettings = null; - this.sessionMonitorData = null; + this.clearSessionInfos(); // Open login (get SessionId and SessionData) loginSessionResponse = this.getLoginSession(); @@ -201,10 +206,12 @@ protected boolean executeLoginProcedure() { this.sessionProfile = this.getMyProfile(); this.sessionCountrySettings = this.getMyCountrySettings(); this.sessionM2MEnabled = this.getM2MEnabled().value; - if(!this.sessionM2MEnabled) - this.sessionMonitorData = this.getMonitorData(); + //Care Partner + multi follow => patients if(this.sessionUser.isCarePartner() && this.sessionM2MEnabled) this.sessionPatients = this.getM2MPatients(); + //Patient or Care Partner & not multi follow => monitor data + else + this.sessionMonitorData = this.getMonitorData(); } catch (Exception e) { lastErrorMessage = e.getClass().getSimpleName() + ":" + e.getMessage(); @@ -215,22 +222,27 @@ protected boolean executeLoginProcedure() { // Set login success if everything was ok: if(this.sessionUser != null && this.sessionProfile != null && this.sessionCountrySettings != null && this.sessionM2MEnabled != null - && (this.sessionM2MEnabled || this.sessionMonitorData != null)) + && ((this.sessionM2MEnabled && this.sessionUser.isCarePartner() && this.sessionPatients != null) || this.sessionMonitorData != null)) lastLoginSuccess = true; //Clear cookies, session infos if error occured during login process else { - ((SimpleOkHttpCookieJar) this.httpClient.cookieJar()).deleteAllCookies(); - this.sessionUser = null; - this.sessionProfile = null; - this.sessionCountrySettings = null; - this.sessionMonitorData = null; - this.sessionPatients = null; + this.clearSessionInfos(); } return lastLoginSuccess; } + protected void clearSessionInfos() + { + ((SimpleOkHttpCookieJar) this.httpClient.cookieJar()).deleteAllCookies(); + this.sessionUser = null; + this.sessionProfile = null; + this.sessionCountrySettings = null; + this.sessionMonitorData = null; + this.sessionPatients = null; + } + protected Response getLoginSession() throws IOException { HttpUrl url = null;