Finder Struct Reference
Inheritance diagram for Finder
Collaboration diagram for Finder:
Public Methods |
char | Finder_find_active (struct Finder *ptr_finder, cyid_t cyber_id) |
char | Finder_find_unknown (struct Finder *ptr_finder, cyid_t cyber_id) |
char | Finder_find_disap (struct Finder *ptr_finder, cyid_t cyber_id) |
char | Finder_age (struct Finder *ptr_finder, char day, char month, char year) |
char* | Finder_create_name (struct Finder *ptr_finder, char *sz_visible_name, struct cyfolk_t *person_info) |
int | Finder_get_best_ids (struct Finder *ptr_finder, cyid_t *ptr_cyid_buff, int number) |
Public Attributes |
struct Mutex | finder_mutex |
char | howmany_around |
char | howboys_around |
char | howmany_unknown |
char | howmany_disap |
struct folk_t | mf |
struct info_t | mi |
struct cyfolk_t* | cf |
struct Finder | finder |
Detailed Description
Finder is a resident program, that is, it is always in memory. It's main purpose is to gather information about the Cy-environment. If another Cybiko computer appears within the "field of vision" (if we get any message from it), the Finder begins the acquaintance procedure. It sends the identification information "You&Me/About me" and "You&Me/About you", and requests the same information from the unknown Cybiko computer. Then the Finder calculates the match coefficients (hearts). If our common coefficient is equal to 3 hearts, the Finder creates a dialog, informing the user of our Cy-friend's appearance. The Finder also grants information about other users in the vicinity to other programs, including People and Chat.
The finder can also tell you other information. The total number of active people is stored in the field finder.howmany_around. The total number of unknown users is stored in howmany_unknown. The "cf" field holds an array of records, each describing some aspects of other Cybiko computers: Cyid, nickname, gender, age etc.
-
See also:
-
Finder-related
Member Function Documentation
char Finder_age (
|
struct Finder * ptr_finder,
|
|
char day,
|
|
char month,
|
|
char year )
|
|
|
Calculates the user's age from his/her last birthday.
-
Parameters:
-
ptr_finder
|
The Finder object. MUST BE &finder! |
day
|
Day of birth |
month
|
Month of birth |
year
|
Year of birth |
-
Returns:
-
Current age
#include <cybiko.h>
...
TRACE("Your age is: %d", Finder_age(&finder,
finder.mi.i_bday,
finder.mi.i_bmonth,
finder.mi.i_byear));
... |
char * Finder_create_name (
|
struct Finder * ptr_finder,
|
|
char * sz_visible_name,
|
|
struct cyfolk_t * person_info )
|
|
|
Alters a real name to create a visible name form. For example, if two "visible" Cybiko computers have the same nickname ("Cy", for instance), the Finder can alter one of their names so the user can tell them apart (for example, showing one as "Cy" and the other as "Cy1"). -
Parameters:
-
ptr_finder
|
The Finder object. MUST BE &finder! |
sz_visible_name
|
The buffer where the visible (altered) name will be placed |
person_info
|
Person information about the other user whose Cybiko computer name is being altered |
-
Returns:
-
The visible name.
#include <cybiko.h>
...
int index;
int finder_list_index;
int friend_candidates_number;
cyid_t friend_candidates[10];
char sz_friend_candidate_name[16];
...
friend_candidates_number = Finder_get_best_ids(&finder,
friend_candidates,
10);
TRACE("Friend candidates:");
for(index = 0; index < friend_candidates_number; index ++)
{
finder_list_index = Finder_find_active(&finder,
friend_candidates[index]);
if(finder_list_index != NOT_FOUND)
{
Finder_create_name(&finder,
sz_friend_candidate_name,
&finder.cf[finder_list_index]);
TRACE("%s", sz_friend_candidate_name);
}
}
... |
char Finder_find_active (
|
struct Finder * ptr_finder,
|
|
cyid_t cyber_id )
|
|
|
Finds the active person's position in finder.cf array.
-
Parameters:
-
ptr_finder
|
The Finder object. MUST BE &finder! |
cyber_id
|
Cy ID of the other person's device |
-
Returns:
-
Position in the finder.cf, or NOT_FOUND, if the other user is not active
#include <cybiko.h>
...
int index;
int finder_list_index;
int friend_candidates_number;
cyid_t friend_candidates[10];
char sz_friend_candidate_name[16];
...
friend_candidates_number = Finder_get_best_ids(&finder,
friend_candidates,
10);
TRACE("Friend candidates:");
for(index = 0; index < friend_candidates_number; index ++)
{
finder_list_index = Finder_find_active(&finder,
friend_candidates[index]);
if(finder_list_index != NOT_FOUND)
{
Finder_create_name(&finder,
sz_friend_candidate_name,
&finder.cf[finder_list_index]);
TRACE("%s", sz_friend_candidate_name);
}
}
...
-
See also:
-
NOT_FOUND.
|
char Finder_find_disap (
|
struct Finder * ptr_finder,
|
|
cyid_t cyber_id )
|
|
|
Finds the position in the finder.cf array of the person who temporarily disappeared from the finder's environment.
-
Parameters:
-
ptr_finder
|
The Finder object. MUST BE &finder! |
cyber_id
|
The Cy ID of the other person's device |
-
Returns:
-
Position in finder.cf or NOT_FOUND, if the other user is not founded
#include <cybiko.h>
...
char* get_nickname_by_id( char* sz_nickname, cyid_t id )
{
char index;
Mutex_lock( &finder.finder_mutex, 0 );
if( ( index = Finder_find_active( &finder, id ) ) != NOT_FOUND )
{
Finder_create_name( &finder, sz_nickname, &finder.cf[index] );
}
else if( ( index = Finder_find_unknown( &finder, id ) ) != NOT_FOUND )
{
strcpy( sz_nickname, "unknown" );
}
else if( ( index = Finder_find_disap( &finder, id ) ) != NOT_FOUND)
{
Finder_create_name( &finder, sz_nickname, &finder.cf[index] );
}
else
{
strcpy( sz_nickname, "no info" );
}
Mutex_unlock( &finder.finder_mutex );
return sz_nickname;
}
...
-
See also:
-
NOT_FOUND.
|
char Finder_find_unknown (
|
struct Finder * ptr_finder,
|
|
cyid_t cyber_id )
|
|
|
Finds the position of the unknown person in the finder.cf array.
-
Parameters:
-
ptr_finder
|
The Finder object. MUST BE &finder! |
cyber_id
|
The Cy ID of the other person's device |
-
Returns:
-
Position in finder.cf or NOT_FOUND, if the other user is not found
#include <cybiko.h>
...
char* get_nickname_by_id( char* sz_nickname, cyid_t id )
{
char index;
Mutex_lock( &finder.finder_mutex, 0 );
if( ( index = Finder_find_active( &finder, id ) ) != NOT_FOUND )
{
Finder_create_name( &finder, sz_nickname, &finder.cf[index] );
}
else if( ( index = Finder_find_unknown( &finder, id ) ) != NOT_FOUND )
{
strcpy( sz_nickname, "unknown" );
}
else if( ( index = Finder_find_disap( &finder, id ) ) != NOT_FOUND)
{
Finder_create_name( &finder, sz_nickname, &finder.cf[index] );
}
else
{
strcpy( sz_nickname, "no info" );
}
Mutex_unlock( &finder.finder_mutex );
return sz_nickname;
}
...
-
See also:
-
NOT_FOUND.
|
int Finder_get_best_ids (
|
struct Finder * ptr_finder,
|
|
cyid_t * ptr_cyid_buff,
|
|
int number )
|
|
|
Gets the Cy IDs of the devices with the best match coefficient.
-
Parameters:
-
ptr_finde
|
The Finder object. MUST BE &finder! |
ptr_cyid_buff
|
The buffer for Cy IDs |
number
|
The desired number of Cy IDs. |
-
Returns:
-
Number of Cy IDs stored in the buffer.
#include <cybiko.h>
...
int index;
int finder_list_index;
int friend_candidates_number;
cyid_t friend_candidates[10];
char sz_friend_candidate_name[16];
...
friend_candidates_number = Finder_get_best_ids(&finder,
friend_candidates,
10);
TRACE("Friend candidates:");
for(index = 0; index < friend_candidates_number; index ++)
{
finder_list_index = Finder_find_active(&finder,
friend_candidates[index]);
if(finder_list_index != NOT_FOUND)
{
Finder_create_name(&finder,
sz_friend_candidate_name,
&finder.cf[finder_list_index]);
TRACE("%s", sz_friend_candidate_name);
}
}
... |
Member Data Documentation
|
Array of records describing the people in the vicinity. |
|
Global Finder object. Must be used as the first parameter of all Finder_ functions. #include <cybiko.h>
...
struct Time current_time;
...
Time_get_RTC(¤t_time);
if((current_time.month == finder.mi.i_bmonth)
&&(current_time.day == finder.mi.i_bday))
{
TRACE("Happy birthday!");
}
... |
struct Mutex finder_mutex
|
|
|
Mutually exclusive access synchronization object. |
|
Number of people around who temporarily disappeared from the finder's environment. |
|
Number of people around whose nicknames are "unknown". |
|
The user's own business card. |