1 /* 2 PresenceModel.java 3 Copyright (C) 2010-2013 Belledonne Communications, Grenoble, France 4 5 This program is free software; you can redistribute it and/or 6 modify it under the terms of the GNU General Public License 7 as published by the Free Software Foundation; either version 2 8 of the License, or (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 package org.linphone.core; 21 22 public interface PresenceModel { 23 24 /** 25 * Gets the basic status of a presence model. 26 * @return The #BasicStatus of the #PresenceModel object. 27 */ getBasicStatus()28 PresenceBasicStatus getBasicStatus(); 29 30 /** 31 * Sets the basic status of a presence model. 32 * @param basic_status The #BasicStatus to set for the #PresenceModel object. 33 * @return 0 if successful, a value < 0 in case of error. 34 */ setBasicStatus(PresenceBasicStatus basic_status)35 int setBasicStatus(PresenceBasicStatus basic_status); 36 37 /** 38 * Gets the timestamp of a presence model. 39 * @return The timestamp of the #LinphonePresenceModel object or -1 on error. 40 */ getTimestamp()41 long getTimestamp(); 42 43 /** 44 * Gets the contact of a presence model. 45 * @return A string containing the contact, or null if no contact is found. 46 */ getContact()47 String getContact(); 48 49 /** 50 * Sets the contact of a presence model. 51 * @param contact The contact string to set. 52 */ setContact(String contact)53 void setContact(String contact); 54 55 /** 56 * Gets the first activity of a presence model (there is usually only one). 57 * @return A #PresenceActivity object if successful, null otherwise. 58 */ getActivity()59 PresenceActivity getActivity(); 60 61 /** 62 * Sets the activity of a presence model (limits to only one activity). 63 * @param activity The #PresenceActivityType to set for the model. 64 * @param description An additional description of the activity to set for the model. Can be null if no additional description is to be added. 65 * @return 0 if successful, a value < 0 in case of error. 66 * 67 * WARNING: This method will modify the basic status of the model according to the activity being set. 68 * If you don't want the basic status to be modified automatically, you can use the combination of setBasicStatus(), clearActivities() and addActivity(). 69 */ setActivity(PresenceActivityType activity, String description)70 int setActivity(PresenceActivityType activity, String description); 71 72 /** 73 * Gets the number of activities included in the presence model. 74 * @return The number of activities included in the #PresenceModel object. 75 */ getNbActivities()76 long getNbActivities(); 77 78 /** 79 * Gets the nth activity of a presence model. 80 * @param idx The index of the activity to get (the first activity having the index 0). 81 * @return A #PresenceActivity object if successful, null otherwise. 82 */ getNthActivity(long idx)83 PresenceActivity getNthActivity(long idx); 84 85 /** 86 * Adds an activity to a presence model. 87 * @param activity The #PresenceActivity to add to the model. 88 * @return 0 if successful, a value < 0 in case of error. 89 */ addActivity(PresenceActivity activity)90 int addActivity(PresenceActivity activity); 91 92 /** 93 * Clears the activities of a presence model. 94 * @return 0 if successful, a value < 0 in case of error. 95 */ clearActivities()96 int clearActivities(); 97 98 /** 99 * Gets the first note of a presence model (there is usually only one). 100 * @param 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. 101 * @return A #PresenceNote object if successful, null otherwise. 102 */ getNote(String lang)103 PresenceNote getNote(String lang); 104 105 /** 106 * Adds a note to a presence model. 107 * @param note_content The note to be added to the presence model. 108 * @param lang The language of the note to be added. Can be null if no language is to be specified for the note. 109 * @return 0 if successful, a value < 0 in case of error. 110 * 111 * Only one note for each language can be set, so e.g. setting a note for the 'fr' language if there is only one will replace the existing one. 112 */ addNote(String note_content, String lang)113 int addNote(String note_content, String lang); 114 115 /** 116 * Clears all the notes of a presence model. 117 * @return 0 if successful, a value < 0 in case of error. 118 */ clearNotes()119 int clearNotes(); 120 121 /** 122 * Gets the number of services included in the presence model. 123 * @return The number of services included in the #PresenceModel object. 124 */ getNbServices()125 long getNbServices(); 126 127 /** 128 * Gets the nth service of a presence model. 129 * @param idx The index of the service to get (the first service having the index 0). 130 * @return A #PresenceService object if successful, null otherwise. 131 */ getNthService(long idx)132 PresenceService getNthService(long idx); 133 134 /** 135 * Adds a service to a presence model. 136 * @param service The #PresenceService object to add to the model. 137 * @return 0 if successful, a value < 0 in case of error. 138 */ addService(PresenceService service)139 int addService(PresenceService service); 140 141 /** 142 * Clears the services of a presence model. 143 * @return 0 if successful, a value < 0 in case of error. 144 */ clearServices()145 int clearServices(); 146 147 /** 148 * Gets the number of persons included in the presence model. 149 * @return The number of persons included in the #PresenceModel object. 150 */ getNbPersons()151 long getNbPersons(); 152 153 /** 154 * Gets the nth person of a presence model. 155 * @param idx The index of the person to get (the first person having the index 0). 156 * @return A pointer to a #PresencePerson object if successful, null otherwise. 157 */ getNthPerson(long idx)158 PresencePerson getNthPerson(long idx); 159 160 /** 161 * Adds a person to a presence model. 162 * @param person The #PresencePerson object to add to the model. 163 * @return 0 if successful, a value < 0 in case of error. 164 */ addPerson(PresencePerson person)165 int addPerson(PresencePerson person); 166 167 /** 168 * Clears the persons of a presence model. 169 * @return 0 if successful, a value < 0 in case of error. 170 */ clearPersons()171 int clearPersons(); 172 173 } 174