* improved documentation

* update ms2
* javascript generator in progress
This commit is contained in:
Simon Morlat 2013-09-27 08:48:45 +02:00
parent 643dc7f9f6
commit f8bc426a19
8 changed files with 314 additions and 141 deletions

View file

@ -535,7 +535,7 @@ LINPHONE_PUBLIC const char *linphone_call_state_to_string(LinphoneCallState cs);
LINPHONE_PUBLIC LinphoneCore *linphone_call_get_core(const LinphoneCall *call);
LINPHONE_PUBLIC LinphoneCallState linphone_call_get_state(const LinphoneCall *call);
bool_t linphone_call_asked_to_autoanswer(LinphoneCall *call);
LINPHONE_PUBLIC const LinphoneAddress * linphone_core_get_current_call_remote_address(struct _LinphoneCore *lc);
LINPHONE_PUBLIC const LinphoneAddress * linphone_core_get_current_call_remote_address(LinphoneCore *lc);
LINPHONE_PUBLIC const LinphoneAddress * linphone_call_get_remote_address(const LinphoneCall *call);
LINPHONE_PUBLIC char *linphone_call_get_remote_address_as_string(const LinphoneCall *call);
LINPHONE_PUBLIC LinphoneCallDir linphone_call_get_dir(const LinphoneCall *call);
@ -694,7 +694,7 @@ LINPHONE_PUBLIC bool_t linphone_proxy_config_register_enabled(const LinphoneProx
LINPHONE_PUBLIC void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj);
LINPHONE_PUBLIC const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConfig *obj);
LINPHONE_PUBLIC void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *obj, const char *contact_params);
struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj);
LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj);
LINPHONE_PUBLIC bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg);
LINPHONE_PUBLIC const char * linphone_proxy_config_get_dial_prefix(const LinphoneProxyConfig *cfg);
@ -744,7 +744,7 @@ LINPHONE_PUBLIC LinphonePrivacyMask linphone_proxy_config_get_privacy(const Linp
**/
typedef struct _LinphoneAccountCreator{
struct _LinphoneCore *lc;
LinphoneCore *lc;
struct _SipSetupContext *ssctx;
char *username;
char *password;
@ -755,7 +755,7 @@ typedef struct _LinphoneAccountCreator{
bool_t succeeded;
}LinphoneAccountCreator;
LinphoneAccountCreator *linphone_account_creator_new(struct _LinphoneCore *core, const char *type);
LinphoneAccountCreator *linphone_account_creator_new(LinphoneCore *core, const char *type);
void linphone_account_creator_set_username(LinphoneAccountCreator *obj, const char *username);
void linphone_account_creator_set_password(LinphoneAccountCreator *obj, const char *password);
void linphone_account_creator_set_domain(LinphoneAccountCreator *obj, const char *domain);
@ -920,33 +920,38 @@ typedef enum _LinphoneGlobalState{
const char *linphone_global_state_to_string(LinphoneGlobalState gs);
/**
* Global state notification callback.
* @param lc
* @param gstate the global state
* @param message informational message.
*/
typedef void (*LinphoneGlobalStateCb)(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
/**Call state notification callback prototype*/
typedef void (*LinphoneGlobalStateCb)(struct _LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
/**Call state notification callback prototype*/
typedef void (*LinphoneCallStateCb)(struct _LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message);
typedef void (*LinphoneCallStateCb)(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message);
/**Call encryption changed callback prototype*/
typedef void (*CallEncryptionChangedCb)(struct _LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token);
typedef void (*CallEncryptionChangedCb)(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token);
/** @ingroup Proxies
* Registration state notification callback prototype
* */
typedef void (*LinphoneRegistrationStateCb)(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message);
typedef void (*LinphoneRegistrationStateCb)(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message);
/** Callback prototype */
typedef void (*ShowInterfaceCb)(struct _LinphoneCore *lc);
typedef void (*ShowInterfaceCb)(LinphoneCore *lc);
/** Callback prototype */
typedef void (*DisplayStatusCb)(struct _LinphoneCore *lc, const char *message);
typedef void (*DisplayStatusCb)(LinphoneCore *lc, const char *message);
/** Callback prototype */
typedef void (*DisplayMessageCb)(struct _LinphoneCore *lc, const char *message);
typedef void (*DisplayMessageCb)(LinphoneCore *lc, const char *message);
/** Callback prototype */
typedef void (*DisplayUrlCb)(struct _LinphoneCore *lc, const char *message, const char *url);
typedef void (*DisplayUrlCb)(LinphoneCore *lc, const char *message, const char *url);
/** Callback prototype */
typedef void (*LinphoneCoreCbFunc)(struct _LinphoneCore *lc,void * user_data);
typedef void (*LinphoneCoreCbFunc)(LinphoneCore *lc,void * user_data);
/**
* Report status change for a friend previously \link linphone_core_add_friend() added \endlink to #LinphoneCore.
* @param lc #LinphoneCore object .
* @param lf Updated #LinphoneFriend .
*/
typedef void (*NotifyPresenceReceivedCb)(struct _LinphoneCore *lc, LinphoneFriend * lf);
typedef void (*NotifyPresenceReceivedCb)(LinphoneCore *lc, LinphoneFriend * lf);
/**
* Reports that a new subscription request has been received and wait for a decision.
* <br> Status on this subscription request is notified by \link linphone_friend_set_inc_subscribe_policy() changing policy \endlink for this friend
@ -955,11 +960,11 @@ typedef void (*NotifyPresenceReceivedCb)(struct _LinphoneCore *lc, LinphoneFrien
* @param url of the subscriber
* Callback prototype
* */
typedef void (*NewSubscribtionRequestCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url);
typedef void (*NewSubscribtionRequestCb)(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
/** Callback prototype */
typedef void (*AuthInfoRequestedCb)(struct _LinphoneCore *lc, const char *realm, const char *username);
typedef void (*AuthInfoRequestedCb)(LinphoneCore *lc, const char *realm, const char *username);
/** Callback prototype */
typedef void (*CallLogUpdatedCb)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl);
typedef void (*CallLogUpdatedCb)(LinphoneCore *lc, struct _LinphoneCallLog *newcl);
/**
* Callback prototype
* @deprecated use #MessageReceived instead.
@ -980,24 +985,24 @@ typedef void (*TextMessageReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room,
typedef void (*MessageReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message);
/** Callback prototype */
typedef void (*DtmfReceivedCb)(struct _LinphoneCore* lc, LinphoneCall *call, int dtmf);
typedef void (*DtmfReceivedCb)(LinphoneCore* lc, LinphoneCall *call, int dtmf);
/** Callback prototype */
typedef void (*ReferReceivedCb)(struct _LinphoneCore *lc, const char *refer_to);
typedef void (*ReferReceivedCb)(LinphoneCore *lc, const char *refer_to);
/** Callback prototype */
typedef void (*BuddyInfoUpdatedCb)(struct _LinphoneCore *lc, LinphoneFriend *lf);
typedef void (*BuddyInfoUpdatedCb)(LinphoneCore *lc, LinphoneFriend *lf);
/** Callback prototype for in progress transfers. The new_call_state is the state of the call resulting of the transfer, at the other party. */
typedef void (*LinphoneTransferStateChangedCb)(struct _LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state);
typedef void (*LinphoneTransferStateChangedCb)(LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state);
/** Callback prototype for receiving quality statistics for calls*/
typedef void (*CallStatsUpdatedCb)(struct _LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats);
typedef void (*CallStatsUpdatedCb)(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats);
/** Callback prototype for receiving info messages*/
typedef void (*LinphoneInfoReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg);
typedef void (*LinphoneInfoReceivedCb)(LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg);
/**
* This structure holds all callbacks that the application should implement.
* None is mandatory.
**/
typedef struct _LinphoneVTable{
LinphoneGlobalStateCb global_state_changed; /**<Notifies globlal state changes*/
typedef struct _LinphoneCoreVTable{
LinphoneGlobalStateCb global_state_changed; /**<Notifies global state changes*/
LinphoneRegistrationStateCb registration_state_changed;/**<Notifies registration state changes*/
LinphoneCallStateCb call_state_changed;/**<Notifies call state changes*/
NotifyPresenceReceivedCb notify_presence_recv; /**< Notify received presence events*/
@ -1048,7 +1053,7 @@ typedef enum _LinphoneWaitingState{
LinphoneWaitingProgress,
LinphoneWaitingFinished
} LinphoneWaitingState;
typedef void * (*LinphoneWaitingCallback)(struct _LinphoneCore *lc, void *context, LinphoneWaitingState ws, const char *purpose, float progress);
typedef void * (*LinphoneWaitingCallback)(LinphoneCore *lc, void *context, LinphoneWaitingState ws, const char *purpose, float progress);
/* THE main API */

View file

@ -197,7 +197,7 @@ typedef struct _LinphonePresenceNote LinphonePresenceNote;
****************************************************************************/
/**
* @brief Creates a presence model specifying an activity.
* Creates a presence model specifying an activity.
* @param[in] activity The activity to set for the created presence model.
* @param[in] description An additional description of the activity (mainly useful for the 'other' activity). Set it to NULL to not add a description.
* @returns The created presence model, or NULL if an error occured.
@ -209,7 +209,7 @@ typedef struct _LinphonePresenceNote LinphonePresenceNote;
LINPHONE_PUBLIC LinphonePresenceModel * linphone_presence_model_new_with_activity(LinphonePresenceActivityType activity, const char *description);
/**
* @brief Creates a presence model specifying an activity and adding a note.
* Creates a presence model specifying an activity and adding a note.
* @param[in] activity The activity to set for the created presence model.
* @param[in] description An additional description of the activity (mainly useful for the 'other' activity). Set it to NULL to not add a description.
* @param[in] note An additional note giving additional information about the contact presence.
@ -223,14 +223,14 @@ LINPHONE_PUBLIC LinphonePresenceModel * linphone_presence_model_new_with_activit
LINPHONE_PUBLIC LinphonePresenceModel * linphone_presence_model_new_with_activity_and_note(LinphonePresenceActivityType activity, const char *description, const char *note, const char *lang);
/**
* @brief Gets the basic status of a presence model.
* Gets the basic status of a presence model.
* @param[in] model The #LinphonePresenceModel object to get the basic status from.
* @return The #LinphonePresenceBasicStatus of the #LinphonePresenceModel object given as parameter.
*/
LINPHONE_PUBLIC LinphonePresenceBasicStatus linphone_presence_model_get_basic_status(const LinphonePresenceModel *model);
/**
* @brief Sets the basic status of a presence model.
* Sets the basic status of a presence model.
* @param[in] model The #LinphonePresenceModel object for which to set the basic status.
* @param[in] basic_status The #LinphonePresenceBasicStatus to set for the #LinphonePresenceModel object.
* @return 0 if successful, a value < 0 in case of error.
@ -238,14 +238,14 @@ LINPHONE_PUBLIC LinphonePresenceBasicStatus linphone_presence_model_get_basic_st
LINPHONE_PUBLIC int linphone_presence_model_set_basic_status(LinphonePresenceModel *model, LinphonePresenceBasicStatus basic_status);
/**
* @brief Gets the timestamp of a presence model.
* Gets the timestamp of a presence model.
* @param[in] model The #LinphonePresenceModel object to get the timestamp from.
* @return The timestamp of the #LinphonePresenceModel object or -1 on error.
*/
LINPHONE_PUBLIC time_t linphone_presence_model_get_timestamp(const LinphonePresenceModel *model);
/**
* @brief Gets the contact of a presence model.
* Gets the contact of a presence model.
* @param[in] model The #LinphonePresenceModel object to get the contact from.
* @return A pointer to a dynamically allocated string containing the contact, or NULL if no contact is found.
*
@ -254,7 +254,7 @@ LINPHONE_PUBLIC time_t linphone_presence_model_get_timestamp(const LinphonePrese
LINPHONE_PUBLIC char * linphone_presence_model_get_contact(const LinphonePresenceModel *model);
/**
* @brief Sets the contact of a presence model.
* Sets the contact of a presence model.
* @param[in] model The #LinphonePresenceModel object for which to set the contact.
* @param[in] contact The contact string to set.
* @return 0 if successful, a value < 0 in case of error.
@ -262,14 +262,14 @@ LINPHONE_PUBLIC char * linphone_presence_model_get_contact(const LinphonePresenc
LINPHONE_PUBLIC int linphone_presence_model_set_contact(LinphonePresenceModel *model, const char *contact);
/**
* @brief Gets the first activity of a presence model (there is usually only one).
* Gets the first activity of a presence model (there is usually only one).
* @param[in] model The #LinphonePresenceModel object to get the activity from.
* @return A #LinphonePresenceActivity object if successful, NULL otherwise.
*/
LINPHONE_PUBLIC LinphonePresenceActivity * linphone_presence_model_get_activity(const LinphonePresenceModel *model);
/**
* @brief Sets the activity of a presence model (limits to only one activity).
* Sets the activity of a presence model (limits to only one activity).
* @param[in] model The #LinphonePresenceModel object for which to set the activity.
* @param[in] activity The #LinphonePresenceActivityType to set for the model.
* @param[in] description An additional description of the activity to set for the model. Can be NULL if no additional description is to be added.
@ -282,14 +282,14 @@ LINPHONE_PUBLIC LinphonePresenceActivity * linphone_presence_model_get_activity(
LINPHONE_PUBLIC int linphone_presence_model_set_activity(LinphonePresenceModel *model, LinphonePresenceActivityType activity, const char *description);
/**
* @brief Gets the number of activities included in the presence model.
* Gets the number of activities included in the presence model.
* @param[in] model The #LinphonePresenceModel object to get the number of activities from.
* @return The number of activities included in the #LinphonePresenceModel object.
*/
LINPHONE_PUBLIC unsigned int linphone_presence_model_nb_activities(const LinphonePresenceModel *model);
/**
* @brief Gets the nth activity of a presence model.
* Gets the nth activity of a presence model.
* @param[in] model The #LinphonePresenceModel object to get the activity from.
* @param[in] idx The index of the activity to get (the first activity having the index 0).
* @return A pointer to a #LinphonePresenceActivity object if successful, NULL otherwise.
@ -297,7 +297,7 @@ LINPHONE_PUBLIC unsigned int linphone_presence_model_nb_activities(const Linphon
LINPHONE_PUBLIC LinphonePresenceActivity * linphone_presence_model_get_nth_activity(const LinphonePresenceModel *model, unsigned int idx);
/**
* @brief Adds an activity to a presence model.
* Adds an activity to a presence model.
* @param[in] model The #LinphonePresenceModel object for which to add an activity.
* @param[in] activity The #LinphonePresenceActivity object to add to the model.
* @return 0 if successful, a value < 0 in case of error.
@ -305,14 +305,14 @@ LINPHONE_PUBLIC LinphonePresenceActivity * linphone_presence_model_get_nth_activ
LINPHONE_PUBLIC int linphone_presence_model_add_activity(LinphonePresenceModel *model, LinphonePresenceActivity *activity);
/**
* @brief Clears the activities of a presence model.
* Clears the activities of a presence model.
* @param[in] model The #LinphonePresenceModel object for which to clear the activities.
* @return 0 if successful, a value < 0 in case of error.
*/
LINPHONE_PUBLIC int linphone_presence_model_clear_activities(LinphonePresenceModel *model);
/**
* @brief Gets the first note of a presence model (there is usually only one).
* Gets the first note of a presence model (there is usually only one).
* @param[in] model The #LinphonePresenceModel object to get the note from.
* @param[in] lang The language of the note to get. Can be NULL to get a note that has no language specified or to get the first note whatever language it is written into.
* @return A pointer to a #LinphonePresenceNote object if successful, NULL otherwise.
@ -320,7 +320,7 @@ LINPHONE_PUBLIC int linphone_presence_model_clear_activities(LinphonePresenceMod
LINPHONE_PUBLIC LinphonePresenceNote * linphone_presence_model_get_note(const LinphonePresenceModel *model, const char *lang);
/**
* @brief Adds a note to a presence model.
* Adds a note to a presence model.
* @param[in] model The #LinphonePresenceModel object to add a note to.
* @param[in] note_content The note to be added to the presence model.
* @param[in] lang The language of the note to be added. Can be NULL if no language is to be specified for the note.
@ -331,7 +331,7 @@ LINPHONE_PUBLIC LinphonePresenceNote * linphone_presence_model_get_note(const Li
LINPHONE_PUBLIC int linphone_presence_model_add_note(LinphonePresenceModel *model, const char *note_content, const char *lang);
/**
* @brief Clears all the notes of a presence model.
* Clears all the notes of a presence model.
* @param[in] model The #LinphonePresenceModel for which to clear notes.
* @return 0 if successful, a value < 0 in case of error.
*/
@ -343,7 +343,7 @@ LINPHONE_PUBLIC int linphone_presence_model_clear_notes(LinphonePresenceModel *m
****************************************************************************/
/**
* @brief Creates a default presence model.
* Creates a default presence model.
* @returns The created presence model, NULL on error.
* @see linphone_presence_model_new_with_activity
* @see linphone_presence_model_new_with_activity_and_note
@ -353,14 +353,14 @@ LINPHONE_PUBLIC int linphone_presence_model_clear_notes(LinphonePresenceModel *m
LINPHONE_PUBLIC LinphonePresenceModel * linphone_presence_model_new(void);
/**
* @brief Gets the number of services included in the presence model.
* Gets the number of services included in the presence model.
* @param[in] model The #LinphonePresenceModel object to get the number of services from.
* @return The number of services included in the #LinphonePresenceModel object.
*/
LINPHONE_PUBLIC unsigned int linphone_presence_model_nb_services(const LinphonePresenceModel *model);
/**
* @brief Gets the nth service of a presence model.
* Gets the nth service of a presence model.
* @param[in] model The #LinphonePresenceModel object to get the service from.
* @param[in] idx The index of the service to get (the first service having the index 0).
* @return A pointer to a #LinphonePresenceService object if successful, NULL otherwise.
@ -368,7 +368,7 @@ LINPHONE_PUBLIC unsigned int linphone_presence_model_nb_services(const LinphoneP
LINPHONE_PUBLIC LinphonePresenceService * linphone_presence_model_get_nth_service(const LinphonePresenceModel *model, unsigned int idx);
/**
* @brief Adds a service to a presence model.
* Adds a service to a presence model.
* @param[in] model The #LinphonePresenceModel object for which to add a service.
* @param[in] service The #LinphonePresenceService object to add to the model.
* @return 0 if successful, a value < 0 in case of error.
@ -376,21 +376,21 @@ LINPHONE_PUBLIC LinphonePresenceService * linphone_presence_model_get_nth_servic
LINPHONE_PUBLIC int linphone_presence_model_add_service(LinphonePresenceModel *model, LinphonePresenceService *service);
/**
* @brief Clears the services of a presence model.
* Clears the services of a presence model.
* @param[in] model The #LinphonePresenceModel object for which to clear the services.
* @return 0 if successful, a value < 0 in case of error.
*/
LINPHONE_PUBLIC int linphone_presence_model_clear_services(LinphonePresenceModel *model);
/**
* @brief Gets the number of persons included in the presence model.
* Gets the number of persons included in the presence model.
* @param[in] model The #LinphonePresenceModel object to get the number of persons from.
* @return The number of persons included in the #LinphonePresenceModel object.
*/
LINPHONE_PUBLIC unsigned int linphone_presence_model_nb_persons(const LinphonePresenceModel *model);
/**
* @brief Gets the nth person of a presence model.
* Gets the nth person of a presence model.
* @param[in] model The #LinphonePresenceModel object to get the person from.
* @param[in] idx The index of the person to get (the first person having the index 0).
* @return A pointer to a #LinphonePresencePerson object if successful, NULL otherwise.
@ -398,7 +398,7 @@ LINPHONE_PUBLIC unsigned int linphone_presence_model_nb_persons(const LinphonePr
LINPHONE_PUBLIC LinphonePresencePerson * linphone_presence_model_get_nth_person(const LinphonePresenceModel *model, unsigned int idx);
/**
* @brief Adds a person to a presence model.
* Adds a person to a presence model.
* @param[in] model The #LinphonePresenceModel object for which to add a person.
* @param[in] person The #LinphonePresencePerson object to add to the model.
* @return 0 if successful, a value < 0 in case of error.
@ -406,7 +406,7 @@ LINPHONE_PUBLIC LinphonePresencePerson * linphone_presence_model_get_nth_person(
LINPHONE_PUBLIC int linphone_presence_model_add_person(LinphonePresenceModel *model, LinphonePresencePerson *person);
/**
* @brief Clears the persons of a presence model.
* Clears the persons of a presence model.
* @param[in] model The #LinphonePresenceModel object for which to clear the persons.
* @return 0 if successful, a value < 0 in case of error.
*/
@ -418,7 +418,7 @@ LINPHONE_PUBLIC int linphone_presence_model_clear_persons(LinphonePresenceModel
****************************************************************************/
/**
* @brief Creates a presence service.
* Creates a presence service.
* @param[in] id The id of the presence service to be created. Can be NULL to generate it automatically.
* @param[in] basic_status The #LinphonePresenceBasicStatus to set for the #LinphonePresenceService object.
* @param[in] contact The contact string to set.
@ -429,7 +429,7 @@ LINPHONE_PUBLIC int linphone_presence_model_clear_persons(LinphonePresenceModel
LINPHONE_PUBLIC LinphonePresenceService * linphone_presence_service_new(const char *id, LinphonePresenceBasicStatus, const char *contact);
/**
* @brief Gets the id of a presence service.
* Gets the id of a presence service.
* @param[in] service The #LinphonePresenceService object to get the id from.
* @return A pointer to a dynamically allocated string containing the id, or NULL in case of error.
*
@ -438,7 +438,7 @@ LINPHONE_PUBLIC LinphonePresenceService * linphone_presence_service_new(const ch
LINPHONE_PUBLIC char * linphone_presence_service_get_id(const LinphonePresenceService *service);
/**
* @brief Sets the id of a presence service.
* Sets the id of a presence service.
* @param[in] service The #LinphonePresenceService object for which to set the id.
* @param[in] id The id string to set. Can be NULL to generate it automatically.
* @return 0 if successful, a value < 0 in case of error.
@ -446,14 +446,14 @@ LINPHONE_PUBLIC char * linphone_presence_service_get_id(const LinphonePresenceSe
LINPHONE_PUBLIC int linphone_presence_service_set_id(LinphonePresenceService *service, const char *id);
/**
* @brief Gets the basic status of a presence service.
* Gets the basic status of a presence service.
* @param[in] service The #LinphonePresenceService object to get the basic status from.
* @return The #LinphonePresenceBasicStatus of the #LinphonePresenceService object given as parameter.
*/
LINPHONE_PUBLIC LinphonePresenceBasicStatus linphone_presence_service_get_basic_status(const LinphonePresenceService *service);
/**
* @brief Sets the basic status of a presence service.
* Sets the basic status of a presence service.
* @param[in] service The #LinphonePresenceService object for which to set the basic status.
* @param[in] basic_status The #LinphonePresenceBasicStatus to set for the #LinphonePresenceService object.
* @return 0 if successful, a value < 0 in case of error.
@ -461,7 +461,7 @@ LINPHONE_PUBLIC LinphonePresenceBasicStatus linphone_presence_service_get_basic_
LINPHONE_PUBLIC int linphone_presence_service_set_basic_status(LinphonePresenceService *service, LinphonePresenceBasicStatus basic_status);
/**
* @brief Gets the contact of a presence service.
* Gets the contact of a presence service.
* @param[in] service The #LinphonePresenceService object to get the contact from.
* @return A pointer to a dynamically allocated string containing the contact, or NULL if no contact is found.
*
@ -470,7 +470,7 @@ LINPHONE_PUBLIC int linphone_presence_service_set_basic_status(LinphonePresenceS
LINPHONE_PUBLIC char * linphone_presence_service_get_contact(const LinphonePresenceService *service);
/**
* @brief Sets the contact of a presence service.
* Sets the contact of a presence service.
* @param[in] service The #LinphonePresenceService object for which to set the contact.
* @param[in] contact The contact string to set.
* @return 0 if successful, a value < 0 in case of error.
@ -478,14 +478,14 @@ LINPHONE_PUBLIC char * linphone_presence_service_get_contact(const LinphonePrese
LINPHONE_PUBLIC int linphone_presence_service_set_contact(LinphonePresenceService *service, const char *contact);
/**
* @brief Gets the number of notes included in the presence service.
* Gets the number of notes included in the presence service.
* @param[in] service The #LinphonePresenceService object to get the number of notes from.
* @return The number of notes included in the #LinphonePresenceService object.
*/
LINPHONE_PUBLIC unsigned int linphone_presence_service_nb_notes(const LinphonePresenceService *service);
/**
* @brief Gets the nth note of a presence service.
* Gets the nth note of a presence service.
* @param[in] service The #LinphonePresenceService object to get the note from.
* @param[in] idx The index of the note to get (the first note having the index 0).
* @return A pointer to a #LinphonePresenceNote object if successful, NULL otherwise.
@ -493,7 +493,7 @@ LINPHONE_PUBLIC unsigned int linphone_presence_service_nb_notes(const LinphonePr
LINPHONE_PUBLIC LinphonePresenceNote * linphone_presence_service_get_nth_note(const LinphonePresenceService *service, unsigned int idx);
/**
* @brief Adds a note to a presence service.
* Adds a note to a presence service.
* @param[in] service The #LinphonePresenceService object for which to add a note.
* @param[in] note The #LinphonePresenceNote object to add to the service.
* @return 0 if successful, a value < 0 in case of error.
@ -501,7 +501,7 @@ LINPHONE_PUBLIC LinphonePresenceNote * linphone_presence_service_get_nth_note(co
LINPHONE_PUBLIC int linphone_presence_service_add_note(LinphonePresenceService *service, LinphonePresenceNote *note);
/**
* @brief Clears the notes of a presence service.
* Clears the notes of a presence service.
* @param[in] service The #LinphonePresenceService object for which to clear the notes.
* @return 0 if successful, a value < 0 in case of error.
*/
@ -513,14 +513,14 @@ LINPHONE_PUBLIC int linphone_presence_service_clear_notes(LinphonePresenceServic
****************************************************************************/
/**
* @brief Creates a presence person.
* Creates a presence person.
* @param[in] id The id of the presence person to be created. Can be NULL to generate it automatically.
* @returns The created presence person, NULL on error.
*/
LINPHONE_PUBLIC LinphonePresencePerson * linphone_presence_person_new(const char *id);
/**
* @brief Gets the id of a presence person.
* Gets the id of a presence person.
* @param[in] person The #LinphonePresencePerson object to get the id from.
* @return A pointer to a dynamically allocated string containing the id, or NULL in case of error.
*
@ -529,7 +529,7 @@ LINPHONE_PUBLIC LinphonePresencePerson * linphone_presence_person_new(const char
LINPHONE_PUBLIC char * linphone_presence_person_get_id(const LinphonePresencePerson *person);
/**
* @brief Sets the id of a presence person.
* Sets the id of a presence person.
* @param[in] person The #LinphonePresencePerson object for which to set the id.
* @param[in] id The id string to set. Can be NULL to generate it automatically.
* @return 0 if successful, a value < 0 in case of error.
@ -537,14 +537,14 @@ LINPHONE_PUBLIC char * linphone_presence_person_get_id(const LinphonePresencePer
LINPHONE_PUBLIC int linphone_presence_person_set_id(LinphonePresencePerson *person, const char *id);
/**
* @brief Gets the number of activities included in the presence person.
* Gets the number of activities included in the presence person.
* @param[in] person The #LinphonePresencePerson object to get the number of activities from.
* @return The number of activities included in the #LinphonePresencePerson object.
*/
LINPHONE_PUBLIC unsigned int linphone_presence_person_nb_activities(const LinphonePresencePerson *person);
/**
* @brief Gets the nth activity of a presence person.
* Gets the nth activity of a presence person.
* @param[in] person The #LinphonePresencePerson object to get the activity from.
* @param[in] idx The index of the activity to get (the first activity having the index 0).
* @return A pointer to a #LinphonePresenceActivity object if successful, NULL otherwise.
@ -552,7 +552,7 @@ LINPHONE_PUBLIC unsigned int linphone_presence_person_nb_activities(const Linpho
LINPHONE_PUBLIC LinphonePresenceActivity * linphone_presence_person_get_nth_activity(const LinphonePresencePerson *person, unsigned int idx);
/**
* @brief Adds an activity to a presence person.
* Adds an activity to a presence person.
* @param[in] person The #LinphonePresencePerson object for which to add an activity.
* @param[in] activity The #LinphonePresenceActivity object to add to the person.
* @return 0 if successful, a value < 0 in case of error.
@ -560,21 +560,21 @@ LINPHONE_PUBLIC LinphonePresenceActivity * linphone_presence_person_get_nth_acti
LINPHONE_PUBLIC int linphone_presence_person_add_activity(LinphonePresencePerson *person, LinphonePresenceActivity *activity);
/**
* @brief Clears the activities of a presence person.
* Clears the activities of a presence person.
* @param[in] person The #LinphonePresencePerson object for which to clear the activities.
* @return 0 if successful, a value < 0 in case of error.
*/
LINPHONE_PUBLIC int linphone_presence_person_clear_activities(LinphonePresencePerson *person);
/**
* @brief Gets the number of notes included in the presence person.
* Gets the number of notes included in the presence person.
* @param[in] person The #LinphonePresencePerson object to get the number of notes from.
* @return The number of notes included in the #LinphonePresencePerson object.
*/
LINPHONE_PUBLIC unsigned int linphone_presence_person_nb_notes(const LinphonePresencePerson *person);
/**
* @brief Gets the nth note of a presence person.
* Gets the nth note of a presence person.
* @param[in] person The #LinphonePresencePerson object to get the note from.
* @param[in] idx The index of the note to get (the first note having the index 0).
* @return A pointer to a #LinphonePresenceNote object if successful, NULL otherwise.
@ -582,7 +582,7 @@ LINPHONE_PUBLIC unsigned int linphone_presence_person_nb_notes(const LinphonePre
LINPHONE_PUBLIC LinphonePresenceNote * linphone_presence_person_get_nth_note(const LinphonePresencePerson *person, unsigned int idx);
/**
* @brief Adds a note to a presence person.
* Adds a note to a presence person.
* @param[in] person The #LinphonePresencePerson object for which to add a note.
* @param[in] note The #LinphonePresenceNote object to add to the person.
* @return 0 if successful, a value < 0 in case of error.
@ -590,21 +590,21 @@ LINPHONE_PUBLIC LinphonePresenceNote * linphone_presence_person_get_nth_note(con
LINPHONE_PUBLIC int linphone_presence_person_add_note(LinphonePresencePerson *person, LinphonePresenceNote *note);
/**
* @brief Clears the notes of a presence person.
* Clears the notes of a presence person.
* @param[in] person The #LinphonePresencePerson object for which to clear the notes.
* @return 0 if successful, a value < 0 in case of error.
*/
LINPHONE_PUBLIC int linphone_presence_person_clear_notes(LinphonePresencePerson *person);
/**
* @brief Gets the number of activities notes included in the presence person.
* Gets the number of activities notes included in the presence person.
* @param[in] person The #LinphonePresencePerson object to get the number of activities notes from.
* @return The number of activities notes included in the #LinphonePresencePerson object.
*/
LINPHONE_PUBLIC unsigned int linphone_presence_person_nb_activities_notes(const LinphonePresencePerson *person);
/**
* @brief Gets the nth activities note of a presence person.
* Gets the nth activities note of a presence person.
* @param[in] person The #LinphonePresencePerson object to get the activities note from.
* @param[in] idx The index of the activities note to get (the first note having the index 0).
* @return A pointer to a #LinphonePresenceNote object if successful, NULL otherwise.
@ -612,7 +612,7 @@ LINPHONE_PUBLIC unsigned int linphone_presence_person_nb_activities_notes(const
LINPHONE_PUBLIC LinphonePresenceNote * linphone_presence_person_get_nth_activities_note(const LinphonePresencePerson *person, unsigned int idx);
/**
* @brief Adds an activities note to a presence person.
* Adds an activities note to a presence person.
* @param[in] person The #LinphonePresencePerson object for which to add an activities note.
* @param[in] note The #LinphonePresenceNote object to add to the person.
* @return 0 if successful, a value < 0 in case of error.
@ -620,7 +620,7 @@ LINPHONE_PUBLIC LinphonePresenceNote * linphone_presence_person_get_nth_activiti
LINPHONE_PUBLIC int linphone_presence_person_add_activities_note(LinphonePresencePerson *person, LinphonePresenceNote *note);
/**
* @brief Clears the activities notes of a presence person.
* Clears the activities notes of a presence person.
* @param[in] person The #LinphonePresencePerson object for which to clear the activities notes.
* @return 0 if successful, a value < 0 in case of error.
*/
@ -632,7 +632,7 @@ LINPHONE_PUBLIC int linphone_presence_person_clear_activities_notes(LinphonePres
****************************************************************************/
/**
* @brief Creates a presence activity.
* Creates a presence activity.
* @param[in] acttype The #LinphonePresenceActivityType to set for the activity.
* @param[in] description An additional description of the activity to set for the activity. Can be NULL if no additional description is to be added.
* @returns The created presence activity, NULL on error.
@ -640,7 +640,7 @@ LINPHONE_PUBLIC int linphone_presence_person_clear_activities_notes(LinphonePres
LINPHONE_PUBLIC LinphonePresenceActivity * linphone_presence_activity_new(LinphonePresenceActivityType acttype, const char *description);
/**
* @brief Gets the string representation of a presence activity.
* Gets the string representation of a presence activity.
* @param[in] activity A pointer to the #LinphonePresenceActivity object for which to get a string representation.
* @return A pointer a dynamically allocated string representing the given activity.
*
@ -649,14 +649,14 @@ LINPHONE_PUBLIC LinphonePresenceActivity * linphone_presence_activity_new(Linpho
LINPHONE_PUBLIC char * linphone_presence_activity_to_string(const LinphonePresenceActivity * activity);
/**
* @brief Gets the activity type of a presence activity.
* Gets the activity type of a presence activity.
* @param[in] activity A pointer to the #LinphonePresenceActivity for which to get the type.
* @return The #LinphonePresenceActivityType of the activity.
*/
LINPHONE_PUBLIC LinphonePresenceActivityType linphone_presence_activity_get_type(const LinphonePresenceActivity *activity);
/**
* @brief Sets the type of activity of a presence activity.
* Sets the type of activity of a presence activity.
* @param[in] activity The #LinphonePresenceActivity for which to set for the activity type.
* @param[in] acttype The activity type to set for the activity.
* @return 0 if successful, a value < 0 in case of error.
@ -664,14 +664,14 @@ LINPHONE_PUBLIC LinphonePresenceActivityType linphone_presence_activity_get_type
LINPHONE_PUBLIC int linphone_presence_activity_set_type(LinphonePresenceActivity *activity, LinphonePresenceActivityType acttype);
/**
* @brief Gets the description of a presence activity.
* Gets the description of a presence activity.
* @param[in] activity A pointer to the #LinphonePresenceActivity for which to get the description.
* @return A pointer to the description string of the presence activity, or NULL if no description is specified.
*/
LINPHONE_PUBLIC const char * linphone_presence_activity_get_description(const LinphonePresenceActivity *activity);
/**
* @brief Sets the description of a presence activity.
* Sets the description of a presence activity.
* @param[in] activity The #LinphonePresenceActivity object for which to set the description.
* @param[in] description An additional description of the activity. Can be NULL if no additional description is to be added.
* @return 0 if successful, a value < 0 in case of error.
@ -684,7 +684,7 @@ LINPHONE_PUBLIC int linphone_presence_activity_set_description(LinphonePresenceA
****************************************************************************/
/**
* @brief Creates a presence note.
* Creates a presence note.
* @param[in] content The content of the note to be created.
* @param[in] lang The language of the note to be created. Can be NULL if no language is to be specified for the note.
* @returns The created presence note, NULL on error.
@ -692,14 +692,14 @@ LINPHONE_PUBLIC int linphone_presence_activity_set_description(LinphonePresenceA
LINPHONE_PUBLIC LinphonePresenceNote * linphone_presence_note_new(const char *content, const char *lang);
/**
* @brief Gets the content of a presence note.
* Gets the content of a presence note.
* @param[in] note A pointer to the #LinphonePresenceNote for which to get the content.
* @return A pointer to the content of the presence note.
*/
LINPHONE_PUBLIC const char * linphone_presence_note_get_content(const LinphonePresenceNote *note);
/**
* @brief Sets the content of a presence note.
* Sets the content of a presence note.
* @param[in] note The #LinphonePresenceNote object for which to set the content.
* @param[in] content The content of the note.
* @return 0 if successful, a value < 0 in case of error.
@ -707,14 +707,14 @@ LINPHONE_PUBLIC const char * linphone_presence_note_get_content(const LinphonePr
LINPHONE_PUBLIC int linphone_presence_note_set_content(LinphonePresenceNote *note, const char *content);
/**
* @brief Gets the language of a presence note.
* Gets the language of a presence note.
* @param[in] note A pointer to the #LinphonePresenceNote for which to get the language.
* @return A pointer to the language string of the presence note, or NULL if no language is specified.
*/
LINPHONE_PUBLIC const char * linphone_presence_note_get_lang(const LinphonePresenceNote *note);
/**
* @brief Sets the language of a presence note.
* Sets the language of a presence note.
* @param[in] note The #LinphonePresenceNote object for which to set the language.
* @param[in] lang The language of the note.
* @return 0 if successful, a value < 0 in case of error.

View file

@ -260,11 +260,11 @@ void linphone_proxy_config_edit(LinphoneProxyConfig *obj){
}
}
void linphone_proxy_config_apply(LinphoneProxyConfig *obj,LinphoneCore *lc)
{
void linphone_proxy_config_apply(LinphoneProxyConfig *obj,LinphoneCore *lc){
obj->lc=lc;
linphone_proxy_config_done(obj);
}
LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *obj){
LinphoneAddress *ret=NULL;
LinphoneAddress *proxy=linphone_address_new(obj->reg_proxy);
@ -312,38 +312,13 @@ LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *obj){
}
#endif //BUILD_UPNP
#ifndef USE_BELLESIP
if(localip == NULL) {
char localip_tmp[LINPHONE_IPADDR_SIZE] = {'\0'};
localip = localip_tmp;
linphone_core_get_local_ip(obj->lc,host,localip_tmp);
}
if(localport == -1) {
localport = linphone_core_get_sip_port(obj->lc);
}
{
LCSipTransports tr;
linphone_core_get_sip_transports(obj->lc,&tr);
if (tr.udp_port <= 0) {
if (tr.tcp_port>0) {
sal_address_set_param(contact,"transport","tcp");
} else if (tr.tls_port>0) {
sal_address_set_param(contact,"transport","tls");
}
}
}
#endif
linphone_address_set_port(contact,localport);
linphone_address_set_domain(contact,localip);
linphone_address_set_display_name(contact,NULL);
#ifndef USE_BELLESIP
ret = linphone_address_as_string(contact);
linphone_address_destroy(contact);
#else
ret=contact;
#endif /*USE_BELLESIP*/
linphone_address_destroy (proxy);
ms_free(tmp);
}

@ -1 +1 @@
Subproject commit 8097db23c50a476593cf912f0c554ca4e391c7e3
Subproject commit dbe58747533b5e2b3e3c25009f483158e2b0cde9

View file

@ -28,6 +28,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif
string to_lower(const string &str){
string res=str;
for(string::iterator it=res.begin();it!=res.end();++it){
*it=tolower(*it);
}
return res;
}
CplusplusGenerator::CplusplusGenerator(){
}
@ -42,17 +50,25 @@ void CplusplusGenerator::generate(Project *proj){
for_each(classes.begin(),classes.end(),bind1st(mem_fun(&CplusplusGenerator::writeClass),this));
}
void CplusplusGenerator::writeEnumMember(ConstField *cf, bool isLast){
writeTabs(1);
mOutfile<<cf->getName();
if (!isLast) mOutfile<<",";
if (!cf->getHelp().empty()) mOutfile<<"\t/**< "<<cf->getHelp()<<" */";
mOutfile<<endl;
}
void CplusplusGenerator::writeClass(Class *klass){
ostringstream filename;
if (klass->getType()!=Type::Class) return;
filename<<mCurProj->getName()<<"/"<<klass->getName()<<".hh";
mOutfile.open(filename.str().c_str());
if (!mOutfile.is_open()){
cerr<<"Could not write into "<<filename.str()<<endl;
return;
}
const list<Method*> &methods=klass->getMethods();
list<Method*> methods=klass->getMethods();
list<ConstField*> constFields=klass->getConstFields();
mCurClass=klass;
mOutfile<<"/* Wrapper generated by lp-gen-wrappers, do not edit*/"<<endl;
mOutfile<<endl;
@ -60,10 +76,20 @@ void CplusplusGenerator::writeClass(Class *klass){
mOutfile<<endl;
if (!mCurProj->getName().empty())
mOutfile<<"namespace "<<mCurProj->getName()<<"{"<<endl<<endl;
mOutfile<<"class "<<klass->getName()<<"{"<<endl;
mOutfile<<"public:"<<endl;
for_each(methods.begin(),methods.end(),bind1st(mem_fun(&CplusplusGenerator::writeMethod),this));
mOutfile<<"}"<<endl<<endl;
if (klass->getType()==Type::Enum){
mOutfile<<"enum "<<klass->getName()<<"{"<<endl;
list<ConstField*>::iterator cfit,next;
for (cfit=constFields.begin();cfit!=constFields.end();){
ConstField *cf=*cfit;
writeEnumMember(cf,++cfit==constFields.end());
}
}else{
mOutfile<<"class "<<klass->getName()<<"{"<<endl;
mOutfile<<"public:"<<endl;
for_each(methods.begin(),methods.end(),bind1st(mem_fun(&CplusplusGenerator::writeMethod),this));
}
mOutfile<<"};"<<endl<<endl;
if (!mCurProj->getName().empty())
mOutfile<<"} //end of namespace "<<mCurProj->getName()<<endl;
mOutfile<<endl;
@ -154,29 +180,102 @@ void JavascriptGenerator::generate(Project *proj){
list<Class*> classes=proj->getClasses();
mCurProj=proj;
#ifndef WIN32
unlink(proj->getName().c_str());
mkdir(proj->getName().c_str(),S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IROTH);
remove(to_lower(proj->getName()).c_str());
mkdir(to_lower(proj->getName()).c_str(),S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IROTH);
#else
_mkdir(proj->getName().c_str());
_mkdir(to_lower(proj->getName()).c_str());
#endif
for_each(classes.begin(),classes.end(),bind1st(mem_fun(&JavascriptGenerator::writeClass),this));
}
void JavascriptGenerator::writeClass(Class *klass){
ostringstream filename;
if (klass->getType()!=Type::Class) return;
filename<<mCurProj->getName()<<"/"<<klass->getName()<<".js";
/*write a file for the namespace*/
filename<<to_lower(mCurProj->getName())<<"/"<<to_lower(mCurProj->getName())<<".js";
mOutfile.open(filename.str().c_str());
if (!mOutfile.is_open()){
cerr<<"Could not write into "<<filename.str()<<endl;
return;
}
mOutfile<<"/**"<<endl;
mOutfile<<" * Namespace for non-external variables and objects."<<endl;
mOutfile<<" * @namespace "<<mCurProj->getName()<<endl;
mOutfile<<"**/"<<endl;
mOutfile<<"var "<<proj->getName()<<" = {};"<<endl;
mOutfile.close();
for_each(classes.begin(),classes.end(),bind1st(mem_fun(&JavascriptGenerator::writeEnum),this));
for_each(classes.begin(),classes.end(),bind1st(mem_fun(&JavascriptGenerator::writeClass),this));
}
void JavascriptGenerator::writeEnum(Class *klass){
if (klass->getType()!=Type::Enum) return;
ostringstream filename;
list<ConstField*> members=klass->getConstFields();
list<ConstField*>::iterator it;
string enum_name=klass->getName();
int value=0;
if (strncasecmp(enum_name.c_str(),mCurProj->getName().c_str(),mCurProj->getName().size())==0){
//since enum is part of the namespace, drop the namespace part of the enum if any.
enum_name.erase(0,mCurProj->getName().size());
}
filename<<to_lower(mCurProj->getName())<<"/"<<to_lower(enum_name)<<".js";
mOutfile.open(filename.str().c_str());
if (!mOutfile.is_open()){
cerr<<"Could not write into "<<filename.str()<<endl;
return;
}
mOutfile<<"/* Wrapper generated by lp-gen-wrappers, do not edit*/"<<endl<<endl;
mOutfile<<"var "<<mCurProj->getName()<<" = "<<mCurProj->getName()<<" || {};"<<endl;
mOutfile<<"/**"<<endl;
writeHelpComment(klass->getHelp(),0);
mOutfile<<endl;
mOutfile<<" * "<<"@readonly"<<endl;
mOutfile<<" * "<<"@enum {number}"<<endl;
mOutfile<<"**/"<<endl;
mOutfile<<mCurProj->getName()<<"."<<enum_name<<" = {"<<endl;
string prefix=ConstField::getCommonPrefix(members);
size_t prefix_size=prefix.size();
for(it=members.begin();it!=members.end();value++){
ConstField *cf=(*it);
if (!cf->getHelp().empty()){
writeTabs(1);
mOutfile<<"/**"<<endl;
writeHelpComment(cf->getHelp(),1);
mOutfile<<endl;
writeTabs(1);
mOutfile<<"*/"<<endl;
}
writeTabs(1);
mOutfile<<cf->getName().substr(prefix_size,string::npos)<<" : "<<value;
if (++it!=members.end()) mOutfile<<",";
mOutfile<<endl;
}
mOutfile<<"};"<<endl;
mOutfile.close();
}
void JavascriptGenerator::writeClass(Class *klass){
ostringstream filename;
if (klass->getType()==Type::Enum) {
return;
}
filename<<to_lower(mCurProj->getName())<<"/"<<to_lower(klass->getName())<<".js";
mOutfile.open(filename.str().c_str());
if (!mOutfile.is_open()){
cerr<<"Could not write into "<<filename.str()<<endl;
return;
}
const list<Method*> &methods=klass->getMethods();
mCurClass=klass;
mOutfile<<"/* Wrapper generated by lp-gen-wrappers, do not edit*/"<<endl;
mOutfile<<endl;
const list<Method*> &methods=klass->getMethods();
//if (!mCurProj->getName().empty())
// mOutfile<<"namespace "<<mCurProj->getName()<<"{"<<endl<<endl;
mOutfile<<"/**"<<endl;
@ -239,11 +338,12 @@ void JavascriptGenerator::writeTabs(int ntabs){
void JavascriptGenerator::writeHelpComment(const std::string &comment, int ntabs){
size_t i;
int curindex=0;
writeTabs(ntabs);
mOutfile<<" * ";
for(i=0;i<comment.size();i++,curindex++){
if (comment[i]=='\n' || (curindex>100 && comment[i]==' ')){
mOutfile<<endl;
writeTabs(ntabs);
mOutfile<<" * ";
curindex=0;
}else mOutfile<<comment[i];
@ -251,6 +351,7 @@ void JavascriptGenerator::writeHelpComment(const std::string &comment, int ntabs
}
void JavascriptGenerator::writeProperty(Property *prop){
if (prop->getName()=="userData" || prop->getName()=="userPointer") return;
mOutfile<<"/**"<<endl;
writeHelpComment(prop->getHelp(),0);
mOutfile<<endl;

View file

@ -40,6 +40,7 @@ private:
void writeTabs(int ntabs);
void writeHelpComment(const std::string &comment, int ntabs);
void writeMethod(Method *method);
void writeEnumMember(ConstField *cf, bool isLast);
ofstream mOutfile;
Project *mCurProj;
Class *mCurClass;
@ -51,6 +52,7 @@ public:
virtual void generate(Project *proj);
private:
void writeClass(Class *klass);
void writeEnum(Class *klass);
void writeType(Type *type);
void writeArgument(Argument *arg, bool isReturn=false);
void writeTabs(int ntabs);
@ -62,5 +64,6 @@ private:
Class *mCurClass;
};
string to_lower(const string &str);
#endif

View file

@ -250,6 +250,22 @@ static void parseFunction(Project *proj, xmlNode *node){
}
}
static void parseEnum(Project *proj, XmlNode node){
string name=node.getChild("name").getText();
if (name[0]=='_') name.erase(0,1);
Class *klass=proj->getClass(name);
klass->setHelp(node.getChild("detaileddescription").getChild("para").getText());
list<XmlNode> enumValues=node.getChildren("enumvalue");
list<XmlNode>::iterator it;
for (it=enumValues.begin();it!=enumValues.end();++it){
ConstField *cf=new ConstField(Type::getType("int"),(*it).getChild("name").getText());
cf->setHelp((*it).getChild("detaileddescription").getChild("para").getText());
klass->addConstField(cf);
}
}
static void parseTypedef(Project *proj, xmlNode *node){
XmlNode tdef(node);
string typecontent=tdef.getChild("type").getText();
@ -278,6 +294,8 @@ static void parseMemberDef(Project *proj, xmlNode *node){
parseFunction(proj,node);
}else if (kind=="typedef"){
parseTypedef(proj,node);
}else if (kind=="enum"){
parseEnum(proj,node);
}
}
@ -321,7 +339,7 @@ static int parse_file(Project *proj, const char *filename){
int main(int argc, char *argv[]){
int i;
Project *proj=new Project();
string projectName="wrapper";
OutputGenerator *gen=NULL;
list<string> files;
list<string>::iterator it;
@ -330,15 +348,18 @@ int main(int argc, char *argv[]){
for(i=1;i<argc;i++){
if (strcmp(argv[i],"--help")==0){
fprintf(stderr,"%s: [--help] --output (c++) file1 file2...\nParses xml files generated by doxygen to output wrappers in a specified language.\n",argv[0]);
fprintf(stderr,"%s: [--help] --output (c++, javascript) --project <project name> file1 file2...\nParses xml files generated by doxygen to output wrappers in a specified language.\n",argv[0]);
return -1;
}if (strcmp(argv[i],"--output")==0){
}else if (strcmp(argv[i],"--output")==0){
i++;
if (strcmp(argv[i],"c++")==0){
gen=new CplusplusGenerator();
}else if (strcmp(argv[i],"javascript")==0){
gen=new JavascriptGenerator();
}
}else if (strcmp(argv[i],"--project")==0){
i++;
projectName=argv[i];
}else{
files.push_back(argv[i]);
}
@ -348,7 +369,7 @@ int main(int argc, char *argv[]){
cerr<<"No output generator selected !"<<endl;
return -1;
}
Project *proj=new Project(projectName);
for(it=files.begin();it!=files.end();it++){
if (parse_file(proj,(*it).c_str())==-1){
cerr<<"Parsing aborted."<<endl;

View file

@ -270,6 +270,65 @@ private:
string mHelp;
};
class ConstField{
public:
ConstField(Type *type, const string &name, const string &value="") : mType(type), mName(name), mValue(value){
}
void setHelp(const string & help){
mHelp=help;
}
const string &getHelp()const{
return mHelp;
}
const string & getName()const{
return mName;
}
Type *getType()const{
return mType;
}
const string &getValue()const{
return mValue;
}
static string getCommonPrefix(list<ConstField *> fields){
if (fields.size()<2) return "";
list<ConstField*>::iterator it;
string prefix=fields.front()->getName();
int prefixsize;
for (prefixsize=prefix.size();prefixsize>0;prefixsize--){
bool isMatching=true;
prefix=prefix.substr(0,prefixsize);
for(it=fields.begin();it!=fields.end();++it){
ConstField *cf=*it;
if (prefix != cf->getName().substr(0,prefixsize)){
isMatching=false;
break;
}
}
if (isMatching){
cout<<"enum prefix: "<<prefix<<endl;
return prefix;
}
}
return "";
}
private:
Type *mType;
string mName;
string mValue;
string mHelp;
};
template <typename _type>
struct name_matcher{
name_matcher(const string &name) : mName(name){}
bool operator()(_type *cf){
return cf->getName()==mName;
}
string mName;
};
/*actually a class or an enum*/
class Class{
public:
@ -282,10 +341,15 @@ public:
if (mMethods.find(method->getName())==mMethods.end())
mMethods.insert(make_pair(method->getName(),method));
}
void addConstField(ConstField *field){
list<ConstField*>::iterator it=find_if(mConstFields.begin(),mConstFields.end(),name_matcher<ConstField>(field->getName()));
if (it==mConstFields.end())
mConstFields.push_back(field);
}
void setHelp(const std::string &help){
mHelp=help;
}
const list<Method*> getMethods()const{
list<Method*> getMethods()const{
list<Method*> ret;
map<string,Method*>::const_iterator it;
for(it=mMethods.begin();it!=mMethods.end();++it){
@ -293,13 +357,16 @@ public:
}
return ret;
}
const list<ConstField*> &getConstFields()const{
return mConstFields;
}
const string &getName()const{
return mName;
}
const string &getHelp()const{
return mHelp;
}
const list<Property*> getProperties(){
list<Property*> getProperties(){
list<Property*> ret;
map<string,Property*>::const_iterator it;
for(it=mProperties.begin();it!=mProperties.end();++it){
@ -333,6 +400,7 @@ public:
private:
map<string,Method*> mMethods;
map<string,Property*> mProperties;
list<ConstField*> mConstFields;
string mName;
string mHelp;
};