* #38608: removes IncomingReceiver, use Fragment instead of compatibility ones
diff --git a/src/org/sflphone/adapters/SectionsPagerAdapter.java b/src/org/sflphone/adapters/SectionsPagerAdapter.java
index 234e486..485c005 100644
--- a/src/org/sflphone/adapters/SectionsPagerAdapter.java
+++ b/src/org/sflphone/adapters/SectionsPagerAdapter.java
@@ -34,6 +34,8 @@
 import java.util.ArrayList;
 import java.util.Locale;
 
+import android.app.Fragment;
+import android.app.FragmentManager;
 import org.sflphone.R;
 import org.sflphone.fragments.CallListFragment;
 import org.sflphone.fragments.DialingFragment;
@@ -42,11 +44,9 @@
 
 import android.content.Context;
 import android.os.RemoteException;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
 import android.util.Log;
 
-public class SectionsPagerAdapter extends android.support.v4.app.FragmentStatePagerAdapter implements PagerSlidingTabStrip.IconTabProvider {
+public class SectionsPagerAdapter extends android.support.v13.app.FragmentStatePagerAdapter implements PagerSlidingTabStrip.IconTabProvider {
 
     private static final String TAG = SectionsPagerAdapter.class.getSimpleName();
     Context mContext;
diff --git a/src/org/sflphone/client/HomeActivity.java b/src/org/sflphone/client/HomeActivity.java
index 694bfd0..7abceb5 100644
--- a/src/org/sflphone/client/HomeActivity.java
+++ b/src/org/sflphone/client/HomeActivity.java
@@ -40,7 +40,9 @@
 import java.util.Timer;
 import java.util.TimerTask;
 
-import android.support.v4.app.*;
+import android.app.*;
+import android.support.v4.app.ActionBarDrawerToggle;
+import android.support.v4.app.FragmentActivity;
 import org.sflphone.R;
 import org.sflphone.fragments.AboutFragment;
 import org.sflphone.fragments.AccountsManagementFragment;
@@ -61,8 +63,6 @@
 import org.sflphone.views.SlidingUpPanelLayout;
 import org.sflphone.views.SlidingUpPanelLayout.PanelSlideListener;
 
-import android.app.Activity;
-import android.app.AlertDialog;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -80,7 +80,6 @@
 import android.provider.ContactsContract;
 import android.provider.ContactsContract.CommonDataKinds.Phone;
 import android.provider.ContactsContract.CommonDataKinds.SipAddress;
-import android.support.v4.app.FragmentManager.BackStackEntry;
 import android.support.v4.view.GravityCompat;
 import android.support.v4.widget.DrawerLayout;
 import android.util.Log;
@@ -322,7 +321,7 @@
             return;
         }
 
-        if (getSupportFragmentManager().getBackStackEntryCount() > 1) {
+        if (getFragmentManager().getBackStackEntryCount() > 1) {
             popCustomBackStack();
             fMenu.backToHome();
             return;
@@ -345,9 +344,9 @@
     }
 
     private void popCustomBackStack() {
-        BackStackEntry entry = getSupportFragmentManager().getBackStackEntryAt(0);
-        fContent = getSupportFragmentManager().findFragmentByTag(entry.getName());
-        FragmentManager fm = getSupportFragmentManager();
+        FragmentManager.BackStackEntry entry = getFragmentManager().getBackStackEntryAt(0);
+        fContent = getFragmentManager().findFragmentByTag(entry.getName());
+        FragmentManager fm = getFragmentManager();
         for (int i = 0; i < fm.getBackStackEntryCount() - 1; ++i) {
             fm.popBackStack();
         }
@@ -402,8 +401,8 @@
 
                 fMenu = new MenuFragment();
                 fContent = new HomeFragment();
-                getSupportFragmentManager().beginTransaction().replace(R.id.left_drawer, fMenu).commit();
-                getSupportFragmentManager().beginTransaction().replace(R.id.main_frame, fContent, "Home").addToBackStack("Home").commit();
+                getFragmentManager().beginTransaction().replace(R.id.left_drawer, fMenu).commit();
+                getFragmentManager().beginTransaction().replace(R.id.main_frame, fContent, "Home").addToBackStack("Home").commit();
 
                 service.destroyNotification();
             } catch (RemoteException e) {
@@ -689,7 +688,7 @@
                 if (fContent instanceof HomeFragment)
                     break;
 
-                if (getSupportFragmentManager().getBackStackEntryCount() == 1)
+                if (getFragmentManager().getBackStackEntryCount() == 1)
                     break;
 
                 popCustomBackStack();
@@ -699,13 +698,13 @@
                 if (fContent instanceof AccountsManagementFragment)
                     break;
                 fContent = new AccountsManagementFragment();
-                getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).replace(R.id.main_frame, fContent, "Accounts").addToBackStack("Accounts").commit();
+                getFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).replace(R.id.main_frame, fContent, "Accounts").addToBackStack("Accounts").commit();
                 break;
             case 2:
                 if (fContent instanceof AboutFragment)
                     break;
                 fContent = new AboutFragment();
-                getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).replace(R.id.main_frame, fContent, "About").addToBackStack("About").commit();
+                getFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).replace(R.id.main_frame, fContent, "About").addToBackStack("About").commit();
                 break;
         }
 
diff --git a/src/org/sflphone/fragments/AboutFragment.java b/src/org/sflphone/fragments/AboutFragment.java
index d2d3865..3a84c99 100644
--- a/src/org/sflphone/fragments/AboutFragment.java
+++ b/src/org/sflphone/fragments/AboutFragment.java
@@ -3,7 +3,7 @@
 import org.sflphone.R;
 
 import android.os.Bundle;
-import android.support.v4.app.Fragment;
+import android.app.Fragment;
 import android.text.Html;
 import android.text.method.LinkMovementMethod;
 import android.view.LayoutInflater;
diff --git a/src/org/sflphone/fragments/AccountsManagementFragment.java b/src/org/sflphone/fragments/AccountsManagementFragment.java
index 042f6fe..49289a8 100644
--- a/src/org/sflphone/fragments/AccountsManagementFragment.java
+++ b/src/org/sflphone/fragments/AccountsManagementFragment.java
@@ -35,6 +35,9 @@
 import java.io.File;
 import java.util.ArrayList;
 
+import android.app.ListFragment;
+import android.app.LoaderManager;
+import android.content.*;
 import org.sflphone.R;
 import org.sflphone.client.AccountEditionActivity;
 import org.sflphone.client.AccountWizard;
@@ -50,13 +53,8 @@
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
 import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
 import android.os.Bundle;
 import android.os.RemoteException;
-import android.support.v4.app.ListFragment;
-import android.support.v4.app.LoaderManager.LoaderCallbacks;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.Menu;
@@ -72,7 +70,7 @@
 import android.widget.ListView;
 import android.widget.TextView;
 
-public class AccountsManagementFragment extends ListFragment implements LoaderCallbacks<Bundle>, AccountsInterface {
+public class AccountsManagementFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Bundle>, AccountsInterface {
     static final String TAG = "AccountManagementFragment";
     static final String DEFAULT_ACCOUNT_ID = "IP2IP";
     static final int ACCOUNT_CREATE_REQUEST = 1;
@@ -422,8 +420,16 @@
         });
     }
 
+
     @Override
-    public void onLoadFinished(android.support.v4.content.Loader<Bundle> arg0, Bundle results) {
+    public AsyncTaskLoader<Bundle> onCreateLoader(int arg0, Bundle arg1) {
+        AccountsLoader l = new AccountsLoader(getActivity(), mCallbacks.getService());
+        l.forceLoad();
+        return l;
+    }
+
+    @Override
+    public void onLoadFinished(Loader<Bundle> loader, Bundle results) {
         mAccountsAdapter.removeAll();
         ArrayList<Account> tmp = results.getParcelableArrayList(AccountsLoader.ACCOUNTS);
         ip2ip = results.getParcelable(AccountsLoader.ACCOUNT_IP2IP);
@@ -437,14 +443,7 @@
     }
 
     @Override
-    public void onLoaderReset(android.support.v4.content.Loader<Bundle> arg0) {
+    public void onLoaderReset(Loader<Bundle> loader) {
 
     }
-
-    @Override
-    public android.support.v4.content.Loader<Bundle> onCreateLoader(int arg0, Bundle arg1) {
-        AccountsLoader l = new AccountsLoader(getActivity(), mCallbacks.getService());
-        l.forceLoad();
-        return l;
-    }
 }
diff --git a/src/org/sflphone/fragments/CallListFragment.java b/src/org/sflphone/fragments/CallListFragment.java
index d838d41..7bfa23f 100644
--- a/src/org/sflphone/fragments/CallListFragment.java
+++ b/src/org/sflphone/fragments/CallListFragment.java
@@ -52,7 +52,7 @@
 import android.os.RemoteException;
 import android.os.SystemClock;
 import android.os.Vibrator;
-import android.support.v4.app.Fragment;
+import android.app.Fragment;
 import android.util.Log;
 import android.view.DragEvent;
 import android.view.LayoutInflater;
diff --git a/src/org/sflphone/fragments/DetailsHistoryEntryFragment.java b/src/org/sflphone/fragments/DetailsHistoryEntryFragment.java
index c5ca432..2576bfa 100644
--- a/src/org/sflphone/fragments/DetailsHistoryEntryFragment.java
+++ b/src/org/sflphone/fragments/DetailsHistoryEntryFragment.java
@@ -38,9 +38,9 @@
 
 import org.sflphone.R;
 import org.sflphone.adapters.ContactPictureTask;
+import org.sflphone.history.HistoryCall;
 import org.sflphone.model.Account;
-import org.sflphone.model.HistoryEntry;
-import org.sflphone.model.HistoryEntry.HistoryCall;
+import org.sflphone.history.HistoryEntry;
 import org.sflphone.model.SipCall;
 import org.sflphone.service.ISipService;
 import org.sflphone.views.parallaxscrollview.AnotherView;
@@ -129,8 +129,6 @@
     public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
         View inflatedView = inflater.inflate(R.layout.frag_history_detail, parent, false);
 
-        // mheaderView = LayoutInflater.from(getActivity()).inflate(R.layout.history_detail_header, null);
-
         llMain = (LinearLayout) inflatedView.findViewById(R.id.llMain);
         llMainHolder = (LinearLayout) inflatedView.findViewById(R.id.llMainHolder);
         lvMain = (ListView) inflatedView.findViewById(R.id.lvMain);
diff --git a/src/org/sflphone/fragments/DialingFragment.java b/src/org/sflphone/fragments/DialingFragment.java
index b7e27d7..762cf7b 100644
--- a/src/org/sflphone/fragments/DialingFragment.java
+++ b/src/org/sflphone/fragments/DialingFragment.java
@@ -41,7 +41,7 @@
 import android.content.Context;
 import android.os.Bundle;
 import android.os.RemoteException;
-import android.support.v4.app.Fragment;
+import android.app.Fragment;
 import android.text.Editable;
 import android.text.TextWatcher;
 import android.view.KeyEvent;
diff --git a/src/org/sflphone/fragments/DropActionsChoice.java b/src/org/sflphone/fragments/DropActionsChoice.java
index a8a608a..e181304 100644
--- a/src/org/sflphone/fragments/DropActionsChoice.java
+++ b/src/org/sflphone/fragments/DropActionsChoice.java
@@ -38,7 +38,7 @@
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
+import android.app.DialogFragment;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemClickListener;
diff --git a/src/org/sflphone/fragments/HistoryFragment.java b/src/org/sflphone/fragments/HistoryFragment.java
index f2366e8..0ab1712 100644
--- a/src/org/sflphone/fragments/HistoryFragment.java
+++ b/src/org/sflphone/fragments/HistoryFragment.java
@@ -34,6 +34,8 @@
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
+import android.content.AsyncTaskLoader;
+import android.content.Loader;
 import android.view.*;
 import org.sflphone.R;
 import org.sflphone.adapters.ContactPictureTask;
@@ -48,8 +50,8 @@
 import android.content.Intent;
 import android.os.Bundle;
 import android.os.RemoteException;
-import android.support.v4.app.ListFragment;
-import android.support.v4.app.LoaderManager.LoaderCallbacks;
+import android.app.ListFragment;
+import android.app.LoaderManager.LoaderCallbacks;
 import android.util.Log;
 import android.view.View.OnClickListener;
 import android.widget.AdapterView;
@@ -99,6 +101,7 @@
         }
 
         mCallbacks = (Callbacks) activity;
+
     }
 
     @Override
@@ -296,23 +299,23 @@
     }
 
     @Override
-    public android.support.v4.content.Loader<ArrayList<HistoryEntry>> onCreateLoader(int arg0, Bundle arg1) {
-        HistoryLoader loader = new HistoryLoader(getActivity(), mCallbacks.getService());
+    public AsyncTaskLoader<ArrayList<HistoryEntry>> onCreateLoader(int arg0, Bundle arg1) {
+        HistoryLoader loader = new HistoryLoader(getActivity());
         loader.forceLoad();
         return loader;
     }
 
     @Override
-    public void onLoadFinished(android.support.v4.content.Loader<ArrayList<HistoryEntry>> arg0, ArrayList<HistoryEntry> history) {
+    public void onLoadFinished(Loader<ArrayList<HistoryEntry>> loader, ArrayList<HistoryEntry> data) {
         mAdapter.clear();
-        mAdapter.addAll(history);
+        mAdapter.addAll(data);
         mAdapter.notifyDataSetChanged();
     }
 
     @Override
-    public void onLoaderReset(android.support.v4.content.Loader<ArrayList<HistoryEntry>> arg0) {
-        // TODO Stub de la méthode généré automatiquement
+    public void onLoaderReset(Loader<ArrayList<HistoryEntry>> loader) {
 
     }
 
+
 }
diff --git a/src/org/sflphone/fragments/HomeFragment.java b/src/org/sflphone/fragments/HomeFragment.java
index 29b302a..c5a073c 100644
--- a/src/org/sflphone/fragments/HomeFragment.java
+++ b/src/org/sflphone/fragments/HomeFragment.java
@@ -37,7 +37,7 @@
 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
-import android.support.v4.app.Fragment;
+import android.app.Fragment;
 import android.support.v4.view.ViewPager;
 import android.view.LayoutInflater;
 import android.view.View;
diff --git a/src/org/sflphone/fragments/MenuFragment.java b/src/org/sflphone/fragments/MenuFragment.java
index 3b1692f..1ed66da 100644
--- a/src/org/sflphone/fragments/MenuFragment.java
+++ b/src/org/sflphone/fragments/MenuFragment.java
@@ -32,6 +32,9 @@
 
 import java.util.ArrayList;
 
+import android.app.LoaderManager;
+import android.content.AsyncTaskLoader;
+import android.content.Loader;
 import org.sflphone.R;
 import org.sflphone.adapters.AccountSelectionAdapter;
 import org.sflphone.adapters.ContactPictureTask;
@@ -50,8 +53,7 @@
 import android.os.Bundle;
 import android.os.RemoteException;
 import android.provider.ContactsContract.Profile;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.LoaderManager.LoaderCallbacks;
+import android.app.Fragment;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -64,7 +66,7 @@
 import android.widget.Spinner;
 import android.widget.TextView;
 
-public class MenuFragment extends Fragment implements LoaderCallbacks<Bundle>, AccountsInterface {
+public class MenuFragment extends Fragment implements LoaderManager.LoaderCallbacks<Bundle>, AccountsInterface {
 
     @SuppressWarnings("unused")
     private static final String TAG = MenuFragment.class.getSimpleName();
@@ -224,23 +226,21 @@
     }
 
     @Override
-    public android.support.v4.content.Loader<Bundle> onCreateLoader(int arg0, Bundle arg1) {
+    public AsyncTaskLoader<Bundle> onCreateLoader(int arg0, Bundle arg1) {
         AccountsLoader l = new AccountsLoader(getActivity(), mCallbacks.getService());
         l.forceLoad();
         return l;
     }
 
     @Override
-    public void onLoadFinished(android.support.v4.content.Loader<Bundle> arg0, Bundle bun) {
+    public void onLoadFinished(Loader<Bundle> loader, Bundle data) {
         mAccountAdapter.removeAll();
-        ArrayList<Account> accounts = bun.getParcelableArrayList(AccountsLoader.ACCOUNTS);
+        ArrayList<Account> accounts = data.getParcelableArrayList(AccountsLoader.ACCOUNTS);
         mAccountAdapter.addAll(accounts);
-
     }
 
     @Override
-    public void onLoaderReset(android.support.v4.content.Loader<Bundle> arg0) {
-        // TODO Stub de la méthode généré automatiquement
+    public void onLoaderReset(Loader<Bundle> loader) {
 
     }
 
diff --git a/src/org/sflphone/history/HistoryCall.java b/src/org/sflphone/history/HistoryCall.java
index 27b4716..af029bb 100644
--- a/src/org/sflphone/history/HistoryCall.java
+++ b/src/org/sflphone/history/HistoryCall.java
@@ -1,7 +1,198 @@
+/*
+ *  Copyright (C) 2004-2014 Savoir-Faire Linux Inc.
+ *
+ *  Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Additional permission under GNU GPL version 3 section 7:
+ *
+ *  If you modify this program, or any covered work, by linking or
+ *  combining it with the OpenSSL project's OpenSSL library (or a
+ *  modified version of that library), containing parts covered by the
+ *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ *  grants you additional permission to convey the resulting work.
+ *  Corresponding Source for a non-source form of such a combination
+ *  shall include the source code for the parts of OpenSSL used as well
+ *  as that of the covered work.
+ */
+
+
 package org.sflphone.history;
 
-/**
- * Created by lisional on 14/01/14.
- */
-public class HistoryCall {
+import android.os.Parcel;
+import android.os.Parcelable;
+import com.j256.ormlite.field.DatabaseField;
+import org.sflphone.service.ServiceConstants;
+
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.TimeZone;
+
+public class HistoryCall implements Parcelable {
+
+    public long getCallStart() {
+        return call_start;
+    }
+
+    @DatabaseField(index = true)
+    long call_start;
+    @DatabaseField
+    long call_end;
+    @DatabaseField
+    String number;
+    @DatabaseField
+    boolean missed;
+    @DatabaseField
+    String direction;
+    @DatabaseField
+    String recordPath;
+    @DatabaseField
+    String timeFormatted;
+
+    public String getAccountID() {
+        return accountID;
+    }
+
+    @DatabaseField
+    String accountID;
+
+    public long getContactID() {
+        return contactID;
+    }
+
+    @DatabaseField
+    long contactID;
+    @DatabaseField
+    long callID;
+
+    public HistoryCall(HashMap<String, String> entry) {
+        call_end = Long.parseLong(entry.get(ServiceConstants.history.TIMESTAMP_STOP_KEY));
+        call_start = Long.parseLong(entry.get(ServiceConstants.history.TIMESTAMP_START_KEY));
+        accountID = entry.get(ServiceConstants.history.ACCOUNT_ID_KEY);
+
+        direction = entry.get(ServiceConstants.history.DIRECTION_KEY);
+        missed = entry.get(ServiceConstants.history.MISSED_KEY).contentEquals("true");
+
+        recordPath = entry.get(ServiceConstants.history.RECORDING_PATH_KEY);
+        number = entry.get(ServiceConstants.history.PEER_NUMBER_KEY);
+        timeFormatted = HistoryTimeModel.timeToHistoryConst(call_start);
+    }
+
+    /* Needed by ORMLite */
+    public HistoryCall() {
+    }
+
+    public String getDirection() {
+        return direction;
+    }
+
+    public String getDate() {
+        return timeFormatted;
+    }
+
+    public String getStartString(String format) {
+        Timestamp stamp = new Timestamp(call_start * 1000); // in milliseconds
+        Date date = new Date(stamp.getTime());
+        SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.getDefault());
+        sdf.setTimeZone(TimeZone.getDefault());
+        String formattedDate = sdf.format(date);
+        return formattedDate;
+
+    }
+
+    public String getDurationString() {
+
+        long duration = call_end - call_start;
+        if (duration < 60)
+            return String.format(Locale.getDefault(), "%02d secs", duration);
+
+        if (duration < 3600)
+            return String.format(Locale.getDefault(), "%02d mins %02d secs", (duration % 3600) / 60, (duration % 60));
+
+        return String.format(Locale.getDefault(), "%d h %02d mins %02d secs", duration / 3600, (duration % 3600) / 60, (duration % 60));
+
+    }
+
+    public long getDuration() {
+        return call_end - call_start;
+    }
+
+    public String getRecordPath() {
+        return recordPath;
+    }
+
+    public String getNumber() {
+        return number;
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeLong(call_start);
+        dest.writeLong(call_end);
+        dest.writeString(accountID);
+        dest.writeString(number);
+        dest.writeByte((byte) (missed ? 1 : 0));
+        dest.writeString(direction);
+        dest.writeString(recordPath);
+        dest.writeString(timeFormatted);
+        dest.writeLong(contactID);
+        dest.writeLong(callID);
+    }
+
+    public static final Parcelable.Creator<HistoryCall> CREATOR = new Parcelable.Creator<HistoryCall>() {
+        public HistoryCall createFromParcel(Parcel in) {
+            return new HistoryCall(in);
+        }
+
+        public HistoryCall[] newArray(int size) {
+            return new HistoryCall[size];
+        }
+    };
+
+    private HistoryCall(Parcel in) {
+        call_start = in.readLong();
+        call_end = in.readLong();
+        accountID = in.readString();
+        number = in.readString();
+        missed = in.readByte() == 1 ? true : false;
+        direction = in.readString();
+        recordPath = in.readString();
+        timeFormatted = in.readString();
+        contactID = in.readLong();
+        callID = in.readLong();
+    }
+
+    public boolean hasRecord() {
+        return recordPath.length() > 0;
+    }
+
+    public boolean isIncoming() {
+        return direction.contentEquals(ServiceConstants.history.INCOMING_STRING);
+    }
+
+    public boolean isMissed() {
+        return missed;
+    }
+
 }
diff --git a/src/org/sflphone/history/HistoryEntry.java b/src/org/sflphone/history/HistoryEntry.java
index 3003750..c2ef036 100644
--- a/src/org/sflphone/history/HistoryEntry.java
+++ b/src/org/sflphone/history/HistoryEntry.java
@@ -31,21 +31,13 @@
 
 package org.sflphone.history;
 
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.NavigableMap;
-import java.util.TimeZone;
-import java.util.TreeMap;
-
-import org.sflphone.model.CallContact;
-import org.sflphone.service.ServiceConstants;
-
 import android.os.Parcel;
 import android.os.Parcelable;
+import org.sflphone.model.CallContact;
+
+import java.util.ArrayList;
+import java.util.NavigableMap;
+import java.util.TreeMap;
 
 public class HistoryEntry implements Parcelable {
 
@@ -58,7 +50,7 @@
 
     public HistoryEntry(String account, CallContact c) {
         contact = c;
-        calls = new TreeMap<Long, HistoryEntry.HistoryCall>();
+        calls = new TreeMap<Long, HistoryCall>();
         accountID = account;
         missed_sum = outgoing_sum = incoming_sum = 0;
     }
@@ -85,10 +77,11 @@
 
     /**
      * Each call is associated with a contact.
-     * When adding a call to an HIstoryEntry, this methods also verifies if we can update 
+     * When adding a call to an HIstoryEntry, this methods also verifies if we can update
      * the contact (if contact is Unknown, replace it)
-     * @param historyCall The call to put in this HistoryEntry 
-     * @param linkedTo The associated CallContact
+     *
+     * @param historyCall The call to put in this HistoryEntry
+     * @param linkedTo    The associated CallContact
      */
     public void addHistoryCall(HistoryCall historyCall, CallContact linkedTo) {
         calls.put(historyCall.call_start, historyCall);
@@ -99,8 +92,8 @@
         }
         if (historyCall.isMissed())
             missed_sum++;
-        
-        if(contact.isUnknown() && !linkedTo.isUnknown())
+
+        if (contact.isUnknown() && !linkedTo.isUnknown())
             setContact(linkedTo);
     }
 
@@ -110,7 +103,7 @@
 
     public String getTotalDuration() {
         int duration = 0;
-        ArrayList<HistoryCall> all_calls = new ArrayList<HistoryEntry.HistoryCall>(calls.values());
+        ArrayList<HistoryCall> all_calls = new ArrayList<HistoryCall>(calls.values());
         for (int i = 0; i < all_calls.size(); ++i) {
             duration += all_calls.get(i).getDuration();
         }
@@ -166,13 +159,13 @@
     private HistoryEntry(Parcel in) {
         contact = in.readParcelable(CallContact.class.getClassLoader());
 
-        ArrayList<HistoryCall> values = new ArrayList<HistoryEntry.HistoryCall>();
+        ArrayList<HistoryCall> values = new ArrayList<HistoryCall>();
         in.readList(values, HistoryCall.class.getClassLoader());
 
         ArrayList<Long> keys = new ArrayList<Long>();
         in.readList(keys, Long.class.getClassLoader());
 
-        calls = new TreeMap<Long, HistoryEntry.HistoryCall>();
+        calls = new TreeMap<Long, HistoryCall>();
         for (int i = 0; i < keys.size(); ++i) {
             calls.put(keys.get(i), values.get(i));
         }
@@ -183,138 +176,4 @@
         incoming_sum = in.readInt();
     }
 
-    public static class HistoryCall implements Parcelable {
-        long call_start;
-        long call_end;
-        String number;
-
-        boolean missed;
-        String direction;
-
-        String recordPath;
-        String timeFormatted;
-        String displayName;
-
-        String accountID;
-
-        long contactID;
-
-        public HistoryCall(HashMap<String, String> entry) {
-            call_end = Long.parseLong(entry.get(ServiceConstants.history.TIMESTAMP_STOP_KEY));
-            call_start = Long.parseLong(entry.get(ServiceConstants.history.TIMESTAMP_START_KEY));
-            accountID = entry.get(ServiceConstants.history.ACCOUNT_ID_KEY);
-
-            direction = entry.get(ServiceConstants.history.DIRECTION_KEY);
-            missed = entry.get(ServiceConstants.history.MISSED_KEY).contentEquals("true");
-
-            displayName = entry.get(ServiceConstants.history.DISPLAY_NAME_KEY);
-            recordPath = entry.get(ServiceConstants.history.RECORDING_PATH_KEY);
-            number = entry.get(ServiceConstants.history.PEER_NUMBER_KEY);
-            timeFormatted = HistoryTimeModel.timeToHistoryConst(call_start);
-        }
-
-        public String getDirection() {
-            return direction;
-        }
-
-        public String getDate() {
-            return timeFormatted;
-        }
-
-        public String getStartString(String format) {
-            Timestamp stamp = new Timestamp(call_start * 1000); // in milliseconds
-            Date date = new Date(stamp.getTime());
-            SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.getDefault());
-            sdf.setTimeZone(TimeZone.getDefault());
-            String formattedDate = sdf.format(date);
-            return formattedDate;
-
-        }
-
-        public String getDurationString() {
-
-            long duration = call_end - call_start;
-            if (duration < 60)
-                return String.format(Locale.getDefault(), "%02d secs", duration);
-
-            if (duration < 3600)
-                return String.format(Locale.getDefault(), "%02d mins %02d secs", (duration % 3600) / 60, (duration % 60));
-
-            return String.format(Locale.getDefault(), "%d h %02d mins %02d secs", duration / 3600, (duration % 3600) / 60, (duration % 60));
-
-        }
-
-        public long getDuration() {
-            return call_end - call_start;
-
-        }
-
-        public String getRecordPath() {
-            return recordPath;
-        }
-
-        public String getNumber() {
-            return number;
-        }
-
-        public String getDisplayName() {
-            return displayName.substring(0, displayName.indexOf('@'));
-        }
-
-        @Override
-        public int describeContents() {
-            return 0;
-        }
-
-        @Override
-        public void writeToParcel(Parcel dest, int flags) {
-            dest.writeLong(call_start);
-            dest.writeLong(call_end);
-            dest.writeString(accountID);
-            dest.writeString(number);
-            dest.writeByte((byte) (missed ? 1 : 0));
-            dest.writeString(direction);
-            dest.writeString(recordPath);
-            dest.writeString(timeFormatted);
-            dest.writeString(displayName);
-            dest.writeLong(contactID);
-        }
-
-        public static final Parcelable.Creator<HistoryCall> CREATOR = new Parcelable.Creator<HistoryCall>() {
-            public HistoryCall createFromParcel(Parcel in) {
-                return new HistoryCall(in);
-            }
-
-            public HistoryCall[] newArray(int size) {
-                return new HistoryCall[size];
-            }
-        };
-
-        private HistoryCall(Parcel in) {
-            call_start = in.readLong();
-            call_end = in.readLong();
-            accountID = in.readString();
-            number = in.readString();
-            missed = in.readByte() == 1 ? true : false;
-            direction = in.readString();
-            recordPath = in.readString();
-            timeFormatted = in.readString();
-            displayName = in.readString();
-            contactID = in.readLong();
-        }
-
-        public boolean hasRecord() {
-            return recordPath.length() > 0;
-        }
-
-        public boolean isIncoming() {
-            return direction.contentEquals(ServiceConstants.history.INCOMING_STRING);
-        }
-
-        public boolean isMissed() {
-            return missed;
-        }
-
-    }
-
 }
diff --git a/src/org/sflphone/history/HistoryTimeModel.java b/src/org/sflphone/history/HistoryTimeModel.java
index 4839059..87d5c00 100644
--- a/src/org/sflphone/history/HistoryTimeModel.java
+++ b/src/org/sflphone/history/HistoryTimeModel.java
@@ -1,7 +1,137 @@
 package org.sflphone.history;
 
-/**
- * Created by lisional on 14/01/14.
- */
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Locale;
+
 public class HistoryTimeModel {
+
+    static ArrayList<String> timeCategories;
+
+    public interface HistoryTimeCategoryModel {
+        String TODAY = "Today"; // 0
+        String YESTERDAY = "Yesterday"; // 1
+        String TWO_DAYS = getDate(2, "MM/dd");// 2
+        String THREE_DAYS = getDate(3, "MM/dd");// 3
+        String FOUR_DAYS = getDate(4, "MM/dd");// 4
+        String FIVE_DAYS = getDate(5, "MM/dd");// 5
+        String SIX_DAYS = getDate(6, "MM/dd");// 6
+        String LAST_WEEK = "Last week"; // 7
+        String TWO_WEEKS = "Two weeks ago"; // 8
+        String THREE_WEEKS = "Three weeks ago"; // 9
+        String LAST_MONTH = "Last month"; // 10
+        String TWO_MONTH = "Two months ago"; // 11
+        String THREE_MONTH = "Three months ago"; // 12
+        String FOUR_MONTH = "Four months ago"; // 13
+        String FIVE_MONTH = "Five months ago"; // 14
+        String SIX_MONTH = "Six months ago"; // 15
+        String SEVEN_MONTH = "Seven months ago"; // 16
+        String EIGHT_MONTH = "Eight months ago"; // 17
+        String NINE_MONTH = "Nine months ago"; // 18
+        String TEN_MONTH = "Ten months ago"; // 19
+        String ELEVEN_MONTH = "Eleven months ago"; // 20
+        String TWELVE_MONTH = "Twelve months ago"; // 21
+        String LAST_YEAR = "Last year"; // 22
+        String LONG_TIME_AGO = "Very long time ago"; // 23
+        String NEVER = "Never"; // 24
+    }
+
+    private static final String TAG = HistoryManager.class.getSimpleName();
+
+    static Calendar removeDays(int ago) {
+        Calendar cal = Calendar.getInstance(Locale.getDefault());
+        int currentDay = cal.get(Calendar.DAY_OF_MONTH);
+        // Set the date to 2 days ago
+        cal.set(Calendar.DAY_OF_MONTH, currentDay - ago);
+        return cal;
+    }
+
+    static String getDate(int ago, String format) {
+        Calendar cal = removeDays(ago);
+        SimpleDateFormat objFormatter = new SimpleDateFormat(format, Locale.CANADA);
+        objFormatter.setTimeZone(cal.getTimeZone());
+
+        String result = objFormatter.format(cal.getTime());
+        cal.clear();
+        return result;
+    }
+
+    public static String timeToHistoryConst(long time) {
+
+        if(timeCategories == null){
+            initializeCategories();
+        }
+
+        long time2 = time;
+        long currentTime = Calendar.getInstance(Locale.getDefault()).getTime().getTime() / 1000; // in seconds
+
+        if (time < 0)
+            return HistoryTimeCategoryModel.NEVER;
+
+        // Check if part if the current Nychthemeron
+        if (currentTime - time <= 3600 * 24) // The future case would be a bug, but it have to be handled anyway or it will appear in
+            // "very long time ago"
+            return HistoryTimeCategoryModel.TODAY;
+
+        time2 -= time % (3600 * 24); // Reset to midnight
+        currentTime -= currentTime % (3600 * 24); // Reset to midnight
+        // Check for last week
+        if (currentTime - (6) * 3600 * 24 < time2) {
+            for (int i = 1; i < 7; i++) {
+                if (currentTime - ((i) * 3600 * 24) == time2)
+                    return timeCategories.get(i); // Yesterday to Six_days_ago
+            }
+        }
+        // Check for last month
+        else if (currentTime - ((4) * 7 * 24 * 3600) < time2) {
+            for (int i = 1; i < 4; i++) {
+                if (currentTime - ((i + 1) * 7 * 24 * 3600) < time2)
+                    return timeCategories.get(i + timeCategories.indexOf(HistoryTimeCategoryModel.LAST_WEEK) - 1); // Last_week to Three_weeks_ago
+            }
+        }
+        // Check for last year
+        else if (currentTime - (12) * 30.4f * 24 * 3600 < time2) {
+            for (int i = 1; i < 12; i++) {
+                if (currentTime - (i + 1) * 30.4f * 24 * 3600 < time2) // Not exact, but faster
+                    return timeCategories.get(i + timeCategories.indexOf(HistoryTimeCategoryModel.LAST_MONTH) - 1);
+                ; // Last_month to Twelve_months ago
+            }
+        }
+        // if (QDate::currentDate().addYears(-1) >= date && QDate::currentDate().addYears(-2) < date)
+        else if (currentTime - 365 * 24 * 3600 < time2)
+            return HistoryTimeCategoryModel.LAST_YEAR;
+
+        // Every other senario
+        return HistoryTimeCategoryModel.LONG_TIME_AGO;
+    }
+
+    private static void initializeCategories() {
+        timeCategories = new ArrayList<String>();
+        timeCategories.add(HistoryTimeCategoryModel.TODAY);
+        timeCategories.add(HistoryTimeCategoryModel.YESTERDAY);
+        timeCategories.add(HistoryTimeCategoryModel.TWO_DAYS);
+        timeCategories.add(HistoryTimeCategoryModel.THREE_DAYS);
+        timeCategories.add(HistoryTimeCategoryModel.FOUR_DAYS);
+        timeCategories.add(HistoryTimeCategoryModel.FIVE_DAYS);
+        timeCategories.add(HistoryTimeCategoryModel.SIX_DAYS);
+        timeCategories.add(HistoryTimeCategoryModel.LAST_WEEK);
+        timeCategories.add(HistoryTimeCategoryModel.TWO_WEEKS);
+        timeCategories.add(HistoryTimeCategoryModel.THREE_WEEKS);
+        timeCategories.add(HistoryTimeCategoryModel.LAST_MONTH);
+        timeCategories.add(HistoryTimeCategoryModel.TWO_MONTH);
+        timeCategories.add(HistoryTimeCategoryModel.THREE_MONTH);
+        timeCategories.add(HistoryTimeCategoryModel.FOUR_MONTH);
+        timeCategories.add(HistoryTimeCategoryModel.FIVE_MONTH);
+        timeCategories.add(HistoryTimeCategoryModel.SIX_MONTH);
+        timeCategories.add(HistoryTimeCategoryModel.SEVEN_MONTH);
+        timeCategories.add(HistoryTimeCategoryModel.EIGHT_MONTH);
+        timeCategories.add(HistoryTimeCategoryModel.NINE_MONTH);
+        timeCategories.add(HistoryTimeCategoryModel.TEN_MONTH);
+        timeCategories.add(HistoryTimeCategoryModel.ELEVEN_MONTH);
+        timeCategories.add(HistoryTimeCategoryModel.TWELVE_MONTH);
+        timeCategories.add(HistoryTimeCategoryModel.LAST_YEAR);
+        timeCategories.add(HistoryTimeCategoryModel.LONG_TIME_AGO);
+        timeCategories.add(HistoryTimeCategoryModel.NEVER);
+    }
 }
diff --git a/src/org/sflphone/loaders/AccountsLoader.java b/src/org/sflphone/loaders/AccountsLoader.java
index 30bdaa0..fdb7fd1 100644
--- a/src/org/sflphone/loaders/AccountsLoader.java
+++ b/src/org/sflphone/loaders/AccountsLoader.java
@@ -40,7 +40,7 @@
 import android.content.Context;
 import android.os.Bundle;
 import android.os.RemoteException;
-import android.support.v4.content.AsyncTaskLoader;
+import android.content.AsyncTaskLoader;
 import android.util.Log;
 
 public class AccountsLoader extends AsyncTaskLoader<Bundle> {
diff --git a/src/org/sflphone/model/CallContact.java b/src/org/sflphone/model/CallContact.java
index 02170e4..50c054b 100644
--- a/src/org/sflphone/model/CallContact.java
+++ b/src/org/sflphone/model/CallContact.java
@@ -182,13 +182,6 @@
             return result;
         }
 
-        public CallContact buildSimpleContact(String name, String number_called) {
-            ArrayList<Phone> phones = new ArrayList<Phone>();
-            phones.add(new Phone(number_called, 0));
-
-            return new CallContact(-1, name, 0, phones, new ArrayList<CallContact.Phone>(), "", false);
-        }
-
     }
 
     @Override
diff --git a/src/org/sflphone/model/Conference.java b/src/org/sflphone/model/Conference.java
index a90390c..0047f3b 100644
--- a/src/org/sflphone/model/Conference.java
+++ b/src/org/sflphone/model/Conference.java
@@ -177,12 +177,10 @@
     }
 
     public boolean isRecording() {
-        if(hasMultipleParticipants())
             return recording;
-        else
-            return participants.get(0).isRecording();
     }
 
+
     public boolean isOnGoing() {
         if (participants.size() == 1 && participants.get(0).isOngoing())
             return true;
diff --git a/src/org/sflphone/service/CallManagerCallBack.java b/src/org/sflphone/service/CallManagerCallBack.java
index 06e213d..8126c8b 100644
--- a/src/org/sflphone/service/CallManagerCallBack.java
+++ b/src/org/sflphone/service/CallManagerCallBack.java
@@ -1,17 +1,24 @@
 package org.sflphone.service;
 
-import android.content.Context;
 import android.content.Intent;
-import android.util.Log;
 import android.os.Bundle;
+import android.os.RemoteException;
 import android.support.v4.content.LocalBroadcastManager;
+import android.util.Log;
+import org.sflphone.client.CallActivity;
+import org.sflphone.model.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
 
 public class CallManagerCallBack extends Callback {
     
     private static final String TAG = "CallManagerCallBack";
-    private Context mContext; 
+    private final ISipService.Stub mBinder;
+    private  SipService mService;
 
-    static public final String NEW_CALL_CREATED = "new-call-created"; 
     static public final String CALL_STATE_CHANGED = "call-state-changed";
     static public final String INCOMING_CALL = "incoming-call";
     static public final String INCOMING_TEXT = "incoming-text";
@@ -21,37 +28,173 @@
     static public final String RECORD_STATE_CHANGED = "record_state";
 
 
-    public CallManagerCallBack(Context context) {
-        mContext = context;
+    public CallManagerCallBack(SipService context, ISipService.Stub bind) {
+        mService = context;
+        mBinder = bind;
     }
 
     @Override
-    public void on_new_call_created(String accountID, String callID, String to) {
-        Log.d(TAG, "on_new_call_created(" + accountID + ", " + callID + ", " + to + ")");
-
-    }
-
-    @Override
-    public void on_call_state_changed(String callID, String state) {
-        Log.d(TAG, "on_call_state_changed(" + callID + ", " + state + ")");
+    public void on_call_state_changed(String callID, String newState) {
+       Log.d(TAG, "on_call_state_changed : (" + callID + ", " + newState + ")");
         Bundle bundle = new Bundle();
         bundle.putString("CallID", callID);
-        bundle.putString("State", state);
+        bundle.putString("State", newState);
         Intent intent = new Intent(CALL_STATE_CHANGED);
         intent.putExtra("com.savoirfairelinux.sflphone.service.newstate", bundle);
-        LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
+
+        /*try {
+            if (mService.getCurrentCalls().get(callID) != null && mBinder.isConferenceParticipant(callID)) {
+                mService.getCurrentCalls().remove(callID);
+            }
+        } catch (RemoteException e1) {
+            e1.printStackTrace();
+        }*/
+
+
+        if (newState.equals("INCOMING")) {
+            mService.getCurrentCalls().get(callID).setCallState(SipCall.state.CALL_STATE_INCOMING);
+        } else if (newState.equals("RINGING")) {
+            try {
+                mService.getCurrentCalls().get(callID).setCallState(SipCall.state.CALL_STATE_RINGING);
+            } catch (NullPointerException e) {
+                if (mService.getCurrentCalls() == null) {
+                    return;
+                }
+                if (mService.getCurrentCalls().get(callID) == null) {
+                    Log.e(TAG, "call for " + callID + " is null");
+                    return;
+                }
+            }
+
+        } else if (newState.equals("CURRENT")) {
+            if (mService.getCurrentCalls().get(callID) != null) {
+                mService.getCurrentCalls().get(callID).setCallState(SipCall.state.CALL_STATE_CURRENT);
+            } else {
+                // Check if call is in a conference
+                Iterator<Map.Entry<String, Conference>> it = mService.getCurrentConfs().entrySet().iterator();
+                while (it.hasNext()) {
+                    Conference tmp = it.next().getValue();
+                    for (SipCall c : tmp.getParticipants()) {
+                        if (c.getCallId().contentEquals(callID))
+                            c.setCallState(SipCall.state.CALL_STATE_CURRENT);
+                    }
+                }
+            }
+
+        } else if (newState.equals("HUNGUP")) {
+
+            Log.d(TAG, "Hanging up " + callID);
+            if (mService.getCurrentCalls().get(callID) != null) {
+                if (mService.getCurrentCalls().get(callID).isRinging()
+                        && mService.getCurrentCalls().get(callID).isIncoming())
+                    mService.notificationManager.publishMissedCallNotification(mService.getCurrentCalls().get(callID));
+                mService.getCurrentCalls().remove(callID);
+            } else {
+                ArrayList<Conference> it = new ArrayList<Conference>(mService.getCurrentConfs().values());
+
+                boolean found = false;
+                int i = 0;
+                while (!found && i < it.size()) {
+                    Conference tmp = it.get(i);
+
+                    for (int j = 0; j < tmp.getParticipants().size(); ++j) {
+                        if (tmp.getParticipants().get(j).getCallId().contentEquals(callID)) {
+                            mService.getCurrentConfs().get(tmp.getId()).getParticipants().remove(tmp.getParticipants().get(j));
+                            found = true;
+                        }
+
+                    }
+                    ++i;
+
+                }
+            }
+
+            mService.sendBroadcast(intent);
+
+        } else if (newState.equals("BUSY")) {
+            mService.getCurrentCalls().remove(callID);
+        } else if (newState.equals("FAILURE")) {
+            mService.getCurrentCalls().remove(callID);
+        } else if (newState.equals("HOLD")) {
+            if (mService.getCurrentCalls().get(callID) != null) {
+                mService.getCurrentCalls().get(callID).setCallState(SipCall.state.CALL_STATE_HOLD);
+            } else {
+                // Check if call is in a conference
+                Iterator<Map.Entry<String, Conference>> it = mService.getCurrentConfs().entrySet().iterator();
+                while (it.hasNext()) {
+                    Conference tmp = it.next().getValue();
+                    for (SipCall c : tmp.getParticipants()) {
+                        if (c.getCallId().contentEquals(callID))
+                            c.setCallState(SipCall.state.CALL_STATE_HOLD);
+                    }
+                }
+            }
+        } else if (newState.equals("UNHOLD")) {
+
+            if (mService.getCurrentCalls().get(callID) != null) {
+                mService.getCurrentCalls().get(callID).setCallState(SipCall.state.CALL_STATE_CURRENT);
+            } else {
+                // Check if call is in a conference
+                Iterator<Map.Entry<String, Conference>> it = mService.getCurrentConfs().entrySet().iterator();
+                while (it.hasNext()) {
+                    Conference tmp = it.next().getValue();
+                    for (SipCall c : tmp.getParticipants()) {
+                        if (c.getCallId().contentEquals(callID))
+                            c.setCallState(SipCall.state.CALL_STATE_CURRENT);
+                    }
+                }
+            }
+        } else {
+            mService.getCurrentCalls().get(callID).setCallState(SipCall.state.CALL_STATE_NONE);
+        }
+
+
+        Log.d(TAG, "Hanging up " + callID);
+        mService.sendBroadcast(intent);
+
     }
 
     @Override
     public void on_incoming_call(String accountID, String callID, String from) {
         Log.d(TAG, "on_incoming_call(" + accountID + ", " + callID + ", " + from + ")");
-        Bundle bundle = new Bundle();
-        bundle.putString("AccountID", accountID);
-        bundle.putString("CallID", callID);
-        bundle.putString("From", from);
-        Intent intent = new Intent(INCOMING_CALL);
-        intent.putExtra("com.savoirfairelinux.sflphone.service.newcall", bundle);
-        LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
+
+        SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance();
+        try {
+            HashMap<String, String> details = (HashMap<String, String>) mBinder.getAccountDetails(accountID);
+            ArrayList<HashMap<String, String>> credentials = (ArrayList<HashMap<String, String>>) mBinder
+                    .getCredentials(accountID);
+            Account acc = new Account(accountID, details, credentials);
+            callBuilder.startCallCreation(callID).setAccount(acc).setCallState(SipCall.state.CALL_STATE_RINGING)
+                    .setCallType(SipCall.state.CALL_TYPE_INCOMING);
+            callBuilder.setContact(CallContact.ContactBuilder.buildUnknownContact(from));
+
+            Intent toSend = new Intent(CallManagerCallBack.INCOMING_CALL);
+            toSend.setClass(mService, CallActivity.class);
+            toSend.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+            SipCall newCall = callBuilder.build();
+            toSend.putExtra("newcall", newCall);
+            HashMap<String, String> callDetails = (HashMap<String, String>) mBinder.getCallDetails(callID);
+
+            newCall.setTimestamp_start(Long.parseLong(callDetails.get(ServiceConstants.call.TIMESTAMP_START)));
+            mService.getCurrentCalls().put(newCall.getCallId(), newCall);
+
+            Bundle bundle = new Bundle();
+            Conference tmp = new Conference("-1");
+
+            tmp.getParticipants().add(newCall);
+
+            bundle.putParcelable("conference", tmp);
+            toSend.putExtra("resuming", false);
+            toSend.putExtras(bundle);
+            mService.startActivity(toSend);
+            mService.mediaManager.startRing("");
+            mService.mediaManager.obtainAudioFocus(true);
+        } catch (RemoteException e1) {
+            e1.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
     
     @Override
@@ -63,8 +206,21 @@
     public void on_conference_created(String confID){
         Log.w(TAG,"CONFERENCE CREATED:"+confID);
         Intent intent = new Intent(CONF_CREATED);
-        intent.putExtra("confID", confID);
-        LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
+        Conference created = new Conference(confID);
+
+        try {
+            ArrayList<String> all_participants = (ArrayList<String>) mBinder.getParticipantList(intent.getStringExtra("confID"));
+            for (String participant : all_participants) {
+                created.getParticipants().add(mService.getCurrentCalls().get(participant));
+                mService.getCurrentCalls().remove(participant);
+            }
+            intent.putExtra("newconf", created);
+            mService.getCurrentConfs().put(confID, created);
+            mService.sendBroadcast(intent);
+        } catch (RemoteException e1) {
+            e1.printStackTrace();
+        }
+        Log.i(TAG, "current_confs size " + mService.getCurrentConfs().size());
     }
     
     @Override
@@ -77,14 +233,30 @@
         bundle.putString("Msg", msg);
         Intent intent = new Intent(INCOMING_TEXT); 
         intent.putExtra("com.savoirfairelinux.sflphone.service.newtext", bundle);
-        LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
+
+
+        if (mService.getCurrentCalls().get(ID) != null) {
+            mService.getCurrentCalls().get(ID).addSipMessage(new SipMessage(true, msg));
+        } else if (mService.getCurrentConfs().get(ID) != null) {
+            mService.getCurrentConfs().get(ID).addSipMessage(new SipMessage(true, msg));
+        } else
+            return;
+
+        mService.sendBroadcast(intent);
     }
     
     @Override
     public void on_conference_removed(String confID){
         Intent intent = new Intent(CONF_REMOVED);
         intent.putExtra("confID", confID);
-        LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
+
+        Conference toDestroy = mService.getCurrentConfs().get(confID);
+        for (int i = 0; i < toDestroy.getParticipants().size(); ++i) {
+            mService.getCurrentCalls().put(toDestroy.getParticipants().get(i).getCallId(), toDestroy.getParticipants().get(i));
+        }
+        mService.getCurrentConfs().remove(confID);
+        mService.sendBroadcast(intent);
+
     }
     
     @Override
@@ -92,7 +264,30 @@
         Intent intent = new Intent(CONF_CHANGED);
         intent.putExtra("confID", confID);
         intent.putExtra("State", state);
-        LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
+        ArrayList<String> all_participants;
+
+        try {
+            all_participants = (ArrayList<String>) mBinder.getParticipantList(intent.getStringExtra("confID"));
+            for (String participant : all_participants) {
+                if (mService.getCurrentConfs().get(confID).getParticipants().size() < all_participants.size()
+                        && mService.getCurrentCalls().get(participant) != null) { // We need to add the new participant to the conf
+                    mService.getCurrentConfs().get(confID).getParticipants()
+                            .add(mService.getCurrentCalls().get(participant));
+                    mService.getCurrentCalls().remove(participant);
+                    mService.getCurrentConfs().get(confID).setState(intent.getStringExtra("State"));
+                    mService.sendBroadcast(intent);
+                    return;
+                }
+            }
+        } catch (RemoteException e) {
+            e.printStackTrace();
+        }
+
+        Log.i(TAG, "Received" + intent.getAction());
+        if (mService.getCurrentConfs().get(confID) != null) {
+            mService.getCurrentConfs().get(confID).setState(intent.getStringExtra("State"));
+            mService.sendBroadcast(intent);
+        }
     }
     
     @Override
@@ -100,7 +295,7 @@
         Intent intent = new Intent(RECORD_STATE_CHANGED);
         intent.putExtra("id", id);
         intent.putExtra("file", filename);
-        LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
+        LocalBroadcastManager.getInstance(mService).sendBroadcast(intent);
     }
 
 }
diff --git a/src/org/sflphone/service/ConfigurationManagerCallback.java b/src/org/sflphone/service/ConfigurationManagerCallback.java
index 5d4efc1..0a02925 100644
--- a/src/org/sflphone/service/ConfigurationManagerCallback.java
+++ b/src/org/sflphone/service/ConfigurationManagerCallback.java
@@ -28,14 +28,15 @@
 
 public class ConfigurationManagerCallback extends ConfigurationCallback {
 //    private static final String TAG = "ConfigurationManagerCallback";
-    private Context mContext;
+private final ISipService.Stub mBinder;
+    private  SipService mService;
 
-    static public final String SIGNAL_NAME = "signal-name";
     static public final String ACCOUNTS_CHANGED = "accounts-changed";
     static public final String ACCOUNT_STATE_CHANGED = "account-state-changed";
 
-    public ConfigurationManagerCallback(Context context) {
-        mContext = context;
+    public ConfigurationManagerCallback(SipService context, ISipService.Stub bind) {
+        mService = context;
+        mBinder = bind;
     }
 
     @Override
@@ -93,12 +94,12 @@
         intent.putExtra("Account", accoundID);
         intent.putExtra("state", state);
         intent.putExtra("code", code);
-        LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
+        mService.sendBroadcast(intent);
     }
 
     private void sendAccountsChangedMessage() {
         Intent intent = new Intent(ACCOUNTS_CHANGED);
-        LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
+        mService.sendBroadcast(intent);
     }
 
 }
diff --git a/src/org/sflphone/service/ServiceConstants.java b/src/org/sflphone/service/ServiceConstants.java
index 99ff767..51f4865 100644
--- a/src/org/sflphone/service/ServiceConstants.java
+++ b/src/org/sflphone/service/ServiceConstants.java
@@ -2,30 +2,6 @@
 
 public final class ServiceConstants {
 
-    public static final String INTENT_SIP_SERVICE = "com.savoirfairelinux.sflphone.service.SipService";
-    public static final String EXTRA_OUTGOING_ACTIVITY = "outgoing_activity";
-
-    public interface history {
-        public static final String ACCOUNT_ID_KEY = "accountid";
-        public static final String CALLID_KEY = "callid";
-        public static final String CONFID_KEY = "confid";
-        public static final String DISPLAY_NAME_KEY = "display_name";
-        public static final String PEER_NUMBER_KEY = "peer_number";
-        public static final String RECORDING_PATH_KEY = "recordfile";
-
-        // New fields
-        public static final String MISSED_KEY = "missed";
-        public static final String DIRECTION_KEY = "direction";
-
-        public static final String TIMESTAMP_START_KEY = "timestamp_start";
-        public static final String TIMESTAMP_STOP_KEY = "timestamp_stop";
-        public static final String AUDIO_CODEC_KEY = "audio_codec";
-        public static final String VIDEO_CODEC_KEY = "video_codec";
-
-        public static final String MISSED_STRING = "missed";
-        public static final String INCOMING_STRING = "incoming";
-        public static final String OUTGOING_STRING = "outgoing";
-    }
 
     public interface call {
         public static final String CALL_TYPE = "CALL_TYPE";
diff --git a/src/org/sflphone/service/SipService.java b/src/org/sflphone/service/SipService.java
index 5de1bc1..c76ad97 100644
--- a/src/org/sflphone/service/SipService.java
+++ b/src/org/sflphone/service/SipService.java
@@ -36,14 +36,12 @@
 import org.sflphone.model.Conference;
 import org.sflphone.model.SipCall;
 import org.sflphone.model.SipMessage;
-import org.sflphone.receivers.IncomingReceiver;
 import org.sflphone.utils.MediaManager;
 import org.sflphone.utils.SipNotifications;
 import org.sflphone.utils.SwigNativeConverter;
 
 import android.app.Service;
 import android.content.Intent;
-import android.content.IntentFilter;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.HandlerThread;
@@ -57,7 +55,6 @@
 public class SipService extends Service {
 
     static final String TAG = "SipService";
-    static final int DELAY = 5000; /* 5 sec */
     private SipServiceExecutor mExecutor;
     private static HandlerThread executorThread;
     private CallManager callManagerJNI;
@@ -72,12 +69,15 @@
 
     private HashMap<String, SipCall> current_calls = new HashMap<String, SipCall>();
     private HashMap<String, Conference> current_confs = new HashMap<String, Conference>();
-    private IncomingReceiver receiver;
 
-    public HashMap<String, Conference> getCurrent_confs() {
+    public HashMap<String, Conference> getCurrentConfs() {
         return current_confs;
     }
 
+    public HashMap<String, SipCall> getCurrentCalls() {
+        return current_calls;
+    }
+
     @Override
     public boolean onUnbind(Intent i) {
         super.onUnbind(i);
@@ -96,19 +96,6 @@
         Log.i(TAG, "onCreated");
         super.onCreate();
 
-        IntentFilter callFilter = new IntentFilter(CallManagerCallBack.CALL_STATE_CHANGED);
-        callFilter.addAction(CallManagerCallBack.INCOMING_CALL);
-        callFilter.addAction(CallManagerCallBack.NEW_CALL_CREATED);
-        callFilter.addAction(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED);
-        callFilter.addAction(ConfigurationManagerCallback.ACCOUNTS_CHANGED);
-        callFilter.addAction(CallManagerCallBack.INCOMING_TEXT);
-        callFilter.addAction(CallManagerCallBack.CONF_CREATED);
-        callFilter.addAction(CallManagerCallBack.CONF_REMOVED);
-        callFilter.addAction(CallManagerCallBack.CONF_CHANGED);
-        callFilter.addAction(CallManagerCallBack.RECORD_STATE_CHANGED);
-        receiver = new IncomingReceiver(this, mBinder);
-        LocalBroadcastManager.getInstance(this).registerReceiver(receiver, callFilter);
-
         getExecutor().execute(new StartRunnable());
 
         notificationManager = new SipNotifications(this);
@@ -124,9 +111,6 @@
     public int onStartCommand(Intent intent, int flags, int startId) {
         Log.i(TAG, "onStarted");
         super.onStartCommand(intent, flags, startId);
-
-        receiver = new IncomingReceiver(this, mBinder);
-
         return START_STICKY; /* started and stopped explicitly */
     }
 
@@ -134,8 +118,6 @@
     public void onDestroy() {
         Log.i(TAG, "onDestroy");
         /* called once by stopService() */
-
-        LocalBroadcastManager.getInstance(this).unregisterReceiver(receiver);
         notificationManager.onServiceDestroy();
 
         getExecutor().execute(new FinalizeRunnable());
@@ -234,21 +216,17 @@
         // managerImpl.setPath(getApplication().getFilesDir().getAbsolutePath());
 
         callManagerJNI = new CallManager();
-        callManagerCallBack = new CallManagerCallBack(this);
+        callManagerCallBack = new CallManagerCallBack(this, mBinder);
         SFLPhoneservice.setCallbackObject(callManagerCallBack);
 
         configurationManagerJNI = new ConfigurationManager();
-        configurationManagerCallback = new ConfigurationManagerCallback(this);
+        configurationManagerCallback = new ConfigurationManagerCallback(this, mBinder);
         SFLPhoneservice.setConfigurationCallbackObject(configurationManagerCallback);
         managerImpl.init("");
 
         Log.i(TAG, "->startPjSipStack");
     }
 
-    public HashMap<String, SipCall> getCurrent_calls() {
-        return current_calls;
-    }
-
     // Enforce same thread contract to ensure we do not call from somewhere else
     public class SameThreadException extends Exception {
         private static final long serialVersionUID = -905639124232613768L;
@@ -333,7 +311,7 @@
                     HashMap<String, String> details = SwigNativeConverter.convertCallDetailsToNative(callManagerJNI.getCallDetails(call.getCallId()));
                     // watchout timestamp stored by sflphone is in seconds
                     call.setTimestamp_start(Long.parseLong(details.get(ServiceConstants.call.TIMESTAMP_START)));
-                    getCurrent_calls().put(call.getCallId(), call);
+                    getCurrentCalls().put(call.getCallId(), call);
                     mediaManager.obtainAudioFocus(false);
                 }
             });
@@ -895,13 +873,13 @@
                     Log.i(TAG, "SipService.toggleRecordingCall() thread running...");
                     boolean result = callManagerJNI.toggleRecording(id);
 
-                    if (getCurrent_calls().containsKey(id)) {
-                        getCurrent_calls().get(id).setRecording(result);
-                    } else if (getCurrent_confs().containsKey(id)) {
-                        getCurrent_confs().get(id).setRecording(result);
+                    if (getCurrentCalls().containsKey(id)) {
+                        getCurrentCalls().get(id).setRecording(result);
+                    } else if (getCurrentConfs().containsKey(id)) {
+                        getCurrentConfs().get(id).setRecording(result);
                     } else {
                         // A call in a conference has been put on hold
-                        Iterator<Conference> it = getCurrent_confs().values().iterator();
+                        Iterator<Conference> it = getCurrentConfs().values().iterator();
                         while (it.hasNext()) {
                             Conference c = it.next();
                             if (c.getCall(id) != null)
@@ -962,10 +940,10 @@
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.sendTextMessage() thread running...");
                     callManagerJNI.sendTextMessage(callID, message.comment);
-                    if (getCurrent_calls().get(callID) != null)
-                        getCurrent_calls().get(callID).addSipMessage(message);
-                    else if (getCurrent_confs().get(callID) != null)
-                        getCurrent_confs().get(callID).addSipMessage(message);
+                    if (getCurrentCalls().get(callID) != null)
+                        getCurrentCalls().get(callID).addSipMessage(message);
+                    else if (getCurrentConfs().get(callID) != null)
+                        getCurrentConfs().get(callID).addSipMessage(message);
                 }
             });
 
@@ -1096,12 +1074,12 @@
             // results.put(calls.get(i), new SipCall(calls.get(i), callManagerJNI.getCallDetails(calls.get(i))));
             // }
 
-            return getCurrent_calls();
+            return getCurrentCalls();
         }
 
         @Override
         public SipCall getCall(String callID) throws RemoteException {
-            return getCurrent_calls().get(callID);
+            return getCurrentCalls().get(callID);
         }
 
         /***********************
@@ -1109,7 +1087,7 @@
          ***********************/
         @Override
         public void createNotification() throws RemoteException {
-            notificationManager.makeNotification(getCurrent_calls());
+            notificationManager.makeNotification(getCurrentCalls());
 
         }