PageRenderTime 24ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/miranda/protocols/IcqOscarJ/changeinfo/upload.cpp

http://miranda.googlecode.com/
C++ | 103 lines | 47 code | 20 blank | 36 comment | 12 complexity | 8aabddfd609d137043fcc7a162eb89da MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, LGPL-3.0, LGPL-2.1
  1. // ---------------------------------------------------------------------------80
  2. // ICQ plugin for Miranda Instant Messenger
  3. // ________________________________________
  4. //
  5. // Copyright Š 2001-2004 Richard Hughes, Martin Öberg
  6. // Copyright Š 2004-2009 Joe Kucera, Bio
  7. //
  8. // This program is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU General Public License
  10. // as published by the Free Software Foundation; either version 2
  11. // of the License, or (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. //
  22. // -----------------------------------------------------------------------------
  23. //
  24. // File name : $URL: http://miranda.googlecode.com/svn/trunk/miranda/protocols/IcqOscarJ/changeinfo/upload.cpp $
  25. // Revision : $Revision: 14415 $
  26. // Last change on : $Date: 2013-04-03 21:45:32 +0200 (Wed, 03 Apr 2013) $
  27. // Last change by : $Author: rainwater@gmail.com $
  28. //
  29. // DESCRIPTION:
  30. //
  31. // ChangeInfo Plugin stuff
  32. //
  33. // -----------------------------------------------------------------------------
  34. #include "icqoscar.h"
  35. int CIcqProto::StringToListItemId(const char *szSetting,int def)
  36. {
  37. int i;
  38. for(i=0;i<settingCount;i++)
  39. if(!strcmpnull(szSetting,setting[i].szDbSetting))
  40. break;
  41. if (i==settingCount) return def;
  42. FieldNamesItem *list = (FieldNamesItem*)setting[i].pList;
  43. char *szValue = getSettingStringUtf(NULL, szSetting, NULL);
  44. if (!szValue)
  45. return def;
  46. for (i=0; list[i].text; i++)
  47. if (!strcmpnull(list[i].text, szValue))
  48. break;
  49. SAFE_FREE(&szValue);
  50. if (!list[i].text) return def;
  51. return list[i].code;
  52. }
  53. int ChangeInfoData::UploadSettings(void)
  54. {
  55. if (!ppro->icqOnline())
  56. {
  57. MessageBoxUtf(hwndDlg, LPGEN("You are not currently connected to the ICQ network. You must be online in order to update your information on the server."), LPGEN("Change ICQ Details"), MB_OK);
  58. return 0;
  59. }
  60. hUpload[0] = (HANDLE)ppro->ChangeInfoEx(CIXT_FULL, 0);
  61. //password
  62. char* tmp = ppro->GetUserPassword(TRUE);
  63. if (tmp)
  64. {
  65. if (strlennull(Password) > 0 && strcmpnull(Password, tmp))
  66. {
  67. // update password in user info dialog (still open)
  68. strcpy(Password, tmp);
  69. // update password in protocol
  70. strcpy(ppro->m_szPassword, tmp);
  71. hUpload[1] = (HANDLE)ppro->icq_changeUserPasswordServ(tmp);
  72. char szPwd[PASSWORDMAXLEN] = {0};
  73. if (ppro->GetUserStoredPassword(szPwd, sizeof(szPwd)))
  74. { // password is stored in DB, update
  75. char ptmp[PASSWORDMAXLEN];
  76. strcpy(ptmp, tmp);
  77. CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(ptmp), (LPARAM)ptmp);
  78. ppro->setSettingString(NULL, "Password", ptmp);
  79. }
  80. }
  81. }
  82. return 1;
  83. }