Changeset 795:653a07331dfa in mediastreamer2


Ignore:
Timestamp:
Dec 16, 2009 2:41:27 PM (3 years ago)
Author:
smorlat <smorlat@…>
Branch:
default
Message:

add persistent call logs feature + refkey

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@783 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

Location:
linphone
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • linphone/console/linphonec.c

    r794 r795  
    613613         * Initialize linphone core 
    614614         */ 
    615         linphonec=linphone_core_new (&linphonec_vtable, configfile_name, 
     615        linphonec=linphone_core_new (&linphonec_vtable, configfile_name, NULL, 
    616616                            NULL); 
    617617        linphone_core_enable_video(linphonec,vcap_enabled,display_enabled); 
  • linphone/coreapi/help/Doxyfile.in

    r793 r795  
    8686                         *.c \ 
    8787                         *.dox 
    88 RECURSIVE              = YES 
     88RECURSIVE              = NO 
    8989EXCLUDE                =  
    9090EXCLUDE_SYMLINKS       = NO 
  • linphone/coreapi/help/Makefile.am

    r793 r795  
    33 
    44SOURCES=$(top_srcdir)/coreapi/*.h  
     5 
    56 
    67#html doc 
  • linphone/coreapi/help/doxygen.dox.in

    r793 r795  
    11/** 
    22 * @mainpage 
    3  * Project Website: http://savannah.gnu.org/projects/linphone 
    43 * 
    5  * @verbinclude README 
    6  * 
    7  */ 
    8  
    9 /**  
    10  * @defgroup liblinphone liblinphone library - high level library for building SIP applications 
    11  * @brief liblinphone Version @LINPHONE_VERSION@ 
    12  * 
    13  * @see http://savannah.gnu.org/projects/linphone 
     4 * @see http://www.linphone.org 
    145 * 
    156 * @section what_is_it What is liblinphone 
     
    2819 * (contact@belledonne-communications.com) 
    2920 *  
    30  *  
     21 * 
     22**/ 
    3123 
    3224/** 
     
    3628 
    3729 
     30/**  
     31 * @defgroup initializing Initialization and destruction 
     32 * 
     33**/ 
     34 
     35/** 
     36 * @defgroup media_parameters Controlling media parameters 
     37**/ 
     38 
     39/** 
     40 * @defgroup misc Miscenalleous: logs, version strings 
     41**/ 
  • linphone/coreapi/linphonecore.c

    r793 r795  
    163163} 
    164164 
     165static void set_call_log_date(LinphoneCallLog *cl, const struct tm *loctime){ 
     166        my_strftime(cl->start_date,sizeof(cl->start_date),"%c",loctime); 
     167} 
     168 
    165169LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *from, LinphoneAddress *to){ 
    166170        LinphoneCallLog *cl=ms_new0(LinphoneCallLog,1); 
     
    172176        localtime_r(&call->start_time,&loctime); 
    173177#endif 
    174         my_strftime(cl->start_date,sizeof(cl->start_date),"%c",&loctime); 
     178        set_call_log_date(cl,&loctime); 
    175179        cl->from=from; 
    176180        cl->to=to; 
    177181        return cl; 
    178182} 
     183 
     184static void call_logs_write_to_config_file(LinphoneCore *lc){ 
     185        MSList *elem; 
     186        char logsection[32]; 
     187        int i; 
     188        char *tmp; 
     189        LpConfig *cfg=lc->config; 
     190 
     191        if (!lc->ready) return; 
     192         
     193        for(i=0,elem=lc->call_logs;elem!=NULL;elem=elem->next,++i){ 
     194                LinphoneCallLog *cl=(LinphoneCallLog*)elem->data; 
     195                snprintf(logsection,sizeof(logsection),"call_log_%i",i); 
     196                lp_config_set_int(cfg,logsection,"dir",cl->dir); 
     197                lp_config_set_int(cfg,logsection,"status",cl->status); 
     198                tmp=linphone_address_as_string(cl->from); 
     199                lp_config_set_string(cfg,logsection,"from",tmp); 
     200                ms_free(tmp); 
     201                tmp=linphone_address_as_string(cl->to); 
     202                lp_config_set_string(cfg,logsection,"to",tmp); 
     203                ms_free(tmp); 
     204                lp_config_set_string(cfg,logsection,"start_date",cl->start_date); 
     205                lp_config_set_int(cfg,logsection,"duration",cl->duration); 
     206                if (cl->refkey) lp_config_set_string(cfg,logsection,"refkey",cl->refkey); 
     207        } 
     208        for(;i<lc->max_call_logs;++i){ 
     209                snprintf(logsection,sizeof(logsection),"call_log_%i",i); 
     210                lp_config_clean_section(cfg,logsection); 
     211        } 
     212} 
     213 
     214static void call_logs_read_from_config_file(LinphoneCore *lc){ 
     215        char logsection[32]; 
     216        int i; 
     217        const char *tmp; 
     218        LpConfig *cfg=lc->config; 
     219        for(i=0;;++i){ 
     220                snprintf(logsection,sizeof(logsection),"call_log_%i",i); 
     221                if (lp_config_has_section(cfg,logsection)){ 
     222                        LinphoneCallLog *cl=ms_new0(LinphoneCallLog,1); 
     223                        cl->dir=lp_config_get_int(cfg,logsection,"dir",0); 
     224                        cl->status=lp_config_get_int(cfg,logsection,"status",0); 
     225                        tmp=lp_config_get_string(cfg,logsection,"from",NULL); 
     226                        if (tmp) cl->from=linphone_address_new(tmp); 
     227                        tmp=lp_config_get_string(cfg,logsection,"to",NULL); 
     228                        if (tmp) cl->to=linphone_address_new(tmp); 
     229                        tmp=lp_config_get_string(cfg,logsection,"start_date",NULL); 
     230                        if (tmp) strncpy(cl->start_date,tmp,sizeof(cl->start_date)); 
     231                        cl->duration=lp_config_get_int(cfg,logsection,"duration",0); 
     232                        tmp=lp_config_get_string(cfg,logsection,"refkey",NULL); 
     233                        if (tmp) cl->refkey=ms_strdup(tmp); 
     234                        lc->call_logs=ms_list_append(lc->call_logs,cl); 
     235                }else break;     
     236        } 
     237} 
     238 
     239 
    179240void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call){ 
    180241        LinphoneCore *lc=call->core; 
     242         
    181243        calllog->duration=time(NULL)-call->start_time; 
    182244        switch(call->state){ 
     
    211273                lc->vtable.call_log_updated(lc,calllog); 
    212274        } 
     275        call_logs_write_to_config_file(lc); 
    213276} 
    214277 
     
    252315} 
    253316 
     317/** 
     318 * Associate a persistent reference key to the call log. 
     319 * 
     320 * The reference key can be for example an id to an external database. 
     321 * It is stored in the config file, thus can survive to process exits/restarts. 
     322 * 
     323**/ 
     324void linphone_call_log_set_ref_key(LinphoneCallLog *cl, const char *refkey){ 
     325        if (cl->refkey!=NULL){ 
     326                ms_free(cl->refkey); 
     327                cl->refkey=NULL; 
     328        } 
     329        if (refkey) cl->refkey=ms_strdup(refkey); 
     330        call_logs_write_to_config_file(cl->lc); 
     331} 
     332 
     333/** 
     334 * Get the persistent reference key associated to the call log. 
     335 * 
     336 * The reference key can be for example an id to an external database. 
     337 * It is stored in the config file, thus can survive to process exits/restarts. 
     338 * 
     339**/ 
     340const char *linphone_call_log_get_ref_key(const LinphoneCallLog *cl){ 
     341        return cl->refkey; 
     342} 
     343 
    254344void linphone_call_log_destroy(LinphoneCallLog *cl){ 
    255         if (cl->from!=NULL) osip_free(cl->from); 
    256         if (cl->to!=NULL) osip_free(cl->to); 
     345        if (cl->from!=NULL) linphone_address_destroy(cl->from); 
     346        if (cl->to!=NULL) linphone_address_destroy(cl->to); 
     347        if (cl->refkey!=NULL) ms_free(cl->refkey); 
    257348        ms_free(cl); 
    258349} 
     
    308399} 
    309400 
    310  
     401/** 
     402 * Enable logs in supplied FILE*. 
     403 * 
     404 * @ingroup misc 
     405 * 
     406 * @param file a C FILE* where to fprintf logs. If null stdout is used. 
     407 *  
     408**/ 
    311409void linphone_core_enable_logs(FILE *file){ 
    312410        if (file==NULL) file=stdout; 
     
    316414} 
    317415 
     416/** 
     417 * Enable logs through the user's supplied log callback. 
     418 * 
     419 * @ingroup misc 
     420 * 
     421 * @param logfunc The address of a OrtpLogFunc callback whose protoype is 
     422 *                typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args); 
     423 *  
     424**/ 
    318425void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc){ 
    319426        ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL); 
     
    322429} 
    323430 
     431/** 
     432 * Entirely disable logging. 
     433 * 
     434 * @ingroup misc 
     435**/ 
    324436void linphone_core_disable_logs(){ 
    325437        int tl; 
     
    329441 
    330442 
    331 void 
     443static void 
    332444net_config_read (LinphoneCore *lc) 
    333445{ 
     
    369481} 
    370482 
    371 void sound_config_read(LinphoneCore *lc) 
     483static void sound_config_read(LinphoneCore *lc) 
    372484{ 
    373485        /*int tmp;*/ 
     
    441553} 
    442554 
    443 void sip_config_read(LinphoneCore *lc) 
     555static void sip_config_read(LinphoneCore *lc) 
    444556{ 
    445557        char *contact; 
     
    516628} 
    517629 
    518 void rtp_config_read(LinphoneCore *lc) 
     630static void rtp_config_read(LinphoneCore *lc) 
    519631{ 
    520632        int port; 
     
    536648 
    537649 
    538 PayloadType * get_codec(LpConfig *config, char* type,int index){ 
     650static PayloadType * get_codec(LpConfig *config, char* type,int index){ 
    539651        char codeckey[50]; 
    540652        const char *mime,*fmtp; 
     
    559671} 
    560672 
    561 void codecs_config_read(LinphoneCore *lc) 
     673static void codecs_config_read(LinphoneCore *lc) 
    562674{ 
    563675        int i; 
     
    580692} 
    581693 
    582 void video_config_read(LinphoneCore *lc) 
     694static void video_config_read(LinphoneCore *lc) 
    583695{ 
    584696        int capture, display; 
     
    616728} 
    617729 
    618 void ui_config_read(LinphoneCore *lc) 
     730static void ui_config_read(LinphoneCore *lc) 
    619731{ 
    620732        LinphoneFriend *lf; 
     
    623735                linphone_core_add_friend(lc,lf); 
    624736        } 
    625          
    626 } 
    627  
    628 void autoreplier_config_init(LinphoneCore *lc) 
     737        call_logs_read_from_config_file(lc); 
     738} 
     739 
     740/* 
     741static void autoreplier_config_init(LinphoneCore *lc) 
    629742{ 
    630743        autoreplier_config_t *config=&lc->autoreplier_conf; 
     
    636749        config->message=lp_config_get_string(lc->config,"autoreplier","message",NULL); 
    637750} 
    638  
     751*/ 
     752 
     753/** 
     754 * Sets maximum available download bandwidth 
     755 * 
     756 * @ingroup media_parameters 
     757 * 
     758 * This is IP bandwidth, in kbit/s. 
     759 * This information is used signaled to other parties during 
     760 * calls (within SDP messages) so that the remote end can have 
     761 * sufficient knowledge to properly configure its audio & video 
     762 * codec output bitrate to not overflow available bandwidth. 
     763 * 
     764 * @param lc the LinphoneCore object 
     765 * @param bw the bandwidth in kbits/s, 0 for infinite 
     766 */ 
    639767void linphone_core_set_download_bandwidth(LinphoneCore *lc, int bw){ 
    640768        lc->net_conf.download_bw=bw; 
     
    648776} 
    649777 
     778/** 
     779 * Sets maximum available upload bandwidth 
     780 * 
     781 * @ingroup media_parameters 
     782 * 
     783 * This is IP bandwidth, in kbit/s. 
     784 * This information is used by liblinphone together with remote 
     785 * side available bandwidth signaled in SDP messages to properly 
     786 * configure audio & video codec's output bitrate. 
     787 * 
     788 * @param lc the LinphoneCore object 
     789 * @param bw the bandwidth in kbits/s, 0 for infinite 
     790 */ 
    650791void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw){ 
    651792        lc->net_conf.upload_bw=bw; 
     
    659800} 
    660801 
     802/** 
     803 * Retrieve the maximum available download bandwidth. 
     804 * 
     805 * @ingroup media_parameters 
     806 * 
     807 * This value was set by linphone_core_set_download_bandwidth(). 
     808 * 
     809**/ 
    661810int linphone_core_get_download_bandwidth(const LinphoneCore *lc){ 
    662811        return lc->net_conf.download_bw; 
    663812} 
    664813 
     814/** 
     815 * Retrieve the maximum available upload bandwidth. 
     816 * 
     817 * @ingroup media_parameters 
     818 * 
     819 * This value was set by linphone_core_set_upload_bandwidth(). 
     820 * 
     821**/ 
    665822int linphone_core_get_upload_bandwidth(const LinphoneCore *lc){ 
    666823        return lc->net_conf.upload_bw; 
    667824} 
    668825 
     826/** 
     827 * Returns liblinphone's version as a string. 
     828 * 
     829 * @ingroup misc 
     830 * 
     831**/ 
    669832const char * linphone_core_get_version(void){ 
    670833        return liblinphone_version; 
     
    688851} 
    689852 
    690 void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vtable, const char *config_path, void * userdata) 
     853static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vtable, const char *config_path,  
     854    const char *factory_config_path, void * userdata) 
    691855{ 
    692856        memset (lc, 0, sizeof (LinphoneCore)); 
     
    733897         
    734898        lc->config=lp_config_new(config_path); 
     899        if (factory_config_path) 
     900                lp_config_read_file(lc->config,factory_config_path); 
    735901   
    736902#ifdef VINCENT_MAURY_RSVP 
     
    757923} 
    758924 
     925/** 
     926 * Instanciates a LinphoneCore object. 
     927 * @ingroup initializing 
     928 *  
     929 * The LinphoneCore object is the primary handle for doing all phone actions. 
     930 * It should be unique within your application. 
     931 * @param vtable a LinphoneCoreVTable structure holding your application callbacks 
     932 * @param config_path a path to a config file. If it does not exists it will be created. 
     933 *        The config file is used to store all user settings, call logs, friends, proxies... 
     934 * @param factory_config_path a path to a read-only config file that can be used to  
     935 *        to store hard-coded preference such as proxy settings or internal preferences. 
     936 *        The settings in this factory file always override the one in the normal config file. 
     937 *        It is OPTIONAL, use NULL if unneeded. 
     938 * @param userdata an opaque user pointer that can be retrieved at any time (for example in 
     939 *        callbacks) using linphone_core_get_user_data(). 
     940 *  
     941**/ 
    759942LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable, 
    760                                                 const char *config_path, void * userdata) 
     943                                                const char *config_path, const char *factory_config_path, void * userdata) 
    761944{ 
    762945        LinphoneCore *core=ms_new(LinphoneCore,1); 
    763         linphone_core_init(core,vtable,config_path,userdata); 
     946        linphone_core_init(core,vtable,config_path, factory_config_path, userdata); 
    764947        return core; 
    765948} 
    766949 
     950/** 
     951 * Returns the list of available audio codecs. 
     952 * 
     953 * This list is unmodifiable. The ->data field of the MSList points a PayloadType 
     954 * structure holding the codec information. 
     955 * It is possible to make copy of the list with ms_list_copy() in order to modify it 
     956 * (such as the order of codecs). 
     957**/ 
    767958const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc) 
    768959{ 
     
    770961} 
    771962 
     963/** 
     964 * Returns the list of available video codecs. 
     965 * 
     966 * This list is unmodifiable. The ->data field of the MSList points a PayloadType 
     967 * structure holding the codec information. 
     968 * It is possible to make copy of the list with ms_list_copy() in order to modify it 
     969 * (such as the order of codecs). 
     970**/ 
    772971const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc) 
    773972{ 
     
    12751474                                return FALSE; 
    12761475                        } 
     1476                        linphone_address_set_display_name(uri,NULL); 
    12771477                        linphone_address_set_username(uri,url); 
    12781478                        if (real_parsed_url!=NULL) *real_parsed_url=uri; 
     
    23492549} 
    23502550 
     2551void linphone_core_clear_call_logs(LinphoneCore *lc){ 
     2552        lc->missed_calls=0; 
     2553        ms_list_for_each(lc->call_logs,(void (*)(void*))linphone_call_log_destroy); 
     2554        lc->call_logs=ms_list_free(lc->call_logs); 
     2555} 
     2556 
    23512557static void toggle_video_preview(LinphoneCore *lc, bool_t val){ 
    23522558#ifdef VIDEO_ENABLED 
     
    27352941} 
    27362942 
    2737 void linphone_core_uninit(LinphoneCore *lc) 
     2943static void linphone_core_uninit(LinphoneCore *lc) 
    27382944{ 
    27392945        if (lc->call){ 
  • linphone/coreapi/linphonecore.h

    r793 r795  
    189189        char start_date[128]; 
    190190        int duration; 
     191        char *refkey; 
    191192        void *user_pointer; 
     193        struct _LinphoneCore *lc; 
    192194} LinphoneCallLog; 
    193195 
     
    197199void linphone_call_log_set_user_pointer(LinphoneCallLog *cl, void *up); 
    198200void *linphone_call_log_get_user_pointer(const LinphoneCallLog *cl); 
     201void linphone_call_log_set_ref_key(LinphoneCallLog *cl, const char *refkey); 
     202const char *linphone_call_log_get_ref_key(const LinphoneCallLog *cl); 
    199203char * linphone_call_log_to_str(LinphoneCallLog *cl); 
    200204 
     
    549553 
    550554LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable, 
    551                                                 const char *config_path, void* userdata); 
     555                                                const char *config_path, const char *factory_config, void* userdata); 
    552556 
    553557/* function to be periodically called in a main loop */ 
     
    730734/* returns a list of LinphoneCallLog */ 
    731735const MSList * linphone_core_get_call_logs(LinphoneCore *lc); 
     736void linphone_core_clear_call_logs(LinphoneCore *lc); 
    732737 
    733738/* video support */ 
  • linphone/coreapi/private.h

    r793 r795  
    191191int linphone_core_get_local_ip_for(const char *dest, char *result); 
    192192 
    193 void linphone_core_init(LinphoneCore *lc, const LinphoneCoreVTable *vtable, 
    194                                                 const char *config_path, void * userdata); 
    195 void linphone_core_uninit(LinphoneCore *lc); 
    196  
    197193#endif /* _PRIVATE_H */ 
  • linphone/gtk-glade/main.c

    r783 r795  
    161161static void linphone_gtk_init_liblinphone(const char *file){ 
    162162        linphone_core_set_user_agent("Linphone", LINPHONE_VERSION); 
    163         the_core=linphone_core_new(&vtable,file,NULL); 
     163        the_core=linphone_core_new(&vtable,file,NULL,NULL); 
    164164        linphone_core_set_waiting_callback(the_core,linphone_gtk_wait,NULL); 
    165165} 
  • linphone/po/fr.po

    r733 r795  
    10281028"Duration: %i mn %i sec\n" 
    10291029msgstr "" 
    1030 "%s le %sDe: %s\n" 
     1030"%s le %s\nDe: %s\n" 
    10311031"A destination de: %s\n" 
    10321032"Etat: %s\n" 
Note: See TracChangeset for help on using the changeset viewer.