Esempio n. 1
0
void GGWrapper::processLoginEvent(ggLoginEvent &event)
{
    struct gg_login_params p;
    memset(&p,0,sizeof(gg_login_params));
    p.uin = event.uin;
    p.password = const_cast<char *>(event.pass.c_str());
    p.async = 0;
    p.protocol_features = GG_FEATURE_ALL | GG_FEATURE_MSG77 | GG_FEATURE_MULTILOGON;
    p.tls = GG_SSL_ENABLED;
    p.encoding = GG_ENCODING_UTF8;

    if((mpSession = gg_login(&p)) && gg_notify(mpSession,NULL,0) != -1)
    {
        mOwnerUin = p.uin;
        eventSignal().emit(spEvent(new LoginResultEvent(true,event.uin)));
        if ( -1 != gg_userlist100_request(mpSession,GG_USERLIST100_GET,0,GG_USERLIST100_FORMAT_TYPE_GG100,0))
        {
            Logger::log("Succesfully requested userlist..?");
        }

    }
    else
    {
        eventSignal().emit(spEvent(new LoginResultEvent(false)));
        gg_free_session(mpSession);
        mpSession = 0;
    }
}
Esempio n. 2
0
/*****************************************************************************
 *
 * Description:
 *    This function gives a counting semaphore, i.e. increases the semaphore 
 *    counter. If there are one or more processes waiting for the semaphore 
 *    the process with highest priority is made ready to run. 
 *
 * Params:
 *    [in]  pSem   - A pointer to an initialized semaphore structure. 
 *    [out] pError - The return status of the function. 
 *
 * Error codes:
 *    OS_OK         - The function completed successfully. 
 *    OS_ERROR_NULL - A NULL pointer was supplied to the function where it was 
 *                    not allowed. 
 *
 ****************************************************************************/
void
osSemGive(tCntSem* pSem,
          tU8*     pError)
{
  volatile tSR localSR;  /* declare temporary local space for status word */

  *pError = OS_OK;
  if(pSem == NULL)
  {
    *pError = OS_ERROR_NULL;

    return;
  }

  m_os_dis_int();

  if(eventIsEmpty((tOSEvent*)pSem) == FALSE)
  {
    eventSignal((tOSEvent*)pSem);
    if(isrNesting == 0)
    {
      m_os_ena_int();
      schedule();
      m_os_dis_int();
    }
  }
  else
  {
    pSem->cnt++;
  }
  m_os_ena_int();
}
Esempio n. 3
0
void GGWrapper::onRecvMsg(gg_event_msg& msg)
{
    if(msg.msgclass & GG_CLASS_CHAT || msg.msgclass & GG_CLASS_MSG)
    {
        std::string message((const char*)msg.message);
        std::string decodedMsg = conversions::toUtf8(message);
        auto timestamp = FormattingUtils::time_tToPtime(msg.time);
        HistoryManager::saveRcvEntry(decodedMsg,timestamp,mOwnerUin,msg.sender);
        eventSignal().emit(spEvent(new MessageEvent(msg.sender,decodedMsg,timestamp)));

        Logger::log(message + " sent at " + FormattingUtils::dateToStr(timestamp));
    }
}
Esempio n. 4
0
int mmapLogWrite(const char *buffer, uint16_t len)
{
    MMAP_FILE_HEADER *hd;
    char *mdata;
    mutexLock(g_mmap_log.mutex, -1);
    hd = (MMAP_FILE_HEADER*)g_mmap_log.handle->data;
    mdata = (char*)g_mmap_log.handle->data;
    if(len + hd->writepos + sizeof(uint16_t) > g_mmap_log.handle->size)    //We now rotate
    {
        hd->endpos = hd->writepos;
        hd->writepos = sizeof(MMAP_FILE_HEADER);
    }
    *((short*)(mdata + hd->writepos)) = len;
    memcpy_s(mdata + hd->writepos + sizeof(uint16_t), g_mmap_log.handle->size, buffer, len);
    hd->writepos += len + sizeof(uint16_t);
    if(hd->writepos + 4096 > hd->endpos)
        hd->endpos = sizeof(MMAP_FILE_HEADER);
    mutexUnLock(g_mmap_log.mutex);
    eventSignal(g_mmap_log.event);

    return len;
}