anchor.diff:      end.
   
   
  +
  +%% @private
  +-spec parse_id(nksip:id()) ->
  +    {nksip:app_id(), id(), nksip_dialog:id(), nksip:call_id()}.
  +
  +parse_id(<<"U_", SubsId:6/binary, $_, DialogId:6/binary, $_, App:7/binary, 
  +         $_, CallId/binary>>) ->
  +    AppId = binary_to_existing_atom(App, latin1),
  +    {AppId, SubsId, DialogId, CallId}. 
  +
  +
   %% @private
   -spec make_id(nksip:request()) ->
       id().
  
positive.code: %% ===================================================================
  
  
  % %% @private
  % -spec get_id(nksip:token()|undefined, nksip_dialog:id()) ->
  %     nksip:id().
  
  % get_id({Type, Opts}, <<"D_", _/binary>>=Id) when is_binary(Type), is_list(Opts) ->
  %     {AppId, DialogId, CallId} = nksip_dialog:parse_id(Id),
  %     App = atom_to_binary(AppId, latin1), 
  %     EventId = nksip_lib:get_binary(<<"id">>, Opts, <<>>),
  %     <<$U, $_, App/binary, Type/binary, $_, EventId/binary, $_, DialogId/binary,
  %       CallId/binary>>;
  
  % get_id({Type, Opts}, #dialog{}=Dialog) when is_binary(Type), is_list(Opts) ->
  %     get_id({Type, Opts}, nksip_dialog:get_id(Dialog));
  
  % get_id(_, _) ->
  %     <<>>.
  
  
  %% @private
  -spec parse_id(nksip:id()) ->
      {nksip:app_id(), id(), nksip_dialog:id(), nksip:call_id()}.
  
  parse_id(<<"U_", SubsId:6/binary, $_, DialogId:6/binary, $_, App:7/binary, 
           $_, CallId/binary>>) ->
      AppId = binary_to_existing_atom(App, latin1),
      {AppId, SubsId, DialogId, CallId}. 
  
  
  %% @doc Gets a full subscription record.
  -spec get_subscription(nksip:id()) ->
      nksip:dialog() | error.
  
  get_subscription(Id) ->
      {_AppId, SubsId, _DialogId, _CallId} = parse_id(Id),
      DialogId = nksip_dialog:get_id(Id),
      Fun = fun(#dialog{}=Dialog) ->
  
negative.code: -author('Carlos Gonzalez <carlosj.gf@gmail.com>').
  
  -export([get_id/1, app_id/1, app_name/1, call_id/1, meta/2]).
  -export([get_all/0, get_all/2, get_subscription/2]).
  -export([parse_id/1, get_subscription/1, make_id/1, find/2, subscription_state/1, remote_id/2]).
  -export_type([id/0, status/0, subscription_state/0, terminated_reason/0]).
  
  -include("nksip.hrl").
  -include("nksip_call.hrl").
  
  
  %% ===================================================================
  