Finished job of removing obsolete exceptions and handling reauthentication if the...
authorkenstir <kenstir@gmail.com>
Thu, 5 Dec 2013 01:24:12 +0000 (20:24 -0500)
committerkenstir <kenstir@gmail.com>
Thu, 5 Dec 2013 01:24:12 +0000 (20:24 -0500)
14 files changed:
Open-ILS/src/Android/project.properties
Open-ILS/src/Android/res/values/ou.xml
Open-ILS/src/Android/res/xml/application_preference_screen.xml
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookbagsListView.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/checkout/ItemsCheckOutListView.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldsListView.java
Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SampleUnderlinesNoFade.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java
Open-ILS/src/Android/src/org/evergreen/android/services/ScheduledIntentService.java
Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java
Open-ILS/src/Android/src/org/evergreen/android/views/ConfigureApplicationActivity.java
Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/LoadingTask.java
Open-ILS/src/Android/src/org/evergreen_ils/auth/EvergreenAuthenticator.java

index 73fc661..a5578ba 100644 (file)
@@ -8,4 +8,4 @@
 # project structure.
 
 # Project target.
-target=android-18
+target=android-19
index 1f93e0b..9b5b79f 100644 (file)
@@ -3,7 +3,6 @@
 <resources>
     <!--  TODO: make URLs HTTPS -->
     <string name="ou_library_url">http://bark.cwmars.org</string>
-    <string name="ou_gateway_url">http://bark.cwmars.org/osrf-gateway-v1</string>
     <string name="ou_app_name">C/W Mars Library</string>
     <string name="ou_app_label">C/W Mars</string>
     <string name="ou_app_welcome_label">Welcome</string>
index 0f1ec81..8647a96 100644 (file)
@@ -1,35 +1,18 @@
 <?xml version="1.0" encoding="utf-8"?>
 <PreferenceScreen
-        xmlns:android="http://schemas.android.com/apk/res/android"
-        android:key="first_preferencescreen">
-        <PreferenceCategory
-          android:summary="@string/preference_login_information"
-          android:title="@string/preference_login_informantion_summary" >
-               <EditTextPreference
-            android:key="username"
-            android:summary="@string/preference_username_summary"
-            android:title="@string/preference_username" />
-               <EditTextPreference
-            android:key="password"
-            android:summary="@string/preference_password_summary"
-            android:title="@string/preference_password"
-            android:inputType="textPassword"
-             />
-        </PreferenceCategory>
-   
-        
-                <PreferenceCategory
-          android:summary="@string/preference_server_information_summary"
+        xmlns:android="http://schemas.android.com/apk/res/android">
+
+        <PreferenceCategory
           android:title="@string/preference_server_information_title" >
                <EditTextPreference
             android:key="library_url"
             android:summary="@string/preference_library_url_address_summary"
-            android:title="@string/preference_library_url_address" />
-
+            android:title="@string/preference_library_url_address"
+         android:defaultValue="@string/ou_library_url"/>
         </PreferenceCategory>
   
        <PreferenceCategory
-          android:title="@string/preference_notifications_title" >      
+          android:title="@string/preference_notifications_title" >
                 
          <PreferenceScreen
                 android:key="NotificationsPrefScreen"
index fe8ddee..67d210c 100644 (file)
@@ -145,48 +145,44 @@ public class BookbagsListView extends Activity {
             @Override
             public void onClick(View v) {
 
-                final String name = bookbag_name.getText().toString();
+            final String name = bookbag_name.getText().toString();
 
-                Thread createBookbag = new Thread(new Runnable() {
-                    @Override
-                    public void run() {
-
-                        if (name.length() > 1) {
+            Thread createBookbag = new Thread(new Runnable() {
+                @Override
+                public void run() {
+                    if (name.length() > 1) {
+                        try {
+                            accountAccess.createBookbag(name);
+                        } catch (SessionNotFoundException e) {
                             try {
-                                accountAccess.createBookbag(name);
-                            } catch (SessionNotFoundException e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                            } catch (NoNetworkAccessException e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                            } catch (NoAccessToServer e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
+                                if (accountAccess.reauthenticate(BookbagsListView.this))
+                                    accountAccess.createBookbag(name);
+                            } catch (Exception eauth) {
+                                System.out.println("Exception in reAuth");
                             }
-
-                            runOnUiThread(new Runnable() {
-                                @Override
-                                public void run() {
-                                    progressDialog.dismiss();
-                                }
-                            });
-
-                            Thread getBookBags = new Thread(getBookbagsRunnable);
-                            getBookBags.start();
                         }
 
+                        runOnUiThread(new Runnable() {
+                            @Override
+                            public void run() {
+                                progressDialog.dismiss();
+                            }
+                        });
+
+                        Thread getBookBags = new Thread(getBookbagsRunnable);
+                        getBookBags.start();
                     }
-                });
+                }
+            });
 
-                if (name.length() > 1) {
-                    progressDialog = ProgressDialog.show(context,
-                            "Please wait", "Creating Bookbag");
-                    createBookbag.start();
-                } else
-                    Toast.makeText(context,
-                            "Bookbag name must be at least 2 characters long",
-                            Toast.LENGTH_SHORT).show();
+            if (name.length() > 1) {
+                progressDialog = ProgressDialog.show(context,
+                        "Please wait", "Creating Bookbag");
+                createBookbag.start();
+            } else
+                Toast.makeText(context,
+                        "Bookbag name must be at least 2 characters long",
+                        Toast.LENGTH_SHORT).show();
             }
         });
 
@@ -204,22 +200,15 @@ public class BookbagsListView extends Activity {
 
                 try {
                     accountAccess.retrieveBookbags();
-                    bookBags = accountAccess.getBookbags();
-
-                } catch (NoNetworkAccessException e) {
-                    Utils.showSessionNotAvailableDialog(context);
-                } catch (NoAccessToServer e) {
-                    Utils.showServerNotAvailableDialog(context);
-
                 } catch (SessionNotFoundException e) {
-                    // TODO other way?
                     try {
-                        if (accountAccess.authenticate())
-                            accountAccess.getBookbags();
+                        if (accountAccess.reauthenticate(BookbagsListView.this))
+                            accountAccess.retrieveBookbags();
                     } catch (Exception eauth) {
                         System.out.println("Exception in reAuth");
                     }
                 }
+                bookBags = accountAccess.getBookbags();
 
                 runOnUiThread(new Runnable() {
 
index 645d50a..03fffba 100644 (file)
@@ -54,7 +54,7 @@ import android.widget.Toast;
 
 public class ItemsCheckOutListView extends Activity {
 
-    private String TAG = "ItemsCheckOutListView";
+    private String TAG = ItemsCheckOutListView.class.getName();
 
     private AccountAccess accountAccess = null;
 
@@ -138,21 +138,12 @@ public class ItemsCheckOutListView extends Activity {
 
                 try {
                     circRecords = accountAccess.getItemsCheckedOut();
-                } catch (NoNetworkAccessException e) {
-                    Utils.showSessionNotAvailableDialog(context);
-                } catch (NoAccessToServer e) {
-                    Utils.showServerNotAvailableDialog(context);
-
                 } catch (SessionNotFoundException e) {
-                    // TODO other way?
                     try {
-
-                        Log.d(TAG, "REAUTH " + "in process");
-
-                        if (accountAccess.authenticate())
+                        if (accountAccess.reauthenticate(ItemsCheckOutListView.this))
                             circRecords = accountAccess.getItemsCheckedOut();
                     } catch (Exception eauth) {
-                        System.out.println("Exception in reAuth");
+                        Log.d(TAG, "Exception in reauth", eauth);
                     }
                 }
 
@@ -247,153 +238,132 @@ public class ItemsCheckOutListView extends Activity {
             // Get item
             final CircRecord record = getItem(position);
 
-                // if it is the right type of view
-                if (row == null) {
-
-                    Log.d(tag, "Starting XML Row Inflation ... ");
-                    LayoutInflater inflater = (LayoutInflater) this
-                            .getContext().getSystemService(
-                                    Context.LAYOUT_INFLATER_SERVICE);
-                    row = inflater.inflate(R.layout.checkout_list_item, parent,
-                            false);
-                    Log.d(tag, "Successfully completed XML Row Inflation!");
-
-                }
+            // if it is the right type of view
+            if (row == null) {
 
-                // Get reference to TextView - title
-                recordTitle = (TextView) row
-                        .findViewById(R.id.checkout_record_title);
+                Log.d(tag, "Starting XML Row Inflation ... ");
+                LayoutInflater inflater = (LayoutInflater) this
+                        .getContext().getSystemService(
+                                Context.LAYOUT_INFLATER_SERVICE);
+                row = inflater.inflate(R.layout.checkout_list_item, parent,
+                        false);
+                Log.d(tag, "Successfully completed XML Row Inflation!");
 
-                // Get reference to TextView - author
-                recordAuthor = (TextView) row
-                        .findViewById(R.id.checkout_record_author);
-
-                // Get reference to TextView - record Publisher date+publisher
-                recordDueDate = (TextView) row
-                        .findViewById(R.id.checkout_due_date);
-
-                renewButton = (TextView) row.findViewById(R.id.renew_button);
-
-                renewButton.setText("renew : " + record.getRenewals());
-
-                renewButton.setOnClickListener(new OnClickListener() {
+            }
 
-                    @Override
-                    public void onClick(View v) {
+            // Get reference to TextView - title
+            recordTitle = (TextView) row
+                    .findViewById(R.id.checkout_record_title);
+
+            // Get reference to TextView - author
+            recordAuthor = (TextView) row
+                    .findViewById(R.id.checkout_record_author);
+
+            // Get reference to TextView - record Publisher date+publisher
+            recordDueDate = (TextView) row
+                    .findViewById(R.id.checkout_due_date);
+
+            renewButton = (TextView) row.findViewById(R.id.renew_button);
+
+            renewButton.setText("renew : " + record.getRenewals());
+
+            renewButton.setOnClickListener(new OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    Thread renew = new Thread(new Runnable() {
+
+                        @Override
+                        public void run() {
+                            boolean refresh = true;
+                            AccountAccess ac = AccountAccess
+                                    .getAccountAccess();
+
+                            runOnUiThread(new Runnable() {
+                                @Override
+                                public void run() {
+                                    progressDialog = new ProgressDialog(
+                                            context);
+                                    progressDialog
+                                            .setMessage("Renewing item");
+                                    progressDialog.show();
+                                }
+                            });
 
-                        Thread renew = new Thread(new Runnable() {
+                            try {
+                                ac.renewCirc(record.getTargetCopy());
+                            } catch (MaxRenewalsException e1) {
+                                runOnUiThread(new Runnable() {
 
-                            @Override
-                            public void run() {
-                                boolean refresh = true;
-                                AccountAccess ac = AccountAccess
-                                        .getAccountAccess();
+                                    @Override
+                                    public void run() {
+                                        progressDialog.dismiss();
+                                        Toast.makeText(context,
+                                                "Max renewals reached",
+                                                Toast.LENGTH_LONG).show();
+                                    }
+                                });
 
+                                refresh = false;
+                            } catch (ServerErrorMessage error) {
+                                final String errorMessage = error.message;
                                 runOnUiThread(new Runnable() {
+
                                     @Override
                                     public void run() {
-                                        progressDialog = new ProgressDialog(
-                                                context);
-                                        progressDialog
-                                                .setMessage("Renewing item");
-                                        progressDialog.show();
+                                        progressDialog.dismiss();
+                                        Toast.makeText(context,
+                                                errorMessage,
+                                                Toast.LENGTH_LONG).show();
                                     }
                                 });
-
+                            } catch (SessionNotFoundException e1) {
                                 try {
-                                    ac.renewCirc(record.getTargetCopy());
-                                } catch (MaxRenewalsException e1) {
-                                    runOnUiThread(new Runnable() {
-
-                                        @Override
-                                        public void run() {
-                                            progressDialog.dismiss();
-                                            Toast.makeText(context,
-                                                    "Max renewals reached",
-                                                    Toast.LENGTH_LONG).show();
-                                        }
-                                    });
-
-                                    refresh = false;
-                                } catch (ServerErrorMessage error) {
-
-                                    final String errorMessage = error.message;
-                                    runOnUiThread(new Runnable() {
+                                    if (accountAccess.reauthenticate(ItemsCheckOutListView.this))
+                                        ac.renewCirc(record.getTargetCopy());
+                                } catch (Exception eauth) {
+                                    Log.d(TAG, "Exception in reauth", eauth);
+                                }
+                            }
 
-                                        @Override
-                                        public void run() {
-                                            progressDialog.dismiss();
-                                            Toast.makeText(context,
-                                                    errorMessage,
-                                                    Toast.LENGTH_LONG).show();
-                                        }
-                                    });
-                                } catch (SessionNotFoundException e1) {
+                            if (refresh) {
+                                try {
+                                    circRecords = accountAccess.getItemsCheckedOut();
+                                } catch (SessionNotFoundException e) {
                                     try {
-                                        if (accountAccess.authenticate())
-                                            ac.renewCirc(record.getTargetCopy());
+                                        if (accountAccess.reauthenticate(ItemsCheckOutListView.this))
+                                            circRecords = accountAccess.getItemsCheckedOut();
                                     } catch (Exception eauth) {
-                                        System.out
-                                                .println("Exception in reAuth");
+                                        Log.d(TAG, "Exception in reauth", eauth);
                                     }
-                                } catch (NoNetworkAccessException e1) {
-                                    Utils.showSessionNotAvailableDialog(context);
-                                } catch (NoAccessToServer e1) {
-                                    Utils.showServerNotAvailableDialog(context);
                                 }
 
-                                if (refresh) {
-
-                                    try {
-                                        circRecords = accountAccess
-                                                .getItemsCheckedOut();
-                                    } catch (NoNetworkAccessException e) {
-                                        Utils.showSessionNotAvailableDialog(context);
-                                    } catch (NoAccessToServer e) {
-                                        Utils.showServerNotAvailableDialog(context);
-
-                                    } catch (SessionNotFoundException e) {
-                                        // TODO other way?
-                                        try {
-                                            if (accountAccess.authenticate())
-                                                circRecords = accountAccess
-                                                        .getItemsCheckedOut();
-                                        } catch (Exception eauth) {
-                                            System.out
-                                                    .println("Exception in reAuth");
+                                runOnUiThread(new Runnable() {
+                                    @Override
+                                    public void run() {
+                                        listAdapter.clear();
+                                        for (int i = 0; i < circRecords.size(); i++) {
+                                            listAdapter.add(circRecords.get(i));
                                         }
+                                        progressDialog.dismiss();
+                                        listAdapter.notifyDataSetChanged();
                                     }
-
-                                    runOnUiThread(new Runnable() {
-
-                                        @Override
-                                        public void run() {
-                                            listAdapter.clear();
-                                            for (int i = 0; i < circRecords
-                                                    .size(); i++) {
-                                                listAdapter.add(circRecords
-                                                        .get(i));
-                                            }
-
-                                            progressDialog.dismiss();
-                                            listAdapter.notifyDataSetChanged();
-                                        }
-                                    });
-                                }
+                                });
                             }
-                        });
-
-                        renew.start();
-                    }
-                });
+                        }
+                    });
 
-                // set text
-                System.out.println("Row" + record.getTitle() + " "
-                        + record.getAuthor() + " " + record.getDueDate() + " "
-                        + record.getRenewals());
-                recordTitle.setText(record.getTitle());
-                recordAuthor.setText(record.getAuthor());
-                recordDueDate.setText(record.getDueDate());
+                    renew.start();
+                }
+            });
+
+            // set text
+            recordTitle.setText(record.getTitle());
+            recordAuthor.setText(record.getAuthor());
+            recordDueDate.setText(record.getDueDate());
+            Log.d(TAG, "title:  " + record.getTitle());
+            Log.d(TAG, "author: " + record.getAuthor());
+            Log.d(TAG, "due:    " + record.getDueDate());
+            Log.d(TAG, "renew:  " + record.getRenewals());
 
             return row;
         }
index 414903e..198e4c9 100644 (file)
@@ -140,10 +140,6 @@ public class HoldsListView extends Activity {
                     } catch (Exception eauth) {
                         System.out.println("Exception in reauth");
                     }
-                } catch (NoNetworkAccessException e) {
-                    Utils.showSessionNotAvailableDialog(context);
-                } catch (NoAccessToServer e) {
-                    Utils.showServerNotAvailableDialog(context);
                 }
 
                 runOnUiThread(new Runnable() {
@@ -157,26 +153,18 @@ public class HoldsListView extends Activity {
                         holdsNoText.setText(" " + listAdapter.getCount());
                         progressDialog.dismiss();
                         listAdapter.notifyDataSetChanged();
-
                     }
                 });
             }
         };
 
-        // 1 NPE
-        if (accountAccess.isAuthenticated()) {
-            progressDialog = new ProgressDialog(context);
-            progressDialog.setMessage("Loading holds");
-            progressDialog.show();
+        progressDialog = new ProgressDialog(context);
+        progressDialog.setMessage("Loading holds");
+        progressDialog.show();
 
-            // thread to retrieve holds
-            Thread getHoldsThread = new Thread(getHoldsRunnable);
-            getHoldsThread.start();
-
-        } else
-            Toast.makeText(context,
-                    "You must be authenticated to retrieve circ records",
-                    Toast.LENGTH_LONG);
+        // thread to retrieve holds
+        Thread getHoldsThread = new Thread(getHoldsRunnable);
+        getHoldsThread.start();
 
         lv.setOnItemClickListener(new OnItemClickListener() {
 
@@ -203,13 +191,13 @@ public class HoldsListView extends Activity {
 
         switch (resultCode) {
 
-        case HoldDetails.RESULT_CODE_CANCEL: {
+        case HoldDetails.RESULT_CODE_CANCEL:
             // nothing
             Log.d(TAG, "Do nothing");
-        }
             break;
 
-        case HoldDetails.RESULT_CODE_DELETE_HOLD: {
+        case HoldDetails.RESULT_CODE_DELETE_HOLD:
+        case HoldDetails.RESULT_CODE_UPDATE_HOLD:
             // refresh ui
             progressDialog = new ProgressDialog(context);
             progressDialog.setMessage("Loading holds");
@@ -217,22 +205,8 @@ public class HoldsListView extends Activity {
             // thread to retrieve holds
             Thread getHoldsThread = new Thread(getHoldsRunnable);
             getHoldsThread.start();
-            Log.d(TAG, "Update on delete hold");
-        }
+            Log.d(TAG, "Update on result "+resultCode);
             break;
-
-        case HoldDetails.RESULT_CODE_UPDATE_HOLD: {
-            // refresh ui
-            progressDialog = new ProgressDialog(context);
-            progressDialog.setMessage("Loading holds");
-            progressDialog.show();
-            // thread to retrieve holds
-            Thread getHoldsThread = new Thread(getHoldsRunnable);
-            getHoldsThread.start();
-            Log.d(TAG, "Update on update hold");
-        }
-            break;
-
         }
     }
 
index 0a4508b..51d95ba 100644 (file)
@@ -133,9 +133,8 @@ public class GlobalConfigs {
             long duration_ms = System.currentTimeMillis() - start_ms;
             Log.d(TAG, "loadIDLFile parse took "+duration_ms+"ms");
         } catch (Exception e) {
-            Log.e(TAG, "Error in parsing IDL file", e);
+            Log.w(TAG, "Error in parsing IDL file", e);
         }
-        ;
 
         loadedIDL = true;
     }
index 1da7060..f3eccf9 100644 (file)
@@ -22,6 +22,7 @@ package org.evergreen.android.searchCatalog;
 import java.util.ArrayList;
 
 import org.evergreen.android.R;
+import org.evergreen.android.accountAccess.SessionNotFoundException;
 import org.evergreen.android.globals.Utils;
 import org.evergreen.android.utils.ui.BaseSampleActivity;
 import org.evergreen.android.utils.ui.BasicDetailsFragment;
@@ -136,22 +137,12 @@ public class SampleUnderlinesNoFade extends BaseSampleActivity {
                     }
                 });
                 
-                try {
-                    searchRecords = search.getSearchResults(search.searchText,
-                            records.size());
-                } catch (NoNetworkAccessException e) {
-                    runOnUiThread(Utils
-                            .showSessionNotAvailableDialog(context));
-                } catch (NoAccessToServer e) {
-                    runOnUiThread(Utils
-                            .showServerNotAvailableDialog(context));
-                }
+                searchRecords = search.getSearchResults(search.searchText, records.size());
 
                 runOnUiThread(new Runnable() {
 
                     @Override
                     public void run() {
-
                         // don't clear record list
                         // recordList.clear();
                         if (searchRecords.size() > 0) {
index cefe6ef..f1749bf 100644 (file)
@@ -378,9 +378,7 @@ public class SearchCatalogListView extends Activity {
                     // serialize object and pass it to next activity
                     intent.putExtra("recordInfo", info);
                     intent.putExtra("orgID", search.selectedOrganization.id);
-                    intent.putExtra("depth",
-                            (search.selectedOrganization.level - 1));
-
+                    intent.putExtra("depth", (search.selectedOrganization.level - 1));
                     intent.putExtra("recordList", recordList);
                     intent.putExtra("recordPosition", position);
                     startActivityForResult(intent, 10);
@@ -403,9 +401,11 @@ public class SearchCatalogListView extends Activity {
 
                 if (!loadingElements) {
 
+                    /*
                     Log.d(TAG, " Scroll adapter " + totalItemCount + " "
                             + visibleItemCount + " " + firstVisibleItem + " "
                             + adapter.getCount() + " " + search.visible);
+                            */
                     if (totalItemCount > 0
                             && (((totalItemCount - visibleItemCount) <= (firstVisibleItem)) && adapter
                                     .getCount() < search.visible)) {
index f40db46..cef1cee 100644 (file)
@@ -25,6 +25,9 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
+import android.accounts.AccountManager;
+import android.accounts.AccountManagerFuture;
+import android.os.Bundle;
 import org.androwrapee.db.DefaultDAO;
 import org.evergreen.android.accountAccess.AccountAccess;
 import org.evergreen.android.accountAccess.SessionNotFoundException;
@@ -32,6 +35,7 @@ import org.evergreen.android.accountAccess.checkout.CircRecord;
 import org.evergreen.android.database.DatabaseManager;
 import org.evergreen.android.globals.GlobalConfigs;
 import org.evergreen.android.globals.Utils;
+import org.evergreen_ils.auth.Const;
 import org.open_ils.idl.IDLParser;
 
 import android.app.AlarmManager;
@@ -46,9 +50,9 @@ public class ScheduledIntentService extends IntentService {
 
     public static Date lastUpdateServiceDate;
 
-    public static String TAG = "ScheduledIntentService";
+    public static String TAG = ScheduledIntentService.class.getName();
 
-    public static String ACTION = "org.evergreen.updateservice";
+    public static String ACTION = "org.evergreen_ils.updateservice";
 
     // fire up once a day
     public static int SCHEDULE_TIME_INTERVAL = 1;
@@ -64,6 +68,9 @@ public class ScheduledIntentService extends IntentService {
         return super.onStartCommand(intent, flags, startId);
     }
 
+    //TODO: share some of this code with LoadingTask.doInBackground
+    //TODO: this code needs major work.  I never saw it work so I don't
+    // feel bad about disabling it for now.
     @Override
     protected void onHandleIntent(Intent intent) {
 
@@ -78,28 +85,32 @@ public class ScheduledIntentService extends IntentService {
         String idlFile = GlobalConfigs.IDL_FILE_FROM_ROOT
                 + "?class=circ&class=au&class=mvr&class=acp";
         try {
-            Log.d("debug", "Read fm");
-            InputStream in_IDL = Utils
-                    .getNetInputStream(GlobalConfigs.httpAddress + idlFile);
+            Log.d(TAG, "Load IDL start");
+            InputStream in_IDL = Utils.getNetInputStream(GlobalConfigs.httpAddress + idlFile);
             IDLParser parser = new IDLParser(in_IDL);
+            parser.setKeepIDLObjects(false);
             parser.parse();
         } catch (Exception e) {
-            System.err.println("Error in parsing IDL file " + idlFile + " "
-                    + e.getMessage());
+            Log.w("Error in parsing IDL", e);
         }
-        ;
 
-        // login with the user credentials
+        /*
         AccountAccess accountAccess = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress);
-        boolean auth = true;
-        try {
-            accountAccess.authenticate();
-        } catch (Exception e) {
-            auth = false;
-            e.printStackTrace();
-        }
-
-        // if we managed to authenticate we start
+        Log.d(TAG, tag+"Signing in");
+        AccountManager accountManager = AccountManager.get(this);
+
+        // what needs to be done is
+        // 1. get last used account name
+        // 2. see if the account still exists
+        // 3. get an auth token for it
+        // 4. start an evergreen session
+        AccountManagerFuture<Bundle> future = accountManager.getAuthTokenByFeatures(Const.ACCOUNT_TYPE, Const.AUTHTOKEN_TYPE, null, mCallingActivity, null, null, null, null);
+        Bundle bnd = future.getResult();
+        String auth_token = bnd.getString(AccountManager.KEY_AUTHTOKEN);
+        String account_name = bnd.getString(AccountManager.KEY_ACCOUNT_NAME);
+        Log.d(TAG, tag+"account_name="+account_name+" token="+auth_token);
+
+        boolean auth = false;
         if (auth) {
 
             SharedPreferences sharedPreferences = PreferenceManager
@@ -210,7 +221,6 @@ public class ScheduledIntentService extends IntentService {
 
             Log.d(TAG, "set last service update date " + lastUpdateServiceDate);
         }
-
+        */
     }
-
 }
index f2d53b7..9ed161c 100644 (file)
@@ -108,66 +108,12 @@ public class ApplicationPreferences extends PreferenceActivity implements
 
             @Override
             public void run() {
-
-                boolean routeToAddress = true;
-                AccountAccess account = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress);
-
-                if (routeToAddress) {
-                    try {
-                        if (account.authenticate()) {
-
-                            runOnUiThread(new Runnable() {
-
-                                @Override
-                                public void run() {
-                                    if (reference != null) {
-                                        progressDialog.dismiss();
-                                        Toast.makeText(
-                                                context,
-                                                "Autenthication successfully established :"
-                                                        + GlobalConfigs.httpAddress,
-                                                Toast.LENGTH_LONG).show();
-                                    }
-                                }
-                            });
-                        } else {
-                            runOnUiThread(new Runnable() {
-
-                                @Override
-                                public void run() {
-                                    if (reference != null) {
-                                        progressDialog.dismiss();
-                                        Toast.makeText(
-                                                context,
-                                                "Please check username and password ",
-                                                Toast.LENGTH_LONG).show();
-                                    }
-                                }
-                            });
-                        }
-
-                    } catch (Exception e) {
-                    }
-
-                } else
-                    runOnUiThread(new Runnable() {
-
-                        @Override
-                        public void run() {
-                            if (reference != null)
-                                progressDialog.dismiss();
-                        }
-                    });
             }
         });
 
         boolean checkConnection = false;
 
-        if (key.equals("username")) {
-            AccountAccess.userName = sharedPreferences
-                    .getString("username", "");
-            checkConnection = true;
-        } else if (key.equals("library_url")) {
+        if (key.equals("library_url")) {
             checkConnection = true;
             GlobalConfigs.httpAddress = sharedPreferences.getString(
                     "library_url", "");
@@ -246,18 +192,6 @@ public class ApplicationPreferences extends PreferenceActivity implements
                 // cancel the service
                 am.cancel(sender);
             }
-            // register the
-
-        }
-
-        // test connection
-        if (!isFinishing() && httpAddressChange == false
-                && checkConnection == true) {
-            progressDialog = ProgressDialog
-                    .show(this, "Account login",
-                            "Signing in with new credentials");
-
-            connectionThread.start();
         }
     }
 
index f37f127..635d889 100644 (file)
@@ -55,21 +55,14 @@ public class ConfigureApplicationActivity extends Activity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
-        // TODO Auto-generated method stub
         super.onCreate(savedInstanceState);
         setContentView(R.layout.configure_application);
         context = this;
         server_http = (EditText) findViewById(R.id.server_http_adress);
-        username = (EditText) findViewById(R.id.username);
-        password = (EditText) findViewById(R.id.password);
-
-        
-        SharedPreferences preferences = PreferenceManager
-                .getDefaultSharedPreferences(context);
-        username.setText(preferences.getString("username", ""));
-        server_http.setText(preferences.getString("library_url", "https://bark.cwmars.org"));  
-        password.setText(preferences.getString("password", ""));
-        
+
+        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+        server_http.setText(preferences.getString("library_url", "https://bark.cwmars.org"));
+
         Button connect = (Button) findViewById(R.id.connect_button);
 
         connect.setOnClickListener(new OnClickListener() {
@@ -89,34 +82,19 @@ public class ConfigureApplicationActivity extends Activity {
                                         .getText().toString());
 
                         if (server_address == true) {
-                            
-                            SharedPreferences preferences = PreferenceManager
-                                    .getDefaultSharedPreferences(context);
-                            SharedPreferences.Editor editor = preferences
-                                    .edit();
-                            // store into preference
-                            editor.putString("library_url", server_http
-                                    .getText().toString());
-                            
-                            editor.putString("username", username.getText()
-                                    .toString());
-                            editor.putString("password", password.getText()
-                                    .toString());
-
+                            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+                            SharedPreferences.Editor editor = preferences.edit();
+                            editor.putString("library_url", server_http.getText().toString());
                             editor.commit();
-                            GlobalConfigs.httpAddress = server_http.getText()
-                                    .toString();
+                            GlobalConfigs.httpAddress = server_http.getText().toString();
                             AccountAccess accountAccess = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress);
                             try {
-                                auth = accountAccess.authenticate();
-                                Log.d(TAG, "Auth " + auth);
+                                auth = accountAccess.reauthenticate(ConfigureApplicationActivity.this);
                             } catch (Exception e) {
-                                System.out.println("Exception "
-                                        + e.getMessage());
+                                Log.w(TAG, "caught", e);
                             }
 
                             if (auth == true) {
-
                                 runOnUiThread(new Runnable() {
 
                                     @Override
@@ -124,7 +102,6 @@ public class ConfigureApplicationActivity extends Activity {
                                         progressDialog.dismiss();
                                         setResult(RESULT_CONFIGURE_SUCCESS);
                                         finish();
-
                                     }
                                 });
 
@@ -150,9 +127,7 @@ public class ConfigureApplicationActivity extends Activity {
                                             Toast.LENGTH_LONG).show();
                                 }
                             });
-
                         }
-
                     }
                 });
 
@@ -162,7 +137,5 @@ public class ConfigureApplicationActivity extends Activity {
             }
 
         });
-
     }
-
 }
index 13242db..4c6d506 100644 (file)
@@ -87,6 +87,7 @@ public class LoadingTask {
         });
     }
 
+    //TODO: share some of this code with ScheduledIntentService.onHandleIntent
     protected String doInBackground() {
         final String tag ="doInBackground> "; 
         Log.d(TAG, tag);
index b451dc4..b10ebd2 100644 (file)
@@ -75,7 +75,7 @@ public class EvergreenAuthenticator {
 
         HttpConnection conn;
         try {
-            conn = new HttpConnection(context.getString(R.string.ou_gateway_url));
+            conn = new HttpConnection(context.getString(R.string.ou_library_url) + "/osrf-gateway-v1");
         } catch (MalformedURLException e) {
             throw new AuthenticationException(e);
         }