using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
-
-/// <summary>
-/// The Calendar Service API provides functions, enumerations used in the entire Content Service.
-/// </summary>
-/// <remarks>
-/// The Calendar Service API provides functions and ienumerations used in the entire Content Service.
-/// The Information about calendar items i.e. book, event, todo, alarm, attendee and extended are managed in the database
-/// and operations that involve database requires an active connection with the calendar service.
-/// </remarks>
+using System.Diagnostics.CodeAnalysis;
namespace Tizen.Pims.Calendar
{
/// CalendarDatabase provides methods to manage calendar information from/to the database.
/// </summary>
/// <remarks>
- /// This class allows usre to access/create/update db operations for calendar information.
+ /// This class allows user to access/create/update/delete db operations for calendar information.
+ /// CalendarDatabase is created by CalendarManager.
/// </remarks>
+ /// <since_tizen> 4 </since_tizen>
public class CalendarDatabase
{
- /// <summary>
- /// Delegete for detecting the calendar database changes.
- /// </summary>
- /// <param name="uri">The record uri</param>
- /// <remarks>
- /// The delegate must be registered using AddDBChangedDelegate.
- /// It's invoked when the designated view changes.
- /// </remarks>
- /// <see cref="AddDBChangedDelegate"/>
- public delegate void CalendarDBChangedDelegate(string uri);
-
private Object thisLock = new Object();
- private Dictionary<string, CalendarDBChangedDelegate> _callbackMap = new Dictionary<string, CalendarDBChangedDelegate>();
- private Dictionary<string, Interop.Calendar.Database.DBChangedCallback> _delegateMap = new Dictionary<string, Interop.Calendar.Database.DBChangedCallback>();
- private Interop.Calendar.Database.DBChangedCallback _dbChangedDelegate;
+ private Dictionary<string, EventHandler<DBChangedEventArgs>> _eventHandlerMap = new Dictionary<string, EventHandler<DBChangedEventArgs>>();
+ private Dictionary<string, Interop.Database.DBChangedCallback> _callbackMap = new Dictionary<string, Interop.Database.DBChangedCallback>();
internal CalendarDatabase()
{
- ///To be created in CalendarManager only
+ /*To be created in CalendarManager only*/
}
/// <summary>
/// The calendar database version.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
+ /// <value>The current calendar database version.</value>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
public int Version
{
get
{
int version = -1;
- int error = Interop.Calendar.Database.GetCurrentVersion(out version);
+ int error = Interop.Database.GetCurrentVersion(out version);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "Version Failed with error " + error);
/// <summary>
/// Gets last successful changed calendar database version on the current connection.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <returns>The last successful changed calendar database version on the current connection</returns>
/// <privilege>http://tizen.org/privilege/calendar.read</privilege>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ /// <value>The last successful changed calendar database version on the current connection.</value>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
public int LastChangeVersion
{
get
{
int version = -1;
- int error = Interop.Calendar.Database.GetLastChangeVersion(out version);
+ int error = Interop.Database.GetLastChangeVersion(out version);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "LastChangeVersion Failed with error " + error);
/// <summary>
/// Inserts a record into the calendar database.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="record">The record to be inserted</param>
/// <returns>The ID of inserted record</returns>
/// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
public int Insert(CalendarRecord record)
{
int id = -1;
- int error = Interop.Calendar.Database.Insert(record._recordHandle, out id);
+ int error = Interop.Database.Insert(record._recordHandle, out id);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "Insert Failed with error " + error);
/// <summary>
/// Gets a record from the calendar database.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="viewUri">The view URI of a record</param>
/// <param name="recordId">The record ID</param>
/// <returns>
/// The record associated with the record ID
/// </returns>
/// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
+ [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
public CalendarRecord Get(string viewUri, int recordId)
{
IntPtr handle;
- int error = Interop.Calendar.Database.Get(viewUri, recordId, out handle);
+ int error = Interop.Database.Get(viewUri, recordId, out handle);
if (CalendarError.None != (CalendarError)error)
{
if (CalendarError.DBNotFound == (CalendarError)error)
/// <summary>
/// Updates a record in the calendar database.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="record">The record to be updated</param>
/// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
public void Update(CalendarRecord record)
{
- int error = Interop.Calendar.Database.Update(record._recordHandle);
+ int error = Interop.Database.Update(record._recordHandle);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "Update Failed with error " + error);
/// <summary>
/// Deletes a record from the calendar database with related child records.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="viewUri">The view URI of a record</param>
/// <param name="recordId">The record ID to be deleted</param>
/// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
+ [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
public void Delete(string viewUri, int recordId)
{
- int error = Interop.Calendar.Database.Delete(viewUri, recordId);
+ int error = Interop.Database.Delete(viewUri, recordId);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "Delete Failed with error " + error);
/// <summary>
/// Replaces a record in the calendar database.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="record">The record to be replaced</param>
/// <param name="id">the record id</param>
/// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
public void Replace(CalendarRecord record, int id)
{
- int error = Interop.Calendar.Database.Replace(record._recordHandle, id);
+ int error = Interop.Database.Replace(record._recordHandle, id);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "Replace Failed with error " + error);
/// <summary>
/// Retrieves all records as a list.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="viewUri">The view URI to get records from</param>
/// <param name="offset">The index from which results are received</param>
/// <param name="limit">The maximum number of results(value 0 is used for all records)</param>
/// The record list
/// </returns>
/// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
+ [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
public CalendarList GetAll(string viewUri, int offset, int limit)
{
IntPtr handle;
- int error = Interop.Calendar.Database.GetAllRecords(viewUri, offset, limit, out handle);
+ int error = Interop.Database.GetAllRecords(viewUri, offset, limit, out handle);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "GetAll Failed with error " + error);
/// <summary>
/// Retrieves records using a query.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="query">The query used to filter results</param>
/// <param name="offset">The index from which results are received</param>
/// <param name="limit">The maximum number of results(value 0 is used for all records)</param>
/// CalendarList
/// </returns>
/// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
- /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
public CalendarList GetRecordsWithQuery(CalendarQuery query, int offset, int limit)
{
IntPtr handle;
- int error = Interop.Calendar.Database.GetRecords(query._queryHandle, offset, limit, out handle);
+ int error = Interop.Database.GetRecords(query._queryHandle, offset, limit, out handle);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "GetAllWithQuery Failed with error " + error);
/// <summary>
/// Inserts multiple records into the calendar database as a batch operation.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="list">The record list</param>
/// <returns>
/// The inserted record id array
/// </returns>
/// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
public int[] Insert(CalendarList list)
{
IntPtr ids;
int count;
- int error = Interop.Calendar.Database.InsertRecords(list._listHandle, out ids, out count);
+ int error = Interop.Database.InsertRecords(list._listHandle, out ids, out count);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "Insert Failed with error " + error);
/// <summary>
/// Updates multiple records into the calendar database as a batch operation.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="list">The record list</param>
/// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
public void Update(CalendarList list)
{
- int error = Interop.Calendar.Database.UpdateRecords(list._listHandle);
+ int error = Interop.Database.UpdateRecords(list._listHandle);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "Update Failed with error " + error);
/// <summary>
/// Deletes multiple records with related child records from the calendar database as a batch operation.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="viewUri">The view URI of the records to delete</param>
/// <param name="idArray">The record IDs to delete</param>
/// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
+ [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
public void Delete(string viewUri, int[] idArray)
{
- int error = Interop.Calendar.Database.DeleteRecords(viewUri, idArray, idArray.Length);
+ int error = Interop.Database.DeleteRecords(viewUri, idArray, idArray.Length);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "Delete Failed with error " + error);
/// <summary>
/// Deletes multiple records with related child records from the calendar database as a batch operation.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="list">The record list</param>
/// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
- /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
public void Delete(CalendarList list)
/// <summary>
/// Replaces multiple records in the calendar database as a batch operation.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="list">The record list</param>
/// <param name="idArray">The record IDs</param>
/// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
public void Replace(CalendarList list, int[] idArray)
{
- int error = Interop.Calendar.Database.ReplaceRecords(list._listHandle, idArray, idArray.Length);
+ int error = Interop.Database.ReplaceRecords(list._listHandle, idArray, idArray.Length);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "Replace Failed with error " + error);
/// <summary>
/// Retrieves records with the given calendar database version.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="viewUri">The view URI to get records from</param>
/// <param name="BookId">The calendar book ID to filter</param>
/// <param name="calendarDBVersion">The calendar database version</param>
- /// <param name="currentDBVersion"The current calendar database versio></param>
+ /// <param name="currentDBVersion">The current calendar database version</param>
/// <returns>
/// The record list
/// </returns>
/// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
+ [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
public CalendarList GetChangesByVersion(string viewUri, int BookId, int calendarDBVersion, out int currentDBVersion)
{
IntPtr recordList;
- int error = Interop.Calendar.Database.GetChangesByVersion(viewUri, BookId, calendarDBVersion, out recordList, out currentDBVersion);
+ int error = Interop.Database.GetChangesByVersion(viewUri, BookId, calendarDBVersion, out recordList, out currentDBVersion);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "GetChangesByVersion Failed with error " + error);
/// <summary>
/// Gets the record count of a specific view.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="viewUri">The view URI to get records from</param>
/// <returns>
/// The count of records
/// </returns>
/// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+ [SuppressMessage("Microsoft.Design", "CA1822:MarkMembersAsStatic")]
+ [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
public int GetCount(string viewUri)
{
int count = -1;
- int error = Interop.Calendar.Database.GetCount(viewUri, out count);
+ int error = Interop.Database.GetCount(viewUri, out count);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "GetCount Failed with error " + error);
/// <summary>
/// Gets the record count with a query.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="query">The query used for filtering the results</param>
/// <returns>
/// The count of records
/// </returns>
/// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+ [SuppressMessage("Microsoft.Design", "CA1822:MarkMembersAsStatic")]
public int GetCount(CalendarQuery query)
{
int count = -1;
- int error = Interop.Calendar.Database.GetCountWithQuery(query._queryHandle, out count);
+ int error = Interop.Database.GetCountWithQuery(query._queryHandle, out count);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "GetCount Failed with error " + error);
/// <summary>
/// Registers a callback function to be invoked when a record changes.
+ /// <since_tizen> 4 </since_tizen>
/// </summary>
/// <param name="viewUri">The view URI of the record to subscribe for change notifications</param>
- /// <param name="callback">The callback function to register</param>
+ /// <param name="DBChanged">The EventHandler to register</param>
/// <privilege>http://tizen.org/privilege/calendar.read</privilege>
- public void AddDBChangedDelegate(string viewUri, CalendarDBChangedDelegate callback)
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
+ /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+ /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
+ public void AddDBChangedDelegate(string viewUri, EventHandler<DBChangedEventArgs> DBChanged)
{
Log.Debug(Globals.LogTag, "AddDBChangedDelegate");
- _dbChangedDelegate = (string uri, IntPtr userData) =>
- {
- _callbackMap[uri](uri);
- };
- int error = Interop.Calendar.Database.AddChangedCallback(viewUri, _dbChangedDelegate, IntPtr.Zero);
- if (CalendarError.None != (CalendarError)error)
- {
- Log.Error(Globals.LogTag, "AddDBChangedDelegate Failed with error " + error);
- throw CalendarErrorFactory.GetException(error);
- }
- _callbackMap[viewUri] = callback;
- _delegateMap[viewUri] = _dbChangedDelegate;
+ if (!_callbackMap.ContainsKey(viewUri))
+ {
+ _callbackMap[viewUri] = (string uri, IntPtr userData) =>
+ {
+ DBChangedEventArgs args = new DBChangedEventArgs(uri);
+ _eventHandlerMap[uri]?.Invoke(this, args);
+ };
+
+ int error = Interop.Database.AddChangedCallback(viewUri, _callbackMap[viewUri], IntPtr.Zero);
+ if (CalendarError.None != (CalendarError)error)
+ {
+ Log.Error(Globals.LogTag, "AddDBChangedDelegate Failed with error " + error);
+ throw CalendarErrorFactory.GetException(error);
+ }
+ }
+
+ EventHandler<DBChangedEventArgs> handler = null;
+ if (!_eventHandlerMap.TryGetValue(viewUri, out handler))
+ _eventHandlerMap.Add(viewUri, null);
+
+ _eventHandlerMap[viewUri] = handler + DBChanged;
}
/// <summary>
- /// Unregisters a callback function.
+ /// Deregisters a callback function.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="viewUri">The view URI of the record to subscribe for change notifications</param>
- /// <param name="callback">The callback function to register</param>
+ /// <param name="DBChanged">The EventHandler to deregister</param>
/// <privilege>http://tizen.org/privilege/calendar.read</privilege>
- public void RemoveDBChangedDelegate(string viewUri, CalendarDBChangedDelegate callback)
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
+ /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+ /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
+ public void RemoveDBChangedDelegate(string viewUri, EventHandler<DBChangedEventArgs> DBChanged)
{
Log.Debug(Globals.LogTag, "RemoveDBChangedDelegate");
- int error = Interop.Calendar.Database.RemoveChangedCallback(viewUri, _delegateMap[viewUri], IntPtr.Zero);
- if (CalendarError.None != (CalendarError)error)
+ EventHandler<DBChangedEventArgs> handler = null;
+ if (!_eventHandlerMap.TryGetValue(viewUri, out handler))
+ _eventHandlerMap.Add(viewUri, null);
+ else
+ _eventHandlerMap[viewUri] = handler - DBChanged;
+
+ if (_eventHandlerMap[viewUri] == null)
{
- Log.Error(Globals.LogTag, "RemoveDBChangedDelegate Failed with error " + error);
- throw CalendarErrorFactory.GetException(error);
- }
- _callbackMap.Remove(viewUri);
- _delegateMap.Remove(viewUri);
+ int error = Interop.Database.RemoveChangedCallback(viewUri, _callbackMap[viewUri], IntPtr.Zero);
+ if (CalendarError.None != (CalendarError)error)
+ {
+ Log.Error(Globals.LogTag, "RemoveDBChangedDelegate Failed with error " + error);
+ throw CalendarErrorFactory.GetException(error);
+ }
+ _callbackMap.Remove(viewUri);
+ }
}
/// <summary>
/// Link a record to another record.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="baseId">The base record ID</param>
/// <param name="recordId">The record ID to link to</param>
/// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Design", "CA1822:MarkMembersAsStatic")]
public void LinkRecord(int baseId, int recordId)
{
Log.Debug(Globals.LogTag, "LinkRecord");
- int error = Interop.Calendar.Database.LinkRecord(baseId, recordId);
+ int error = Interop.Database.LinkRecord(baseId, recordId);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "LinkRecor Failed with error " + error);
/// <summary>
/// Unlink a record from base record.
/// </summary>
+ /// <since_tizen> 4 </since_tizen>
/// <param name="recordId">The record ID to unlink</param>
/// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+ /// <feature>http://tizen.org/feature/calendar</feature>
+ /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
/// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
/// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+ [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
public void UnlinkRecord(int recordId)
{
Log.Debug(Globals.LogTag, "UnlinkRecord");
- int error = Interop.Calendar.Database.UnlinkRecord(recordId);
+ int error = Interop.Database.UnlinkRecord(recordId);
if (CalendarError.None != (CalendarError)error)
{
Log.Error(Globals.LogTag, "UnlinkRecor Failed with error " + error);