Ejemplo n.º 1
0
// Get user name e.g. Julian Smart
bool wxGetUserName(wxChar *buf, int maxSize)
{
    *buf = wxT('\0');

    // buffer allocation
    MemHandle handle = MemHandleNew(maxSize-1);
    if( handle == NULL )
        return false;

    // lock the buffer
    char *id = (char *)MemHandleLock(handle);
    if( id == NULL )
        return false;

    // get user's name
    if( DlkGetSyncInfo(NULL, NULL, NULL, id, NULL, NULL) != errNone )
    {
        MemPtrUnlock(id);
        return false;
    }

    wxStrlcpy(buf, wxSafeConvertMB2WX(id), maxSize);

    // free the buffer
    MemPtrUnlock(id);

    return true;
}
Ejemplo n.º 2
0
void get_default_username(Char *buf, Short max_len)
{
  Char *tmp, *first_wspace;
  VoidHand h;
  tmp = md_malloc(sizeof(Char) * (dlkMaxUserNameLength + 1));
  DlkGetSyncInfo(NULL, NULL, NULL, tmp, NULL, NULL);
  /* if it's too long, use the first name only */
  //  if (StrLen(tmp) > max_len-1) {
  if (StrLen(tmp) > 8) {
    first_wspace = StrChr(tmp, spaceChr);
    if (first_wspace)
      *(first_wspace) = '\0';
    else
      tmp[max_len-1] = '\0';
  }
  if (StrLen(tmp))
    StrNCopy(buf, tmp, max_len);
  else {
    Short t = rund(3);
    switch(t) {
    case 0:  StrPrintF(buf, "Noman"); break;
    case 1:  StrPrintF(buf, "Outis"); break; // "no man" in greek, says the web
    default: StrPrintF(buf, "Metis"); break; // "no one"/"cunning" pun in greek
    }
  }
  h = MemPtrRecoverHandle(tmp);
  if (h) MemHandleFree(h);  
}
Ejemplo n.º 3
0
Err GetHotSyncName(ExtensibleBuffer* out)
{
    Err   error;
    char  nameBuffer[dlkUserNameBufSize];

    Assert(out);
    error=DlkGetSyncInfo(NULL, NULL, NULL, nameBuffer, NULL, NULL);
    if (error)
        return error;

    if (StrLen(nameBuffer)>0)
        ebufAddStr(out, nameBuffer);
    else
        error=sysErrNotAllowed;            
    return error;
}