Inherits from NSObject
Declared in SCDataManager.h

Overview

SCDataManager provides the low-level API access to the CoreData Database handled by C2Call SDK.

The Database Schema is available under SocialCommunication.ressources/C2CallDataModel.xcdatamodeld.

All relevant Entities in this Data Model are subclasses from NSManagedObject for convenient access to the Entity Attributes. The following NSManagedObject subclasses are defined by C2Call SDK.

- MOChatHistory
- MOC2CallUser
- MOCallHistory
- MOC2CallEvent
- MOOpenId
- MOAddress
- MOPhoneNumber
- MOGroupMember
- MOC2CallGroup

C2Call SDK GUI Components are based on CoreData. All access to CoreData Objects and all queries to the database have to be done in main Thread. SCDataManager capsules the access to the CoreData database layer and ensures that all request are done in main Thread.

Properties

isDataInitialized

Is CoreData initialized already.

@property (nonatomic) BOOL isDataInitialized

Return Value

YES - Initialized / NO - Not initialized yet.

Declared In

SCDataManager.h

Class Methods

instance

Current Instance of SCDataManager.

+ (SCDataManager *)instance

Return Value

Current Instance of SCDataManager

Declared In

SCDataManager.h

Instance Methods

eventForEventId:

Gets the MOC2CallEvent Object for an eventId.

- (MOC2CallEvent *)eventForEventId:(id)eventId

Parameters

eventId
  • EventId of the object

Return Value

The event object or nil

Discussion

The MOC2CallEvent Object represents a call or a message, which can be inbound call, outbound call, inbound message, outbound message. All relevant information on those calls or messages is available through MOC2CallEvent Object. The data is read only; changes to the object will be discarded on next data synchronisation with the server.

Declared In

SCDataManager.h

fetchRequestForCallHistory:

Gets a predefined NSFetchRequest for a Call History.

- (NSFetchRequest *)fetchRequestForCallHistory:(id)sortAscending

Parameters

sortAscending

YES - Fetch MOCallHistory objects in the order of the oldest call first / NO - Latest call first

See Also

Declared In

SCDataManager.h

fetchRequestForChatHistory:

Gets a predefined NSFetchRequest for a Chat History.

- (NSFetchRequest *)fetchRequestForChatHistory:(id)sortAscending

Parameters

sortAscending

YES - Fetch MOChatHistory objects in the order of the oldest chat first / NO - Latest Chat first

See Also

Declared In

SCDataManager.h

fetchRequestForEventHistory:sort:

Gets a predefined NSFetchRequest for a list of MOC2CallEvent objects of the specific contact.

- (NSFetchRequest *)fetchRequestForEventHistory:(id)userid sort:(id)sortAscending

Parameters

sortAscending

YES - Oldest Event first / NO - Latest Event first

See Also

Declared In

SCDataManager.h

fetchRequestForFriendlist:

Gets a predefined NSFetchRequest for a list of MOC2CallUser objects (list of all friends and groups).

- (NSFetchRequest *)fetchRequestForFriendlist:(id)sortByFirstname

Parameters

sortByFirstname

YES - Sort by Firstname / NO - Sort by Lastname

See Also

Declared In

SCDataManager.h

fetchRequestForUserWithObjectId:

Gets a predefined NSFetchRequest an MOC2CallUser object

- (NSFetchRequest *)fetchRequestForUserWithObjectId:(id)objid

Return Value

NSFetchedRequest

Discussion

Use this NSFetchRequest with NSFetchedResultsController to get automatic updates on that specific user.

See Also

Declared In

SCDataManager.h

fetchedResultsControllerWithFetchRequest:sectionNameKeyPath:cacheName:

Requests a NSFetchedResultsController for the C2Call SDK Database with a given fetchRequest.

- (NSFetchedResultsController *)fetchedResultsControllerWithFetchRequest:(id)fetchRequest sectionNameKeyPath:(id)sectionNameKeyPath cacheName:(id)name

Parameters

fetchRequest
  • The fetchRequest
cacheName
  • The name of the cache file the receiver should use. Pass nil to prevent caching. Pre-computed section info is cached to a private directory under this name. If Core Data finds a cache stored with this name, it is checked to see if it matches the fetchRequest. If it does, the cache is loaded directly—this avoids the overhead of computing the section and index information. If the cached information doesn’t match the request, the cache is deleted and recomputed when the fetch happens.
sectionNameKeypath
  • A key path on result objects that returns the section name. Pass nil to indicate that the controller should generate a single section. The section name is used to pre-compute the section information. If this key path is not the same as that specified by the first sort descriptor in fetchRequest, they must generate the same relative orderings. For example, the first sort descriptor in fetchRequest might specify the key for a persistent property; sectionNameKeyPath might specify a key for a transient property derived from the persistent property.

See Also

Declared In

SCDataManager.h

groupForGroupid:

Gets the MOC2CallGroup Object for a groupid.

- (MOC2CallGroup *)groupForGroupid:(id)groupid

Parameters

eventId
  • EventId of the object

Return Value

The event object or nil

Discussion

The MOC2CallGroup Object represents a group. All relevant information on the group is available through MOC2CallGroup Object. The data is read only; changes to the object will be discarded on next data synchronisation with the server.

Declared In

SCDataManager.h

markAsRead:

Mark an MOC2CallEvent as read

- (BOOL)markAsRead:(id)event

Parameters

event

Return Value

YES : In MOC2CallEvent is of type MessageIn and status is unread else NO

Discussion

MOC2CallEvent messages of type MessageIn can be marked as read. A read notification will be submitted to the remote party. The Missed Events counter will be decremented.

Declared In

SCDataManager.h

missedCallsForContact:

Get the number of missed calls for a specific contact

- (int)missedCallsForContact:(id)contact

Parameters

contact
  • Userid of the contact.

Return Value

Number of missed calls

Declared In

SCDataManager.h

recallMessage:

Removes a submitted message from the senders and the receivers message history

- (BOOL)recallMessage:(id)msgobject

Parameters

msgobject
  • The message object to recall.

Return Value

YES - success / NO - failure

Declared In

SCDataManager.h

recentContacts

Returns the list of the last 20 contacts the user has been in touch with

- (NSArray *)recentContacts

Return Value

Array of userids

Declared In

SCDataManager.h

removeDatabaseObject:

Removes a NSManagedObject from the Database.

- (BOOL)removeDatabaseObject:(id)managedObject

Parameters

managedObject
  • Either one of the descibed objects above.

Return Value

YES - success / NO - failure

Discussion

IMPORTANT: This method must be called on Main-Thread, otherwise it returns NO; The removeDatabaseObject Method removes the following NSManagedObject subclasses correctly from the database and from the server:

- MOC2CallEvent
- MOC2CallUser
- MOChatHistory
- MOCallHistory

The above-mentioned objects have a representation locally on the device and as well on the server with several dependencies to other objects. Therefore deleting an object is a complex task, which has to be handled correctly. For example: The MOC2CallUser Object represents either friend relation or a group (in case the use owns the group) or a group relation (the user is only member of a group). Deleting an MOC2CallUser object has therefore the following implications: 1. In case the MOC2CallUser represents a friend relation, the relation will be removed (this two users are not longer friends) 2. In case the MOC2CallUser represents a group (the user owns the group), the actual group will be deleted on the server and all memberships will be released. 3. In case the MOC2CallUser represents a group relation, only the membership of this user will be released.

The MOC2CallEvent represents an instant message, a rich media message or a call record.
In case of an instant message or a call record, removing the MOC2CallEvent object only removes the corresponding record on the server.
In case of a rich media message, all related media files will be removed, too.

The MOChatHistory is a container object for all messages with a specific person.
Removing a MOChatHistory object will automatically remove all MOC2CallEvent objects from and to that person, too.

The MOCallHistory is a container object for all calls with a specific person.
Removing a MOCallHistory object will automatically remove all MOC2CallEvent objects from and to that person, too.

Declared In

SCDataManager.h

resetMissedCallsForContact:

Manually reset the missed calls indication for a contact

- (void)resetMissedCallsForContact:(id)contact

Parameters

contact
  • Userid of the contact.

Declared In

SCDataManager.h

setFetchLimit:forFetchRequest:

Sets a fetch size limit on a given fetch request.

- (int)setFetchLimit:(id)fetchLimit forFetchRequest:(id)fetchRequest

Parameters

fetchLimit
  • Max number of objects in the result set
fetchRequest
  • The fetchRequest to limit

Discussion

The result set of a fetch request can be quite large, on a long chat for example. Setting the FetchLimit limits the result set to the last fetchLimit objects (for example the last 25 messages of a chat).

NSFetchRequest *fetchRequest = [[SCDataManager instance] fetchRequestForEventHistory:@"<Userid of Chat Partner>" sort:YES];
[[SCDataManager instance] setFetchLimit:25 forFetchRequest:fetchRequest];

See Also

Declared In

SCDataManager.h

setNumber:ofType:forContact:

Save additional phone numbers for a friend contact

- (void)setNumber:(id)number ofType:(id)numberType forContact:(id)contact

Parameters

number
  • The phone number
numberType
  • Valid types are : “NT_WORK”, “NT_MOBILE”, “NT_HOME”, “NT_OTHER”
contact
  • email address of the friend contact

Declared In

SCDataManager.h

totalMissedCalls

Get the number of total missed calls

- (int)totalMissedCalls

Return Value

Number of missed calls

Declared In

SCDataManager.h

totalMissedMessages

Get the number of total missed messages

- (int)totalMissedMessages

Return Value

Number of missed messages

Declared In

SCDataManager.h

userForEmail:

Gets the MOC2CallUser Object for an email address. The MOC2CallUser Object represents a friend, a group or a special user (CallMe Link, Test Call, etc). All relevant information on those users is available through MOC2CallUser Object. The data is read only; changes to the object will be discarded on next data synchronisation with the server.

- (MOC2CallUser *)userForEmail:(id)email

Parameters

email
  • Email address of the user object

Return Value

The user object or nil

Declared In

SCDataManager.h

userForUserid:

Gets the MOC2CallUser Object for a userId.

- (MOC2CallUser *)userForUserid:(id)userid

Parameters

userid
  • C2Call Userid

Return Value

The user object or nil

Discussion

The MOC2CallUser Object represents a friend, a group or a special user (CallMe Link, Test Call, etc). All relevant information on those users is available through MOC2CallUser Object. The data is read only; changes to the object will be discarded on next data synchronisation with the server.

Declared In

SCDataManager.h