* #38608: fix null field, load android contact in history

Android contact id is retrieved from the history database, and is linked to the
history view.
diff --git a/src/org/sflphone/client/CallActivity.java b/src/org/sflphone/client/CallActivity.java
index 1d56564..faf5c04 100644
--- a/src/org/sflphone/client/CallActivity.java
+++ b/src/org/sflphone/client/CallActivity.java
@@ -88,7 +88,6 @@
     CallFragment mCurrentCallFragment;
 
 
-
     /* result code sent in case of call failure */
     public static int RESULT_FAILURE = -10;
     private CallProximityManager mProximityManager;
@@ -162,8 +161,6 @@
         public void run() {
             if (mCurrentCallFragment != null)
                 mCurrentCallFragment.updateTime();
-            // mCallsFragment.update();
-
             mHandler.postAtTime(this, SystemClock.uptimeMillis() + 1000);
         }
     };
@@ -196,7 +193,9 @@
         super.onDestroy();
     }
 
-    /** Defines callbacks for service binding, passed to bindService() */
+    /**
+     * Defines callbacks for service binding, passed to bindService()
+     */
     private ServiceConnection mConnection = new ServiceConnection() {
         @SuppressWarnings("unchecked")
         @Override
@@ -264,14 +263,6 @@
         }
     };
 
-/*    @Override
-    public void incomingCall(Intent call) {
-        mCurrentCallFragment = new CallFragment();
-        mCurrentCallFragment.setArguments(call.getExtras());
-        getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
-        mSlidingPaneLayout.setCurFragment(mCurrentCallFragment);
-    }*/
-
     @Override
     public void callStateChanged(Intent callState) {
 
@@ -330,6 +321,8 @@
 
     @Override
     public void recordingChanged(Intent intent) {
+
+        Log.i(TAG, "RECORDING CHANGED");
     }
 
     @Override
diff --git a/src/org/sflphone/history/HistoryCall.java b/src/org/sflphone/history/HistoryCall.java
index 4d26391..ac13f48 100644
--- a/src/org/sflphone/history/HistoryCall.java
+++ b/src/org/sflphone/history/HistoryCall.java
@@ -64,7 +64,7 @@
     @DatabaseField
     long contactID;
     @DatabaseField
-    long callID;
+    String callID;
 
     public String getAccountID() {
         return accountID;
@@ -77,10 +77,13 @@
     public HistoryCall(SipCall call) {
         call_start = call.getTimestampStart_();
         call_end = call.getTimestampEnd_();
+        accountID = call.getAccount().getAccountID();
         number = call.getContact().getPhones().get(0).getNumber();
         missed = call.isRinging() || call.isIncoming();
         direction = call.getCallTypeString();
         recordPath = call.getRecordPath();
+        contactID = call.getContact().getId();
+        callID = call.getCallId();
     }
 
     /* Needed by ORMLite */
@@ -145,7 +148,7 @@
         dest.writeString(direction);
         dest.writeString(recordPath);
         dest.writeLong(contactID);
-        dest.writeLong(callID);
+        dest.writeString(callID);
     }
 
     public static final Parcelable.Creator<HistoryCall> CREATOR = new Parcelable.Creator<HistoryCall>() {
@@ -167,7 +170,7 @@
         direction = in.readString();
         recordPath = in.readString();
         contactID = in.readLong();
-        callID = in.readLong();
+        callID = in.readString();
     }
 
     public boolean hasRecord() {
diff --git a/src/org/sflphone/loaders/HistoryLoader.java b/src/org/sflphone/loaders/HistoryLoader.java
index 4610104..34e9bae 100644
--- a/src/org/sflphone/loaders/HistoryLoader.java
+++ b/src/org/sflphone/loaders/HistoryLoader.java
@@ -83,6 +83,7 @@
 
                     if (result.moveToFirst()) {
                         builder.startNewContact(result.getLong(iID), result.getString(iName), result.getLong(iPhoto));
+                        builder.addPhoneNumber(call.getNumber(), 0);
                         contact = builder.build();
                     } else {
                         contact = CallContact.ContactBuilder.buildUnknownContact(call.getNumber());
diff --git a/src/org/sflphone/model/CallContact.java b/src/org/sflphone/model/CallContact.java
index 50c054b..72de384 100644
--- a/src/org/sflphone/model/CallContact.java
+++ b/src/org/sflphone/model/CallContact.java
@@ -127,7 +127,6 @@
         ArrayList<Phone> phones;
         ArrayList<Phone> sip;
         String contactMail;
-        boolean hasPhoto;
 
         public ContactBuilder startNewContact(long id, String displayName, long photo_id) {
             contactID = id;
@@ -167,7 +166,7 @@
         public static CallContact buildUserContact(ContentResolver cr) {
             String[] mProjection = new String[] { Profile._ID, Profile.DISPLAY_NAME_PRIMARY, Profile.PHOTO_ID };
             Cursor mProfileCursor = cr.query(Profile.CONTENT_URI, mProjection, null, null, null);
-            CallContact result = null;
+            CallContact result;
             if (mProfileCursor.getCount() > 0) {
                 mProfileCursor.moveToFirst();
                 String displayName = mProfileCursor.getString(mProfileCursor.getColumnIndex(Profile.DISPLAY_NAME_PRIMARY));
diff --git a/src/org/sflphone/model/SipCall.java b/src/org/sflphone/model/SipCall.java
index f2798ff..a1f4a1e 100644
--- a/src/org/sflphone/model/SipCall.java
+++ b/src/org/sflphone/model/SipCall.java
@@ -96,7 +96,6 @@
 
     public interface state {
         public static final int CALL_STATE_NONE = 0;
-        public static final int CALL_STATE_INCOMING = 1;
         public static final int CALL_STATE_RINGING = 2;
         public static final int CALL_STATE_CURRENT = 3;
         public static final int CALL_STATE_HUNGUP = 4;
@@ -198,9 +197,6 @@
         String text_state;
 
         switch (mCallState) {
-            case state.CALL_STATE_INCOMING:
-                text_state = "INCOMING";
-                break;
             case state.CALL_STATE_RINGING:
                 text_state = "RINGING";
                 break;
@@ -337,9 +333,7 @@
     }
 
     public void setCallState(String newState) {
-        if (newState.equals("INCOMING")) {
-            setCallState(SipCall.state.CALL_STATE_INCOMING);
-        } else if (newState.equals("RINGING")) {
+        if (newState.equals("RINGING")) {
             setCallState(SipCall.state.CALL_STATE_RINGING);
         } else if (newState.equals("CURRENT")) {
             setCallState(SipCall.state.CALL_STATE_CURRENT);
diff --git a/src/org/sflphone/service/CallManagerCallBack.java b/src/org/sflphone/service/CallManagerCallBack.java
index dcbc084..de06377 100644
--- a/src/org/sflphone/service/CallManagerCallBack.java
+++ b/src/org/sflphone/service/CallManagerCallBack.java
@@ -39,9 +39,10 @@
         intent.putExtra("com.savoirfairelinux.sflphone.service.newstate", bundle);
 
 
-        if (newState.equals("INCOMING")) {
+        /*if (newState.equals("INCOMING")) {
             mService.getConferences().get(callID).setCallState(callID, SipCall.state.CALL_STATE_INCOMING);
-        } else if (newState.equals("RINGING")) {
+        } else*/
+        if (newState.equals("RINGING")) {
             try {
                 mService.getConferences().get(callID).setCallState(callID, SipCall.state.CALL_STATE_RINGING);
             } catch (NullPointerException e) {