예제 #1
0
파일: MainFrame.cpp 프로젝트: page31/GJTalk
void CMainFrame::OnPostCreate()
{
	if(!this->InitFromXmlFile(_T("MainFrame.xml"),this))
		throw CGJWndError::LOAD_ERROR;  
	m_pBuddyList= static_cast<CBuddyListUI*>(m_pm.FindControl(pstrBuddyListName));
	m_pRecentList=static_cast<CBuddyListUI*>(m_pm.FindControl(pstrRecentBuddyListName));
	m_pOptTabBuddyList=static_cast<COptionUI*>(m_pm.FindControl(pstrOptTabBuddyListName));
	m_pOptTabRecentList=static_cast<COptionUI*>(m_pm.FindControl(pstrOptTabRecentListName));
	m_pListTable=static_cast<CTabLayoutUI*>(m_pm.FindControl(pstrListTableName));

	m_pBtnHeader=static_cast<CButtonUI*>(m_pm.FindControl(pstrButtonHeaderName));
	m_pBtnSearch=FindControl<CButtonUI>(pstrButtonSearchName);
	m_pBtnStatus=FindControl<CButtonUI>(pstrButtonStatusName);



	m_pEditSignaure=static_cast<CEditUI*>(m_pm.FindControl(pstrEditSignatureName));
	m_pLabelName=static_cast<CLabelUI*>(m_pm.FindControl(pstrLabelNameName));

	ASSERT(m_pOptTabBuddyList);
	ASSERT(m_pOptTabRecentList);
	ASSERT(m_pListTable);
	ASSERT(m_pBuddyList);
	ASSERT(m_pRecentList);
	ASSERT(m_pBtnHeader);
	ASSERT(m_pBtnStatus);
	ASSERT(m_pEditSignaure);
	ASSERT(m_pLabelName);

	m_pBuddyList->OnItemAction+= CDelegate<CMainFrame,CMainFrame>(this,&CMainFrame::OnBuddyItemAction);

	/*m_pBuddyList->AddGroup(_T("test"));
	m_pBuddyList->AddGroup(_T("test2"));
	CBuddyListItem *item;

	for (int i = 0; i < 10; i++)
	{
	item=new CBuddyListItem(); 
	CString str;
	str.Format(_T("item %d"),i);
	item->SetName(str);
	item->SetHeader(_T("header.jpg"));
	str.Format(_T("signature %d"),i);
	item->SetSignature(str);
	JID jid;
	jid.setUsername(cstr_str(str));
	item->SetJid(jid);

	m_pBuddyList->GetGroup(i%m_pBuddyList->GetCount()).Add(*item);
	}*/
	ASSERT(GetContext());
	LoadUser();
	GetContext()->GetClient()->rosterManager()->registerRosterListener(this);  
	ASSERT(GetContext()->GetSelfVCard());
	auto vcard=GetContext()->GetSelfVCard();
	m_pLabelName->SetText( utf8dec(vcard->nickname()));
	m_pEditSignaure->SetText(utf8dec(vcard->desc()));
	m_pBtnHeader->SetBkImage(GetContext()->GetHeaderManager().GetHeader(*GetContext()->GetSelf(),true));
	UpdateDock();
}
예제 #2
0
파일: MainFrame.cpp 프로젝트: page31/GJTalk
void CMainFrame::handleVCard( const JID& jid, const VCard* vcard )
{
	GetContext()->m_VCards[jid]=*vcard;
	if(!m_pBuddyList)
		return; 
	auto buddy=m_pBuddyList->FindBuddyItem(jid);
	if(!buddy)
		return; 
	buddy->SetName(utf8dec(vcard->nickname()));
	buddy->SetSignature(utf8dec(vcard->desc())); 

	GetContext()->GetHeaderManager().UpdateHeader(jid,vcard->photo().binval); 
}
예제 #3
0
파일: MainFrame.cpp 프로젝트: page31/GJTalk
void CMainFrame::handleItemAdded( const JID& jid ) 
{
	auto roster=GetContext()->GetClient()->rosterManager()->getRosterItem(jid); 
	if(roster==NULL)
		return;
	CBuddyListItem *item=new CBuddyListItem;
	item->SetJid(jid);
	item->SetName(utf8dec(roster->name()));

	item->SetHeader(GetContext()->GetHeaderManager().GetHeader(jid,item->IsOnline()));

	m_pBuddyList->AddBuddy(utf8dec(roster->groups().front()),*item); 
	auto vcardMgr=GetContext()->GetVCardManager();
	if(vcardMgr)
		vcardMgr->fetchVCard(jid,this);
}
예제 #4
0
파일: utf8.c 프로젝트: vendu/Resurrection
int
main(int argc, char *argv[])
{
    int i;
    uint16_t wc;
    int len;
    uint8_t *cp;

#if 0
    i = 0xa9;
    cp = &tab[i][0];
    utf8enc(i, cp);
    printf("\n");
    i = 0x2260;
    cp = &tab[i][0];
    utf8enc(i, cp);
    printf("\n");
#endif

    exit(0);

    for (i = 0 ; i < 65536 ; i++) {
        cp = &tab[i][0];
        utf8enc(i, cp);
        wc = utf8dec(&tab[i][0], &len);
        if (wc != i) {
//            printf("0x%x (0x%x): %x\n", i, wc, len);
            printf("ERROR: %x != %x (%d)\n", wc, i, len);
            exit(1);
        }
    }

    exit(0);
}
예제 #5
0
파일: GJContext.cpp 프로젝트: page31/GJTalk
bool GJContext::handleSubscriptionRequest( const JID& jid, const std::string& msg )
{
	if(GetClient()&&GetClient()->rosterManager()->getRosterItem(jid))
	{
		GetClient()->rosterManager()->ackSubscriptionRequest(jid,true);
	}
	SubscriptionRequest request; 
	request.from=jid;
	request.msg=utf8dec(msg);
	OnSubscriptionRequest(request);
	return false;
}
예제 #6
0
파일: MainFrame.cpp 프로젝트: page31/GJTalk
void CMainFrame::handleRosterPresence( const RosterItem& item, const std::string& resource,
									  Presence::PresenceType presence, const std::string& msg ) 

{
	if(m_pBuddyList)
	{
		CBuddyListItem* buddy= m_pBuddyList->FindBuddyItem(item.jid());
		if(buddy)
		{
			bool online=buddy->IsOnline();
			buddy->SetPresence(presence);
			buddy->SetSignature(utf8dec(msg));
			if(online!=buddy->IsOnline())
			{
				buddy->SetHeader(GetContext()->GetHeaderManager().GetHeader(item.jid(),buddy->IsOnline()));
			}
		}
	}
}
예제 #7
0
파일: IRIRef.cpp 프로젝트: jrweave/phd
IRIRef *IRIRef::normalize() THROWS(BadAllocException, TraceableException) {
  if (this->normalized && !this->urified) {
    return this;
  }

  uint8_t *normed = NULL;
  DPtr<uint8_t> *normal = NULL;

  if (this->utf8str->standable()) {
    this->utf8str = this->utf8str->stand();
    normal = this->utf8str;
    normal->hold();
  } else {
    NEW(normal, MPtr<uint8_t>, this->utf8str->size());
  }
  normed = normal->dptr();

  // Percent encoding; decode if IUnreserved
  uint8_t bits = UINT8_C(0);
  uint8_t *begin = this->utf8str->dptr();
  uint8_t *end = begin + this->utf8str->size();
  uint8_t *marki = begin;
  uint8_t *markj = begin;
  uint8_t *markk = normed;
  for (; marki != end; marki = markj) {
    for (markj = marki; markj != end && *markj != to_ascii('%'); ++markj) {
      // loop does the work
    }
    size_t sz = markj - marki;
    memmove(markk, marki, sz * sizeof(uint8_t));
    markk += sz;
    if (markj == end) {
      break;
    }

    uint8_t enc[4] = { UINT8_C(0xFF), UINT8_C(0xFF),
                       UINT8_C(0xFF), UINT8_C(0xFF) };
    enc[0] = (((uint8_t) IRI_HEX_VALUE(markj[1])) << 4)
             | (uint8_t) IRI_HEX_VALUE(markj[2]);
    if (enc[0] <= UINT8_C(0x7F)) {
      if (IRIRef::isIUnreserved(enc[0])) {
        *markk = enc[0];
        ++markk;
      } else {
        markk[0] = markj[0];
        markk[1] = to_upper(markj[1]);
        markk[2] = to_upper(markj[2]);
        markk += 3;
      }
      markj += 3;
      continue;
    }

    uint8_t *markl = markj + 3;
    int i = 1;
    uint8_t bits;
    for (bits = enc[0] << 1; markl != end && *markl == to_ascii('%') &&
                             bits > UINT8_C(0x7F) && i < 4; bits <<= 1) {
      enc[i] = (((uint8_t) IRI_HEX_VALUE(markl[1])) << 4)
               | (uint8_t) IRI_HEX_VALUE(markl[2]);
      markl += 3;
      ++i;
    }
    try {
      const uint8_t *endenc;
      uint32_t codepoint = utf8char(enc, &endenc);
      if (IRIRef::isIUnreserved(codepoint)) {
        i = endenc - enc; // should already be equal, but just in case
        memmove(markk, enc, i * sizeof(uint8_t));
        markk += i;
        markj = markl;
        this->urified = false;
      } else {
        for (; markj != markl; markj += 3) {
          markk[0] = markj[0];
          markk[1] = to_upper(markj[1]);
          markk[2] = to_upper(markj[2]);
          markk += 3;
        }
      }
    } catch (InvalidEncodingException &e) {
      markk[0] = markj[0];
      markk[1] = to_upper(markj[1]);
      markk[2] = to_upper(markj[2]);
      markk += 3;
      markj += 3;
    }
  }
  if (markk != end) {
    DPtr<uint8_t> *temp = normal->sub(0, markk - normed);
    normal->drop();
    normal = temp;
  }

  if (this->normalized) {
    this->utf8str->drop();
    this->utf8str = normal;
    return this;
  }

  // Character normalization; NFC
  DPtr<uint32_t> *codepoints = utf8dec(normal);
  normal->drop();
  DPtr<uint32_t> *codepoints2 = nfc_opt(codepoints);
  codepoints->drop();
  normal = utf8enc(codepoints2);
  codepoints2->drop();
  this->utf8str->drop();
  this->utf8str = normal;

  // Path normalization
  this->resolve(NULL);

  // Case normalization; scheme and host
  DPtr<uint8_t> *part = this->getPart(SCHEME);
  if (part != NULL) {
    begin = part->dptr();
    end = begin + part->size();
    for (; begin != end; ++begin) {
      *begin = to_lower(*begin);
    }
    part->drop();
  }
  part = this->getPart(HOST);
  if (part != NULL) {
    begin = part->dptr();
    end = begin + part->size();
    for (; begin != end; ++begin) {
      *begin = to_lower(*begin);
    }
    part->drop();
  }

  this->normalized = true;
  return this;
}