Futures:
- Sign up for Plurk
- Post message to selected friends privately
Login:
bool __fastcall TForm_Login::Login(AnsiString api_key, AnsiString username,AnsiString password) { AnsiString loginBody; AnsiString loginUrl = Form1->GetApiUrl(PLURK_LOGIN + "?api_key=" + Form1->API_Key + "&" + "username=" + username + "&" + "password=" + password ); Form1->Edit1->Text= loginUrl; try { Application->ProcessMessages(); loginBody=Form1->IdHTTP_Plurk->Get(loginUrl); RzProgressStatus_Loading->Visible = true; Application->ProcessMessages(); AnsiString tmp = loginBody; //get friends and fans number AnsiString numTmp; numTmp=tmp.SubString(tmp.Pos("fans_count")+1,20); numTmp.Delete(1,numTmp.Pos(":")); numTmp=numTmp.SubString(1 ,numTmp.Pos(",")-1).Trim(); Form1->iFansNum=StrToInt(numTmp); numTmp=tmp.SubString(tmp.Pos("friends_count")+1,20); numTmp.Delete(1,numTmp.Pos(":")); numTmp=numTmp.SubString(1 ,numTmp.Pos(",")-1).Trim(); Form1->iFriendsNum=StrToInt(numTmp); tmp.Delete(1, tmp.Pos("user_info")); tmp.Delete(1, tmp.Pos("{")); if(tmp.Pos("display_name")>0) { tmp.Delete(1,tmp.Pos(":")); Form1->OwnerData.Display_Name = tmp.SubString(tmp.Pos("\"") +1 ,tmp.Pos(",")-tmp.Pos("\"")-1); if(Form1->OwnerData.Display_Name.Pos("\"")>0) Form1->OwnerData.Display_Name.Delete(Form1->OwnerData.Display_Name.Length(),1); //ShowMessage(friendList[i*10+j].Display_Name); tmp.Delete(1,tmp.Pos(", ")); } if(tmp.Pos("uid")>0) { tmp.Delete(1,tmp.Pos("uid")-1); tmp.Delete(1,tmp.Pos(":")); Form1->OwnerData.UID = tmp.SubString(1 ,tmp.Pos(",")-1).Trim(); tmp.Delete(1,tmp.Pos(", ")); } if(tmp.Pos("nick_name")>0) { tmp.Delete(1,tmp.Pos("nick_name")); tmp.Delete(1,tmp.Pos(":")); Form1->OwnerData.Nick_Name = tmp.SubString(tmp.Pos("\"") +1 ,tmp.Pos("\",")-tmp.Pos("\"")-1); tmp.Delete(1,tmp.Pos(", ")); } if(tmp.Pos("has_profile_image")>0) { tmp.Delete(1,tmp.Pos(":")); Form1->OwnerData.has_profile_image = tmp.Trim().SubString(1 ,1).Trim().ToInt(); } if(tmp.Pos("avatar")>0) { tmp.Delete(1,tmp.Pos("avatar")); tmp.Delete(1,tmp.Pos(":")); Form1->OwnerData.Avatar = tmp.SubString(1 ,tmp.Pos(",")-1).Trim(); tmp.Delete(1,tmp.Pos(", ")); } if(tmp.Pos("full_name")>0) { tmp.Delete(1,tmp.Pos(":")); Form1->OwnerData.Full_Name = tmp.SubString(tmp.Pos("\"") +1 ,tmp.Pos("\",")-tmp.Pos("\"")-1); } if( (Form1->OwnerData.has_profile_image == 1) && (Form1->OwnerData.Avatar == "null" || Form1->OwnerData.Avatar == "0") ) { Form1->OwnerData.Avatar_S_URL = "http://avatars.plurk.com/"+Form1->OwnerData.UID+"-small.gif"; Form1->OwnerData.Avatar_M_URL = "http://avatars.plurk.com/"+Form1->OwnerData.UID+"-medium.gif"; Form1->OwnerData.Avatar_B_URL = "http://avatars.plurk.com/"+Form1->OwnerData.UID+"-big.jpg"; // savefile stream AnsiString image_path = exe_path + "\\images\\" + Form1->OwnerData.UID + ".jpg"; std::auto_ptr<TFileStream> file(new TFileStream(image_path.c_str(), fmCreate)); Form1->IdHTTP_GetImage->Get(Form1->OwnerData.Avatar_B_URL, file.get() ); } else if( (Form1->OwnerData.has_profile_image == 1) && (Form1->OwnerData.Avatar != "null") ) { Form1->OwnerData.Avatar_S_URL = "http://avatars.plurk.com/"+Form1->OwnerData.UID+"-small"+Form1->OwnerData.Avatar+".gif"; Form1->OwnerData.Avatar_M_URL = "http://avatars.plurk.com/"+Form1->OwnerData.UID+"-medium"+Form1->OwnerData.Avatar+".gif"; Form1->OwnerData.Avatar_B_URL = "http://avatars.plurk.com/"+Form1->OwnerData.UID+"-big"+Form1->OwnerData.Avatar+".jpg"; // savefile stream AnsiString image_path = exe_path + "\\images\\" + Form1->OwnerData.UID + ".jpg"; std::auto_ptr<TFileStream> file(new TFileStream(image_path.c_str(), fmCreate)); Form1->IdHTTP_GetImage->Get(Form1->OwnerData.Avatar_B_URL, file.get() ); } else if(Form1->OwnerData.has_profile_image == 0) { Form1->OwnerData.Avatar_S_URL = "http://www.plurk.com/static/default_small.gif"; Form1->OwnerData.Avatar_M_URL = "http://www.plurk.com/static/default_medium.gif"; Form1->OwnerData.Avatar_B_URL = "http://www.plurk.com/static/default_big.gif"; // savefile stream AnsiString image_path = exe_path + "\\images\\" + Form1->OwnerData.UID + ".jpg"; AnsiString old_img=exe_path + "\\images\\default.jpg"; AnsiString new_img=image_path; if(FileExists(new_img)==false) CopyFile(old_img.c_str(),new_img.c_str(),true); } if(Form1->OwnerData.Display_Name != Form1->OwnerData.Nick_Name) Form1->Label_OwnerDisplayName->Caption = Form1->OwnerData.Display_Name; Form1->Label_OwnerNickname->Caption = Form1->OwnerData.Nick_Name; Form1->GetFriends(); Form1->GetUnreadPlurks(); return true; } catch(EIdHTTPProtocolException &e) { if(e.ErrorMessage.Pos("Invalid login")>0) { ShowMessage("It appears that you've entered an incorrect nickname, email or password. Please try again. Or register a new account."); } else if(e.ErrorMessage.Pos("Too many logins")>0) ShowMessage("Too many logins"); else ShowMessage(e.ErrorMessage); return false; } }
Get Friends and unread threads:
void __fastcall TForm1::GetFriends() { friendsList = new UserData[iFriendsNum]; fansList = new UserData[iFansNum]; TTreeNode *ItemUnread, *ItemFriends,*ItemFans; ItemUnread=TreeView_Friends->Items->Add(NULL,"Unread("+IntToStr(iUnread)+")"); //parents TreeView_Friends->Items->Item[0]->ImageIndex = 0; TreeView_Friends->Items->Item[0]->SelectedIndex =0; ItemFriends=TreeView_Friends->Items->Add(NULL,"Friends("+IntToStr(iFriendsNum)+")"); //parents TreeView_Friends->Items->Item[1]->ImageIndex = 1; TreeView_Friends->Items->Item[1]->SelectedIndex =1; TTreeNode *FriendsClildNode,*FansClildNode; ItemFans=TreeView_Friends->Items->Add(NULL,"Fans("+IntToStr(iFansNum)+")"); //parents TreeView_Friends->Items->Item[2]->ImageIndex = 2; TreeView_Friends->Items->Item[2]->SelectedIndex = 2; //get Friends int offset_times; if(iFriendsNum % 10 == 0 ) offset_times = iFriendsNum /10; else offset_times = (iFriendsNum /10) +1; //PLURK_GET_FRIENDS int currentOffset; for(int i=0;i<offset_times;i++) { currentOffset = i*10; AnsiString friendBody; AnsiString friendUrl = GetApiUrl(PLURK_GET_FRIENDS + "?api_key=" + API_Key +"&user_id="+OwnerData.UID+"&offset="+currentOffset); try { friendBody=IdHTTP_Plurk->Get(friendUrl); friendBody.Delete(1,1); friendBody.Delete(friendBody.Length(),1); friendBody=StringReplace(friendBody,"},","}\n",TReplaceFlags()<< rfReplaceAll); TStringList *strFriendsListOffset=new TStringList; strFriendsListOffset->Text=friendBody; AnsiString tmp; for(int j=0;j<strFriendsListOffset->Count;j++) { Form_Login->RzProgressStatus_Loading->Percent = (i*10+j)*(100/(iFriendsNum*2))+2; tmp = friendsList[i*10+j].FullString = strFriendsListOffset->Strings[j]; tmp.Delete(1,tmp.Pos("{")); tmp.Delete(tmp.Length(),1); if(tmp.Pos("display_name")>0) { tmp.Delete(1,tmp.Pos(":")); friendsList[i*10+j].Display_Name = tmp.SubString(tmp.Pos("\"") +1 ,tmp.Pos(",")-tmp.Pos("\"")-1); if(friendsList[i*10+j].Display_Name.Pos("\"")>0) friendsList[i*10+j].Display_Name.Delete(friendsList[i*10+j].Display_Name.Length(),1); tmp.Delete(1,tmp.Pos(", ")); } if(tmp.Pos("uid")>0) { tmp.Delete(1,tmp.Pos("uid")-1); tmp.Delete(1,tmp.Pos(":")); friendsList[i*10+j].UID = tmp.SubString(1 ,tmp.Pos(",")-1).Trim(); tmp.Delete(1,tmp.Pos(", ")); } if(tmp.Pos("nick_name")>0) { tmp.Delete(1,tmp.Pos("nick_name")); tmp.Delete(1,tmp.Pos(":")); friendsList[i*10+j].Nick_Name = tmp.SubString(tmp.Pos("\"") +1 ,tmp.Pos("\",")-tmp.Pos("\"")-1); tmp.Delete(1,tmp.Pos(", ")); } if(tmp.Pos("has_profile_image")>0) { tmp.Delete(1,tmp.Pos(":")); friendsList[i*10+j].has_profile_image = tmp.Trim().SubString(1 ,1).Trim().ToInt(); } if(tmp.Pos("avatar")>0) { tmp.Delete(1,tmp.Pos("avatar")); tmp.Delete(1,tmp.Pos(":")); friendsList[i*10+j].Avatar = tmp.SubString(1 ,tmp.Pos(",")-1).Trim(); tmp.Delete(1,tmp.Pos(", ")); } if(tmp.Pos("full_name")>0) { tmp.Delete(1,tmp.Pos(":")); friendsList[i*10+j].Full_Name = tmp.SubString(tmp.Pos("\"") +1 ,tmp.Pos("\",")-tmp.Pos("\"")-1); } if( (friendsList[i*10+j].has_profile_image == 1) && (friendsList[i*10+j].Avatar == "null" || friendsList[i*10+j].Avatar == "0") ) { friendsList[i*10+j].Avatar_S_URL = "http://avatars.plurk.com/"+friendsList[i*10+j].UID+"-small.gif"; friendsList[i*10+j].Avatar_M_URL = "http://avatars.plurk.com/"+friendsList[i*10+j].UID+"-medium.gif"; friendsList[i*10+j].Avatar_B_URL = "http://avatars.plurk.com/"+friendsList[i*10+j].UID+"-big.jpg"; AnsiString image_path = exe_path + "\\images\\" + friendsList[i*10+j].UID + ".jpg"; std::auto_ptr<TFileStream> file(new TFileStream(image_path.c_str(), fmCreate)); IdHTTP_GetImage->Get(friendsList[i*10+j].Avatar_B_URL, file.get() ); } else if( (friendsList[i*10+j].has_profile_image == 1) && (friendsList[i*10+j].Avatar != "null") ) { friendsList[i*10+j].Avatar_S_URL = "http://avatars.plurk.com/"+friendsList[i*10+j].UID+"-small"+friendsList[i*10+j].Avatar+".gif"; friendsList[i*10+j].Avatar_M_URL = "http://avatars.plurk.com/"+friendsList[i*10+j].UID+"-medium"+friendsList[i*10+j].Avatar+".gif"; friendsList[i*10+j].Avatar_B_URL = "http://avatars.plurk.com/"+friendsList[i*10+j].UID+"-big"+friendsList[i*10+j].Avatar+".jpg"; AnsiString image_path = exe_path + "\\images\\" + friendsList[i*10+j].UID + ".jpg"; std::auto_ptr<TFileStream> file(new TFileStream(image_path.c_str(), fmCreate)); IdHTTP_GetImage->Get(friendsList[i*10+j].Avatar_B_URL, file.get() ); } else if(friendsList[i*10+j].has_profile_image == 0) { friendsList[i*10+j].Avatar_S_URL = "http://www.plurk.com/static/default_small.gif"; friendsList[i*10+j].Avatar_M_URL = "http://www.plurk.com/static/default_medium.gif"; friendsList[i*10+j].Avatar_B_URL = "http://www.plurk.com/static/default_big.gif"; AnsiString image_path = exe_path + "\\images\\" + friendsList[i*10+j].UID + ".jpg"; AnsiString old_img=exe_path + "\\images\\default.jpg"; AnsiString new_img=image_path; if(FileExists(new_img)==false) CopyFile(old_img.c_str(),new_img.c_str(),true); } } delete strFriendsListOffset; } catch(EIdHTTPProtocolException &e) { if(e.ErrorMessage.Pos("Invalid login")>0) { ShowMessage("It appears that you've entered an incorrect nickname, email or password. Please try again. Or register a new account."); } else if(e.ErrorMessage.Pos("Too many logins")>0) ShowMessage("Too many logins"); else ShowMessage(e.ErrorMessage); } } for(int i=0;i<iFriendsNum;i++) { Form_Login->RzProgressStatus_Loading->Percent = i*(50/iFriendsNum) + 53; AnsiString image_path = exe_path + "\\images\\" + friendsList[i].UID + ".jpg"; AnsiString bmp_path = exe_path + "\\images\\" + friendsList[i].UID + ".bmp"; TImage *tempImage; tempImage = new TImage(this); AnsiString strUni=""; AnsiString strBig5=""; strUni = friendsList[i].Display_Name.Trim(); while(strUni.Pos("\\u")!=0) { strBig5 += UnicodeToBig5(strUni.SubString(strUni.Pos("\\u")+2,4)); strUni.Delete(strUni.Pos("\\u"),6); } if(strBig5!="") friendsList[i].Display_Name = strBig5; strUni=""; strBig5=""; strUni = friendsList[i].Nick_Name; while(strUni.Pos("\\u")>0) { strBig5 += UnicodeToBig5(strUni.SubString(strUni.Pos("\\u")+2,4)); strUni.Delete(strUni.Pos("\\u"),6); } if(strBig5!="") friendsList[i].Nick_Name = strBig5; if( (friendsList[i].Display_Name != "") && (friendsList[i].Display_Name != friendsList[i].Nick_Name)) FriendsClildNode=TreeView_Friends->Items->AddChild(ItemFriends,friendsList[i].Nick_Name+" - "+friendsList[i].Display_Name); else FriendsClildNode=TreeView_Friends->Items->AddChild(ItemFriends,friendsList[i].Nick_Name); TreeView_Friends->Items->Item[i+2]->ImageIndex = i+3; TreeView_Friends->Items->Item[i+2]->SelectedIndex = i+3; friendsList[i].ImageListIndex = i + 3; } //get Fans int offset_times_Fans; if(iFansNum % 10 == 0 ) offset_times_Fans = iFansNum /10; else offset_times_Fans = (iFansNum /10) +1; int currentOffset_Fans; for(int i=0;i<offset_times_Fans;i++) { currentOffset_Fans = i*10; AnsiString fansBody; AnsiString fansUrl = GetApiUrl(PLURK_GET_FANS + "?api_key=" + API_Key +"&user_id="+OwnerData.UID+"&offset="+currentOffset_Fans); try { Application->ProcessMessages(); fansBody=IdHTTP_Plurk->Get(fansUrl); fansBody.Delete(1,1); fansBody.Delete(fansBody.Length(),1); fansBody=StringReplace(fansBody,"},","}\n",TReplaceFlags()<< rfReplaceAll); TStringList *strFansListOffset=new TStringList; strFansListOffset->Text=fansBody; AnsiString tmp; for(int j=0;j<strFansListOffset->Count;j++) { tmp = fansList[i*10+j].FullString = strFansListOffset->Strings[j]; tmp.Delete(1,tmp.Pos("{")); tmp.Delete(tmp.Length(),1); if(tmp.Pos("display_name")>0) { tmp.Delete(1,tmp.Pos(":")); fansList[i*10+j].Display_Name = tmp.SubString(tmp.Pos("\"") +1 ,tmp.Pos(",")-tmp.Pos("\"")-1); if(fansList[i*10+j].Display_Name.Pos("\"")>0) fansList[i*10+j].Display_Name.Delete(fansList[i*10+j].Display_Name.Length(),1); tmp.Delete(1,tmp.Pos(", ")); } if(tmp.Pos("uid")>0) { tmp.Delete(1,tmp.Pos("uid")-1); tmp.Delete(1,tmp.Pos(":")); fansList[i*10+j].UID = tmp.SubString(1 ,tmp.Pos(",")-1).Trim(); tmp.Delete(1,tmp.Pos(", ")); } if(tmp.Pos("nick_name")>0) { tmp.Delete(1,tmp.Pos("nick_name")); tmp.Delete(1,tmp.Pos(":")); fansList[i*10+j].Nick_Name = tmp.SubString(tmp.Pos("\"") +1 ,tmp.Pos("\",")-tmp.Pos("\"")-1); tmp.Delete(1,tmp.Pos(", ")); } if(tmp.Pos("has_profile_image")>0) { tmp.Delete(1,tmp.Pos(":")); fansList[i*10+j].has_profile_image = tmp.Trim().SubString(1 ,1).Trim().ToInt(); } if(tmp.Pos("avatar")>0) { tmp.Delete(1,tmp.Pos("avatar")); tmp.Delete(1,tmp.Pos(":")); fansList[i*10+j].Avatar = tmp.SubString(1 ,tmp.Pos(",")-1).Trim(); tmp.Delete(1,tmp.Pos(", ")); } if(tmp.Pos("full_name")>0) { tmp.Delete(1,tmp.Pos(":")); fansList[i*10+j].Full_Name = tmp.SubString(tmp.Pos("\"") +1 ,tmp.Pos("\",")-tmp.Pos("\"")-1); } if( (fansList[i*10+j].has_profile_image == 1) && (fansList[i*10+j].Avatar == "null" || fansList[i*10+j].Avatar == "0") ) { fansList[i*10+j].Avatar_S_URL = "http://avatars.plurk.com/"+fansList[i*10+j].UID+"-small.gif"; fansList[i*10+j].Avatar_M_URL = "http://avatars.plurk.com/"+fansList[i*10+j].UID+"-medium.gif"; fansList[i*10+j].Avatar_B_URL = "http://avatars.plurk.com/"+fansList[i*10+j].UID+"-big.jpg"; AnsiString image_path = exe_path + "\\images\\" + fansList[i*10+j].UID + ".jpg"; std::auto_ptr<TFileStream> file(new TFileStream(image_path.c_str(), fmCreate)); IdHTTP_GetImage->Get(fansList[i*10+j].Avatar_B_URL, file.get() ); } else if( (fansList[i*10+j].has_profile_image == 1) && (fansList[i*10+j].Avatar != "null") ) { fansList[i*10+j].Avatar_S_URL = "http://avatars.plurk.com/"+fansList[i*10+j].UID+"-small"+fansList[i*10+j].Avatar+".gif"; fansList[i*10+j].Avatar_M_URL = "http://avatars.plurk.com/"+fansList[i*10+j].UID+"-medium"+fansList[i*10+j].Avatar+".gif"; fansList[i*10+j].Avatar_B_URL = "http://avatars.plurk.com/"+fansList[i*10+j].UID+"-big"+fansList[i*10+j].Avatar+".jpg"; AnsiString image_path = exe_path + "\\images\\" + fansList[i*10+j].UID + ".jpg"; std::auto_ptr<TFileStream> file(new TFileStream(image_path.c_str(), fmCreate)); IdHTTP_GetImage->Get(fansList[i*10+j].Avatar_B_URL, file.get() ); } else if(fansList[i*10+j].has_profile_image == 0) { fansList[i*10+j].Avatar_S_URL = "http://www.plurk.com/static/default_small.gif"; fansList[i*10+j].Avatar_M_URL = "http://www.plurk.com/static/default_medium.gif"; fansList[i*10+j].Avatar_B_URL = "http://www.plurk.com/static/default_big.gif"; AnsiString image_path = exe_path + "\\images\\" + fansList[i*10+j].UID + ".jpg"; AnsiString old_img=exe_path + "\\images\\default.jpg"; AnsiString new_img=image_path; if(FileExists(new_img)==false) CopyFile(old_img.c_str(),new_img.c_str(),true); } Application->ProcessMessages(); } delete strFansListOffset; } catch(EIdHTTPProtocolException &e) { if(e.ErrorMessage.Pos("Invalid login")>0) { ShowMessage("It appears that you've entered an incorrect nickname, email or password. Please try again. Or register a new account."); } else if(e.ErrorMessage.Pos("Too many logins")>0) ShowMessage("Too many logins"); else ShowMessage(e.ErrorMessage); } } for(int i=0;i<iFansNum;i++) { AnsiString image_path = exe_path + "\\images\\" + fansList[i].UID + ".jpg"; AnsiString bmp_path = exe_path + "\\images\\" + fansList[i].UID + ".bmp"; TImage *tempImage; tempImage = new TImage(this); Application->ProcessMessages(); AnsiString strUni=""; AnsiString strBig5=""; strUni = fansList[i].Display_Name; while(strUni.Pos("\\u")>0) { strBig5 += UnicodeToBig5(strUni.SubString(strUni.Pos("\\u")+2,4)); strUni.Delete(strUni.Pos("\\u"),6); } if(strBig5!="") fansList[i].Display_Name = strBig5; strUni=""; strBig5=""; strUni = fansList[i].Nick_Name; while(strUni.Pos("\\u")>0) { strBig5 += UnicodeToBig5(strUni.SubString(strUni.Pos("\\u")+2,4)); strUni.Delete(strUni.Pos("\\u"),6); } if(strBig5!="") fansList[i].Nick_Name = strBig5; if( (fansList[i].Display_Name != "") && (fansList[i].Display_Name != fansList[i].Nick_Name)) FansClildNode=TreeView_Friends->Items->AddChild(ItemFans,fansList[i].Nick_Name+" - "+fansList[i].Display_Name); else FansClildNode=TreeView_Friends->Items->AddChild(ItemFans,fansList[i].Nick_Name); TreeView_Friends->Items->Item[i+iFriendsNum+3]->ImageIndex = i + 3 + iFriendsNum; TreeView_Friends->Items->Item[i+iFriendsNum+3]->SelectedIndex = i + 3 + iFriendsNum; fansList[i].ImageListIndex = i + 3 + iFriendsNum; } for(int i=0;i<TreeView_Friends->Items->Count;i++) { TreeView_Friends->Items->Item[i]->Expand(true); } Form_Login->RzProgressStatus_Loading->Percent = 100; } //--------------------------------------------------------------------------- void __fastcall TForm1::GetUnreadPlurks() { AnsiString unreadBody; AnsiString unreadUrl = GetApiUrl(PLURK_TIMELINE_GET_UNREAD_PLURKS + "?api_key=" + API_Key); bool isEmpty; try { unreadBody=IdHTTP_Plurk->Get(unreadUrl); //-----------Start dealing with unread plurks------------------------ AnsiString plurk_users,plurks; plurk_users = unreadBody.SubString(unreadBody.Pos("\"plurk_users\":"),unreadBody.Pos("\"plurks\":")-unreadBody.Pos("\"plurk_users\":")); plurks = unreadBody.SubString(unreadBody.Pos("\"plurks\":"),unreadBody.Length() - unreadBody.Pos("\"plurks\":")); TTreeNode *ItemUnread,*ItemChildUnread; ItemUnread=TreeView_Friends->Items->Item[0]; //parents //Step 1. plurk user AnsiString tmp_user = plurk_users; int plurk_user_num = 0; tmp_user=tmp_user.Trim(); tmp_user=StringReplace(tmp_user,"},","}\n",TReplaceFlags()<< rfReplaceAll); TStringList *strUnreadListOffset=new TStringList; strUnreadListOffset->Text=tmp_user; plurk_user_num = strUnreadListOffset->Count; tmp_user = plurk_users; int count=0; for(int i=0;i<iFriendsNum;i++) { if(tmp_user.Pos(friendsList[i].UID)>0) { AnsiString strUni=""; AnsiString strBig5=""; strUni = friendsList[i].Nick_Name; while(strUni.Pos("\\u")>0) { strBig5 += UnicodeToBig5(strUni.SubString(strUni.Pos("\\u")+2,4)); strUni.Delete(strUni.Pos("\\u"),6); } if(strBig5!="") friendsList[i].Nick_Name = strBig5; TreeView_Friends->Items->AddChild(ItemUnread,friendsList[i].Nick_Name); TreeView_Friends->Items->Item[count+1]->ImageIndex = friendsList[i].ImageListIndex; TreeView_Friends->Items->Item[count+1]->SelectedIndex = friendsList[i].ImageListIndex; count++; } } if(tmp_user.Pos(OwnerData.UID)>0) { AnsiString strUni=""; AnsiString strBig5=""; strUni = OwnerData.Nick_Name; while(strUni.Pos("\\u")>0) { strBig5 += UnicodeToBig5(strUni.SubString(strUni.Pos("\\u")+2,4)); strUni.Delete(strUni.Pos("\\u"),6); } if(strBig5!="") OwnerData.Nick_Name = strBig5; TreeView_Friends->Items->AddChild(ItemUnread,OwnerData.Nick_Name); count++; } iUnread=plurk_user_num; TreeView_Friends->Items->Item[0]->Text="Unread("+IntToStr(iUnread)+")"; for(int i=0;i<TreeView_Friends->Items->Count;i++) { TreeView_Friends->Items->Item[i]->Expand(true); } //-----------End dealing with unread plurks-------------------------- Application->ProcessMessages(); } catch(EIdHTTPProtocolException &e) { ShowMessage(e.ErrorMessage); } } //--------------------------------------------------------------------------- void __fastcall TForm1::Btn_LogInOutClick(TObject *Sender) { if(Btn_LogInOut->Caption == "Logout") { Btn_LogInOut->Caption="Login"; AnsiString logoutBody; AnsiString logoutUrl = GetApiUrl(PLURK_LOGOUT + "?api_key=" + API_Key); try { Application->ProcessMessages(); logoutBody=IdHTTP_Plurk->Get(logoutUrl); Application->ProcessMessages(); Memo1->Text=logoutBody; TreeView_Friends->Items->Clear(); } catch(EIdHTTPProtocolException &e) { ShowMessage(e.ErrorMessage); } } else if(Btn_LogInOut->Caption == "Login") { Form_Login->ShowModal(); } } //---------------------------------------------------------------------------