├── .gitignore ├── CHANGELOG.md ├── DuiLib ├── CMakeLists.txt ├── Control │ ├── UIActiveX.cpp │ ├── UIActiveX.h │ ├── UIButton.cpp │ ├── UIButton.h │ ├── UICheckBox.cpp │ ├── UICheckBox.h │ ├── UICombo.cpp │ ├── UICombo.h │ ├── UIComboBox.cpp │ ├── UIComboBox.h │ ├── UIDateTime.cpp │ ├── UIDateTime.h │ ├── UIEdit.cpp │ ├── UIEdit.h │ ├── UIFlash.cpp │ ├── UIFlash.h │ ├── UILabel.cpp │ ├── UILabel.h │ ├── UIList.cpp │ ├── UIList.h │ ├── UIOption.cpp │ ├── UIOption.h │ ├── UIProgress.cpp │ ├── UIProgress.h │ ├── UIRichEdit.cpp │ ├── UIRichEdit.h │ ├── UIScrollBar.cpp │ ├── UIScrollBar.h │ ├── UISlider.cpp │ ├── UISlider.h │ ├── UIText.cpp │ ├── UIText.h │ ├── UITreeView.cpp │ ├── UITreeView.h │ ├── UIWebBrowser.cpp │ └── UIWebBrowser.h ├── Core │ ├── UIBase.cpp │ ├── UIBase.h │ ├── UIContainer.cpp │ ├── UIContainer.h │ ├── UIControl.cpp │ ├── UIControl.h │ ├── UIDefine.h │ ├── UIDlgBuilder.cpp │ ├── UIDlgBuilder.h │ ├── UIManager.cpp │ ├── UIManager.h │ ├── UIMarkup.cpp │ ├── UIMarkup.h │ ├── UIRender.cpp │ └── UIRender.h ├── DuiLib.vcxproj ├── DuiLib.vcxproj.filters ├── Layout │ ├── UIChildLayout.cpp │ ├── UIChildLayout.h │ ├── UIHorizontalLayout.cpp │ ├── UIHorizontalLayout.h │ ├── UITabLayout.cpp │ ├── UITabLayout.h │ ├── UITileLayout.cpp │ ├── UITileLayout.h │ ├── UIVerticalLayout.cpp │ └── UIVerticalLayout.h ├── StdAfx.cpp ├── StdAfx.h ├── UIlib.cpp ├── UIlib.h └── Utils │ ├── Flash11.tlb │ ├── FlashEventHandler.h │ ├── UIDelegate.cpp │ ├── UIDelegate.h │ ├── Utils.cpp │ ├── Utils.h │ ├── WebBrowserEventHandler.h │ ├── WinImplBase.cpp │ ├── WinImplBase.h │ ├── XUnzip.cpp │ ├── downloadmgr.h │ └── stb_image.c ├── HiRedis ├── HiRedis.vcxproj ├── HiRedis.vcxproj.filters ├── hiredis │ ├── .gitignore │ ├── CHANGELOG.md │ ├── CMakeLists.txt │ ├── COPYING │ ├── Makefile │ ├── README.md │ ├── adapters │ │ ├── ae.h │ │ ├── libev.h │ │ └── libevent.h │ ├── async.c │ ├── async.h │ ├── dict.c │ ├── dict.h │ ├── example-ae.c │ ├── example-libev.c │ ├── example-libevent.c │ ├── example.c │ ├── fmacros.h │ ├── hiredis.c │ ├── hiredis.h │ ├── net.c │ ├── net.h │ ├── sds.c │ ├── sds.h │ └── test.c └── win32fix │ ├── adlist.c │ ├── adlist.h │ ├── ae.c │ ├── ae.h │ ├── ae_wsiocp.c │ ├── anet.c │ ├── anet.h │ ├── config.h │ ├── fmacros.h │ ├── win32_wsiocp.c │ ├── win32_wsiocp.h │ ├── win32fixes.c │ ├── win32fixes.h │ ├── winfix.h │ ├── zmalloc.c │ └── zmalloc.h ├── README.md ├── RedisStudio-vs2010.sln ├── RedisStudio ├── AbstractUI.h ├── Base │ ├── CharacterSet.cpp │ ├── CharacterSet.h │ ├── Event.cpp │ ├── Event.h │ ├── Http.cpp │ ├── Http.h │ ├── Mutex.cpp │ ├── Mutex.h │ ├── Runnable.cpp │ ├── Runnable.h │ ├── RunnableAdapter.h │ ├── ScopedLock.h │ ├── String.cpp │ ├── String.h │ ├── Thread.cpp │ ├── Thread.h │ ├── Util.cpp │ └── Util.h ├── ConnInfoSubWhd.cpp ├── ConnInfoSubWhd.h ├── ConnInfoUI.cpp ├── ConnInfoUI.h ├── DBClient.cpp ├── DBClient.h ├── DuiEx │ ├── ObserverBase.h │ ├── UIMenu.cpp │ └── UIMenu.h ├── Environment.cpp ├── Environment.h ├── Main.cpp ├── MainFrameWhd.cpp ├── MainFrameWhd.h ├── MessageBoxWhd.cpp ├── MessageBoxWhd.h ├── Redis │ ├── AbstractRedisModel.h │ ├── RedisClient.cpp │ ├── RedisClient.h │ ├── RedisHashModel.cpp │ ├── RedisHashModel.h │ ├── RedisListModel.cpp │ ├── RedisListModel.h │ ├── RedisModelFactory.cpp │ ├── RedisModelFactory.h │ ├── RedisResult.cpp │ ├── RedisResult.h │ ├── RedisSetModel.cpp │ ├── RedisSetModel.h │ ├── RedisStringModel.cpp │ ├── RedisStringModel.h │ ├── RedisZSetModel.cpp │ ├── RedisZSetModel.h │ └── ScopedRedisReply.h ├── RedisConfigUI.cpp ├── RedisConfigUI.h ├── RedisDataUI.cpp ├── RedisDataUI.h ├── RedisHelpUI.cpp ├── RedisHelpUI.h ├── RedisInfoUI.cpp ├── RedisInfoUI.h ├── RedisMgrUI.cpp ├── RedisMgrUI.h ├── RedisStudio.rc ├── RedisStudio.vcxproj ├── RedisStudio.vcxproj.filters ├── SSDB │ ├── AbstractSSDBModel.h │ ├── SSDB.h │ ├── SSDBClient.cpp │ ├── SSDBClient.h │ ├── SSDBHashModel.cpp │ ├── SSDBHashModel.h │ ├── SSDBModelFactory.cpp │ ├── SSDBModelFactory.h │ ├── SSDBQueueModel.cpp │ ├── SSDBQueueModel.h │ ├── SSDBStringModel.cpp │ ├── SSDBStringModel.h │ ├── SSDBZSetModel.cpp │ ├── SSDBZSetModel.h │ ├── SSDB_impl.cpp │ ├── SSDB_impl.h │ ├── bytes.cpp │ ├── bytes.h │ ├── link.cpp │ ├── link.h │ └── strings.h ├── StdAfx.cpp ├── StdAfx.h ├── UserMessage.cpp ├── UserMessage.h ├── Version.h └── resource.h ├── Skin ├── rs.ico ├── skin-en │ ├── 1_close.png │ ├── 1_open.png │ ├── Combo_nor.bmp │ ├── Combo_over.bmp │ ├── ConnInfo.xml │ ├── ConnSubInfo.xml │ ├── DBOperatorMenu.xml │ ├── KeyOperatorMenu.xml │ ├── MessageBox.xml │ ├── RedisConfig.xml │ ├── RedisData.xml │ ├── RedisHelp.xml │ ├── RedisInfo.xml │ ├── RedisMgr.xml │ ├── Redis_Logo.png │ ├── Skin.jpg │ ├── TreeStandard.png │ ├── btn_add_hover.png │ ├── btn_add_normal.png │ ├── btn_alter_hover.png │ ├── btn_alter_normal.png │ ├── btn_delete_hover.png │ ├── btn_delete_normal.png │ ├── btn_refresh_hover.png │ ├── btn_refresh_normal.png │ ├── button_disable.jpg │ ├── button_down.bmp │ ├── button_focus.jpg │ ├── button_hover.jpg │ ├── button_hover.png │ ├── button_nor.bmp │ ├── button_normal.jpg │ ├── button_normal.png │ ├── button_over.bmp │ ├── button_pushed.jpg │ ├── button_pushed.png │ ├── cloud.png │ ├── cloud_bkgnd.png │ ├── commmon.png │ ├── connect_server.png │ ├── connecterror.png │ ├── examine_background.bmp │ ├── frame_btn_close_disable.bmp │ ├── frame_btn_close_down.bmp │ ├── frame_btn_close_hot.bmp │ ├── frame_btn_close_normal.bmp │ ├── h_dotline.png │ ├── horizontal_border.bmp │ ├── icon.png │ ├── left_menuForOutLook.png │ ├── list_header_bg.png │ ├── list_header_hot.png │ ├── list_header_pushed.png │ ├── list_header_sep.png │ ├── list_icon_a.png │ ├── list_icon_b.png │ ├── menu_bk.png │ ├── msg_icon_check.png │ ├── msg_icon_error.png │ ├── msg_icon_info.png │ ├── msg_icon_question.png │ ├── msg_icon_warning.png │ ├── navigationbar.bmp │ ├── redisconfig.png │ ├── redisinfo.png │ ├── redismgr.png │ ├── redisref.png │ ├── refresh_off.png │ ├── refresh_on.png │ ├── scanbutton.png │ ├── scrollbar.bmp │ ├── skin.xml │ ├── softwaremanager.png │ ├── start.png │ ├── submit_hover.png │ ├── submit_normal.png │ ├── sys_dlg_close.png │ ├── sys_dlg_max.png │ ├── sys_dlg_menu.png │ ├── sys_dlg_min.png │ ├── sys_dlg_restore.png │ ├── tabbar_hover.png │ ├── tabbar_normal.png │ ├── tabbar_pushed.png │ ├── toolbar_hover.png │ ├── toolbar_normal.png │ ├── toolbar_pushed.png │ ├── tree_expand.png │ ├── treeview_expand.png │ ├── treeview_header.png │ ├── v_dotline.png │ ├── vertical_border.bmp │ ├── winbk.bmp │ ├── winbk_menu_close.bmp │ └── winbk_menu_close2.bmp └── skin-zh │ ├── 1_close.png │ ├── 1_open.png │ ├── Combo_nor.bmp │ ├── Combo_over.bmp │ ├── ConnInfo.xml │ ├── ConnSubInfo.xml │ ├── DBOperatorMenu.xml │ ├── KeyOperatorMenu.xml │ ├── MessageBox.xml │ ├── RedisConfig.xml │ ├── RedisData.xml │ ├── RedisHelp.xml │ ├── RedisInfo.xml │ ├── RedisMgr.xml │ ├── Redis_Logo.png │ ├── Skin.jpg │ ├── TreeStandard.png │ ├── btn_add_hover.png │ ├── btn_add_normal.png │ ├── btn_alter_hover.png │ ├── btn_alter_normal.png │ ├── btn_delete_hover.png │ ├── btn_delete_normal.png │ ├── btn_refresh_hover.png │ ├── btn_refresh_normal.png │ ├── button_disable.jpg │ ├── button_down.bmp │ ├── button_focus.jpg │ ├── button_hover.jpg │ ├── button_hover.png │ ├── button_nor.bmp │ ├── button_normal.jpg │ ├── button_normal.png │ ├── button_over.bmp │ ├── button_pushed.jpg │ ├── button_pushed.png │ ├── cloud.png │ ├── cloud_bkgnd.png │ ├── commmon.png │ ├── connect_server.png │ ├── connecterror.png │ ├── examine_background.bmp │ ├── frame_btn_close_disable.bmp │ ├── frame_btn_close_down.bmp │ ├── frame_btn_close_hot.bmp │ ├── frame_btn_close_normal.bmp │ ├── h_dotline.png │ ├── horizontal_border.bmp │ ├── icon.png │ ├── icon.psd │ ├── left_menuForOutLook.png │ ├── list_header_bg.png │ ├── list_header_hot.png │ ├── list_header_pushed.png │ ├── list_header_sep.png │ ├── list_icon_a.png │ ├── list_icon_b.png │ ├── menu_bk.png │ ├── msg_icon_check.png │ ├── msg_icon_error.png │ ├── msg_icon_info.png │ ├── msg_icon_question.png │ ├── msg_icon_warning.png │ ├── navigationbar.bmp │ ├── redisconfig.png │ ├── redisinfo.png │ ├── redismgr.png │ ├── redisref.png │ ├── refresh_off.png │ ├── refresh_on.png │ ├── scanbutton.png │ ├── scrollbar.bmp │ ├── skin.xml │ ├── softwaremanager.png │ ├── start.png │ ├── submit_hover.png │ ├── submit_normal.png │ ├── sys_dlg_close.png │ ├── sys_dlg_max.png │ ├── sys_dlg_menu.png │ ├── sys_dlg_min.png │ ├── sys_dlg_restore.png │ ├── tabbar_hover.png │ ├── tabbar_normal.png │ ├── tabbar_pushed.png │ ├── toolbar_hover.png │ ├── toolbar_normal.png │ ├── toolbar_pushed.png │ ├── tree_expand.png │ ├── treeview_expand.png │ ├── treeview_header.png │ ├── v_dotline.png │ ├── vertical_border.bmp │ ├── winbk.bmp │ ├── winbk_menu_close.bmp │ └── winbk_menu_close2.bmp ├── build ├── directui license.txt ├── duilib license.txt ├── install.nsi ├── msvcr100.dll ├── redis.ico └── redisstudio license.txt ├── docs └── redis.png ├── include ├── rapidjson │ ├── allocators.h │ ├── document.h │ ├── encodedstream.h │ ├── encodings.h │ ├── error │ │ ├── en.h │ │ └── error.h │ ├── filereadstream.h │ ├── filestream.h │ ├── filewritestream.h │ ├── internal │ │ ├── biginteger.h │ │ ├── diyfp.h │ │ ├── dtoa.h │ │ ├── ieee754.h │ │ ├── itoa.h │ │ ├── meta.h │ │ ├── pow10.h │ │ ├── stack.h │ │ ├── strfunc.h │ │ └── strtod.h │ ├── memorybuffer.h │ ├── memorystream.h │ ├── msinttypes │ │ ├── inttypes.h │ │ └── stdint.h │ ├── prettywriter.h │ ├── rapidjson.h │ ├── reader.h │ ├── stringbuffer.h │ └── writer.h └── rapidxml │ ├── license.txt │ ├── manual.html │ ├── rapidxml.hpp │ ├── rapidxml_iterators.hpp │ ├── rapidxml_print.hpp │ └── rapidxml_utils.hpp └── tools └── zip.exe /.gitignore: -------------------------------------------------------------------------------- 1 | *.pdb 2 | /bin/tmp 3 | /*.ncb 4 | /RedisStudio/Debug 5 | *.user 6 | *.user 7 | *.db 8 | *.aps 9 | *.lib 10 | *.exp 11 | /*.opensdf 12 | /*.sdf 13 | /*.suo 14 | /ipch 15 | /ipch 16 | /tmp 17 | /bin/Config.json 18 | /bin 19 | /Skin/skin.zip 20 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | RedisStudio - changlog 2 | 3 | -------------------------------------------------------------- 4 | # 2014-07-20 5 | 1.数据分页增加总页数 6 | 2.连接信息中密码显示为× 7 | 3.连接添加和修改中IP和端口增加空格自动过滤 8 | 4.连接失败显示错误提示窗口 9 | 5.keys按序展示 10 | -------------------------------------------------------------------------------- /DuiLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # cmake file for duilib 2 | #Author Qi Gao(monkgau@gmail.com) 3 | #Created: 2012/09/16 4 | 5 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} Root_src) 6 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Control Control_src) 7 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Core Core_src) 8 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Layout Layout_src) 9 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Utils Utils_src) 10 | 11 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 12 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Control) 13 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Core) 14 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Layout) 15 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Utils) 16 | 17 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 18 | add_library(duilib SHARED ${Control_src} ${Core_src} ${Layout_src} ${Utils_src} ${Root_src}) 19 | 20 | add_definitions(-DUILIB_EXPORTS) 21 | target_link_libraries(duilib riched20 comctl32) 22 | set_target_properties(duilib PROPERTIES OUTPUT_NAME "duilib") 23 | add_custom_command(TARGET duilib POST_BUILD 24 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 25 | ${PROJECT_BINARY_DIR}/lib/duilib.dll ${PROJECT_SOURCE_DIR}/bin/duilib.dll) 26 | -------------------------------------------------------------------------------- /DuiLib/Control/UIActiveX.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UIActiveX.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIActiveX.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIACTIVEX_H__ 2 | #define __UIACTIVEX_H__ 3 | 4 | #pragma once 5 | 6 | struct IOleObject; 7 | 8 | 9 | namespace DuiLib { 10 | ///////////////////////////////////////////////////////////////////////////////////// 11 | // 12 | 13 | class CActiveXCtrl; 14 | 15 | template< class T > 16 | class CSafeRelease 17 | { 18 | public: 19 | CSafeRelease(T* p) : m_p(p) { }; 20 | ~CSafeRelease() { if( m_p != NULL ) m_p->Release(); }; 21 | T* Detach() { T* t = m_p; m_p = NULL; return t; }; 22 | T* m_p; 23 | }; 24 | 25 | ///////////////////////////////////////////////////////////////////////////////////// 26 | // 27 | 28 | class UILIB_API CActiveXUI : public CControlUI, public IMessageFilterUI 29 | { 30 | friend class CActiveXCtrl; 31 | public: 32 | CActiveXUI(); 33 | virtual ~CActiveXUI(); 34 | 35 | LPCTSTR GetClass() const; 36 | LPVOID GetInterface(LPCTSTR pstrName); 37 | 38 | HWND GetHostWindow() const; 39 | 40 | bool IsDelayCreate() const; 41 | void SetDelayCreate(bool bDelayCreate = true); 42 | 43 | bool CreateControl(const CLSID clsid); 44 | bool CreateControl(LPCTSTR pstrCLSID); 45 | HRESULT GetControl(const IID iid, LPVOID* ppRet); 46 | CLSID GetClisd() const; 47 | CDuiString GetModuleName() const; 48 | void SetModuleName(LPCTSTR pstrText); 49 | 50 | void SetVisible(bool bVisible = true); 51 | void SetInternVisible(bool bVisible = true); 52 | void SetPos(RECT rc); 53 | void DoPaint(HDC hDC, const RECT& rcPaint); 54 | 55 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 56 | 57 | LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled); 58 | 59 | protected: 60 | virtual void ReleaseControl(); 61 | virtual bool DoCreateControl(); 62 | 63 | protected: 64 | CLSID m_clsid; 65 | CDuiString m_sModuleName; 66 | bool m_bCreated; 67 | bool m_bDelayCreate; 68 | IOleObject* m_pUnk; 69 | CActiveXCtrl* m_pControl; 70 | HWND m_hwndHost; 71 | }; 72 | 73 | } // namespace DuiLib 74 | 75 | #endif // __UIACTIVEX_H__ 76 | -------------------------------------------------------------------------------- /DuiLib/Control/UIButton.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIBUTTON_H__ 2 | #define __UIBUTTON_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CButtonUI : public CLabelUI 9 | { 10 | public: 11 | CButtonUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | UINT GetControlFlags() const; 16 | 17 | bool Activate(); 18 | void SetEnabled(bool bEnable = true); 19 | void DoEvent(TEventUI& event); 20 | 21 | LPCTSTR GetNormalImage(); 22 | void SetNormalImage(LPCTSTR pStrImage); 23 | LPCTSTR GetHotImage(); 24 | void SetHotImage(LPCTSTR pStrImage); 25 | LPCTSTR GetPushedImage(); 26 | void SetPushedImage(LPCTSTR pStrImage); 27 | LPCTSTR GetFocusedImage(); 28 | void SetFocusedImage(LPCTSTR pStrImage); 29 | LPCTSTR GetDisabledImage(); 30 | void SetDisabledImage(LPCTSTR pStrImage); 31 | LPCTSTR GetForeImage(); 32 | void SetForeImage(LPCTSTR pStrImage); 33 | LPCTSTR GetHotForeImage(); 34 | void SetHotForeImage(LPCTSTR pStrImage); 35 | 36 | void SetHotBkColor(DWORD dwColor); 37 | DWORD GetHotBkColor() const; 38 | void SetHotTextColor(DWORD dwColor); 39 | DWORD GetHotTextColor() const; 40 | void SetPushedTextColor(DWORD dwColor); 41 | DWORD GetPushedTextColor() const; 42 | void SetFocusedTextColor(DWORD dwColor); 43 | DWORD GetFocusedTextColor() const; 44 | SIZE EstimateSize(SIZE szAvailable); 45 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 46 | 47 | void PaintText(HDC hDC); 48 | void PaintStatusImage(HDC hDC); 49 | 50 | protected: 51 | UINT m_uButtonState; 52 | 53 | DWORD m_dwHotBkColor; 54 | DWORD m_dwHotTextColor; 55 | DWORD m_dwPushedTextColor; 56 | DWORD m_dwFocusedTextColor; 57 | 58 | CDuiString m_sNormalImage; 59 | CDuiString m_sHotImage; 60 | CDuiString m_sHotForeImage; 61 | CDuiString m_sPushedImage; 62 | CDuiString m_sPushedForeImage; 63 | CDuiString m_sFocusedImage; 64 | CDuiString m_sDisabledImage; 65 | }; 66 | 67 | } // namespace DuiLib 68 | 69 | #endif // __UIBUTTON_H__ -------------------------------------------------------------------------------- /DuiLib/Control/UICheckBox.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UICheckBox.h" 3 | 4 | namespace DuiLib 5 | { 6 | LPCTSTR CCheckBoxUI::GetClass() const 7 | { 8 | return _T("CheckBoxUI"); 9 | } 10 | 11 | void CCheckBoxUI::SetCheck(bool bCheck) 12 | { 13 | Selected(bCheck); 14 | } 15 | 16 | bool CCheckBoxUI::GetCheck() const 17 | { 18 | return IsSelected(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /DuiLib/Control/UICheckBox.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UICheckBox.h -------------------------------------------------------------------------------- /DuiLib/Control/UICombo.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UICombo.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIComboBox.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UIComboBox.h -------------------------------------------------------------------------------- /DuiLib/Control/UIDateTime.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UIDateTime.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIDateTime.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UIDateTime.h -------------------------------------------------------------------------------- /DuiLib/Control/UIEdit.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIEDIT_H__ 2 | #define __UIEDIT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class CEditWnd; 9 | 10 | class UILIB_API CEditUI : public CLabelUI 11 | { 12 | friend class CEditWnd; 13 | public: 14 | CEditUI(); 15 | 16 | LPCTSTR GetClass() const; 17 | LPVOID GetInterface(LPCTSTR pstrName); 18 | UINT GetControlFlags() const; 19 | 20 | void SetEnabled(bool bEnable = true); 21 | void SetText(LPCTSTR pstrText); 22 | void SetMaxChar(UINT uMax); 23 | UINT GetMaxChar(); 24 | void SetReadOnly(bool bReadOnly); 25 | bool IsReadOnly() const; 26 | void SetPasswordMode(bool bPasswordMode); 27 | bool IsPasswordMode() const; 28 | void SetPasswordChar(TCHAR cPasswordChar); 29 | TCHAR GetPasswordChar() const; 30 | void SetNumberOnly(bool bNumberOnly); 31 | bool IsNumberOnly() const; 32 | int GetWindowStyls() const; 33 | 34 | LPCTSTR GetNormalImage(); 35 | void SetNormalImage(LPCTSTR pStrImage); 36 | LPCTSTR GetHotImage(); 37 | void SetHotImage(LPCTSTR pStrImage); 38 | LPCTSTR GetFocusedImage(); 39 | void SetFocusedImage(LPCTSTR pStrImage); 40 | LPCTSTR GetDisabledImage(); 41 | void SetDisabledImage(LPCTSTR pStrImage); 42 | void SetNativeEditBkColor(DWORD dwBkColor); 43 | DWORD GetNativeEditBkColor() const; 44 | 45 | void SetSel(long nStartChar, long nEndChar); 46 | void SetSelAll(); 47 | void SetReplaceSel(LPCTSTR lpszReplace); 48 | 49 | void SetPos(RECT rc); 50 | void SetVisible(bool bVisible = true); 51 | void SetInternVisible(bool bVisible = true); 52 | SIZE EstimateSize(SIZE szAvailable); 53 | void DoEvent(TEventUI& event); 54 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 55 | 56 | void PaintStatusImage(HDC hDC); 57 | void PaintText(HDC hDC); 58 | 59 | protected: 60 | CEditWnd* m_pWindow; 61 | 62 | UINT m_uMaxChar; 63 | bool m_bReadOnly; 64 | bool m_bPasswordMode; 65 | TCHAR m_cPasswordChar; 66 | UINT m_uButtonState; 67 | CDuiString m_sNormalImage; 68 | CDuiString m_sHotImage; 69 | CDuiString m_sFocusedImage; 70 | CDuiString m_sDisabledImage; 71 | DWORD m_dwEditbkColor; 72 | int m_iWindowStyls; 73 | }; 74 | } 75 | #endif // __UIEDIT_H__ -------------------------------------------------------------------------------- /DuiLib/Control/UIFlash.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UIFlash.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIFlash.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UIFlash.h -------------------------------------------------------------------------------- /DuiLib/Control/UIList.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UIList.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIList.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UIList.h -------------------------------------------------------------------------------- /DuiLib/Control/UIOption.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIOPTION_H__ 2 | #define __UIOPTION_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API COptionUI : public CButtonUI 9 | { 10 | public: 11 | COptionUI(); 12 | ~COptionUI(); 13 | 14 | LPCTSTR GetClass() const; 15 | LPVOID GetInterface(LPCTSTR pstrName); 16 | 17 | void SetManager(CPaintManagerUI* pManager, CControlUI* pParent, bool bInit = true); 18 | 19 | bool Activate(); 20 | void SetEnabled(bool bEnable = true); 21 | 22 | LPCTSTR GetSelectedImage(); 23 | void SetSelectedImage(LPCTSTR pStrImage); 24 | 25 | LPCTSTR GetSelectedHotImage(); 26 | void SetSelectedHotImage(LPCTSTR pStrImage); 27 | 28 | void SetSelectedTextColor(DWORD dwTextColor); 29 | DWORD GetSelectedTextColor(); 30 | 31 | void SetSelectedBkColor(DWORD dwBkColor); 32 | DWORD GetSelectBkColor(); 33 | 34 | LPCTSTR GetForeImage(); 35 | void SetForeImage(LPCTSTR pStrImage); 36 | 37 | LPCTSTR GetGroup() const; 38 | void SetGroup(LPCTSTR pStrGroupName = NULL); 39 | bool IsSelected() const; 40 | virtual void Selected(bool bSelected); 41 | 42 | SIZE EstimateSize(SIZE szAvailable); 43 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 44 | 45 | void PaintStatusImage(HDC hDC); 46 | void PaintText(HDC hDC); 47 | 48 | protected: 49 | bool m_bSelected; 50 | CDuiString m_sGroupName; 51 | 52 | DWORD m_dwSelectedBkColor; 53 | DWORD m_dwSelectedTextColor; 54 | 55 | CDuiString m_sSelectedImage; 56 | CDuiString m_sSelectedHotImage; 57 | CDuiString m_sForeImage; 58 | }; 59 | 60 | } // namespace DuiLib 61 | 62 | #endif // __UIOPTION_H__ -------------------------------------------------------------------------------- /DuiLib/Control/UIProgress.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIPROGRESS_H__ 2 | #define __UIPROGRESS_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CProgressUI : public CLabelUI 9 | { 10 | public: 11 | CProgressUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | 16 | bool IsHorizontal(); 17 | void SetHorizontal(bool bHorizontal = true); 18 | bool IsStretchForeImage(); 19 | void SetStretchForeImage(bool bStretchForeImage = true); 20 | int GetMinValue() const; 21 | void SetMinValue(int nMin); 22 | int GetMaxValue() const; 23 | void SetMaxValue(int nMax); 24 | int GetValue() const; 25 | void SetValue(int nValue); 26 | LPCTSTR GetForeImage() const; 27 | void SetForeImage(LPCTSTR pStrImage); 28 | 29 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 30 | void PaintStatusImage(HDC hDC); 31 | 32 | protected: 33 | bool m_bHorizontal; 34 | bool m_bStretchForeImage; 35 | int m_nMax; 36 | int m_nMin; 37 | int m_nValue; 38 | 39 | CDuiString m_sForeImage; 40 | CDuiString m_sForeImageModify; 41 | }; 42 | 43 | } // namespace DuiLib 44 | 45 | #endif // __UIPROGRESS_H__ 46 | -------------------------------------------------------------------------------- /DuiLib/Control/UIRichEdit.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UIRichEdit.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIRichEdit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UIRichEdit.h -------------------------------------------------------------------------------- /DuiLib/Control/UISlider.h: -------------------------------------------------------------------------------- 1 | #ifndef __UISLIDER_H__ 2 | #define __UISLIDER_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CSliderUI : public CProgressUI 9 | { 10 | public: 11 | CSliderUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | UINT GetControlFlags() const; 15 | LPVOID GetInterface(LPCTSTR pstrName); 16 | 17 | void SetEnabled(bool bEnable = true); 18 | 19 | int GetChangeStep(); 20 | void SetChangeStep(int step); 21 | void SetThumbSize(SIZE szXY); 22 | RECT GetThumbRect() const; 23 | LPCTSTR GetThumbImage() const; 24 | void SetThumbImage(LPCTSTR pStrImage); 25 | LPCTSTR GetThumbHotImage() const; 26 | void SetThumbHotImage(LPCTSTR pStrImage); 27 | LPCTSTR GetThumbPushedImage() const; 28 | void SetThumbPushedImage(LPCTSTR pStrImage); 29 | 30 | void DoEvent(TEventUI& event); 31 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 32 | void PaintStatusImage(HDC hDC); 33 | 34 | protected: 35 | SIZE m_szThumb; 36 | UINT m_uButtonState; 37 | int m_nStep; 38 | 39 | CDuiString m_sThumbImage; 40 | CDuiString m_sThumbHotImage; 41 | CDuiString m_sThumbPushedImage; 42 | 43 | CDuiString m_sImageModify; 44 | }; 45 | } 46 | 47 | #endif // __UISLIDER_H__ -------------------------------------------------------------------------------- /DuiLib/Control/UIText.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITEXT_H__ 2 | #define __UITEXT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CTextUI : public CLabelUI 9 | { 10 | public: 11 | CTextUI(); 12 | ~CTextUI(); 13 | 14 | LPCTSTR GetClass() const; 15 | UINT GetControlFlags() const; 16 | LPVOID GetInterface(LPCTSTR pstrName); 17 | 18 | CDuiString* GetLinkContent(int iIndex); 19 | 20 | void DoEvent(TEventUI& event); 21 | SIZE EstimateSize(SIZE szAvailable); 22 | 23 | void PaintText(HDC hDC); 24 | 25 | protected: 26 | enum { MAX_LINK = 8 }; 27 | int m_nLinks; 28 | RECT m_rcLinks[MAX_LINK]; 29 | CDuiString m_sLinks[MAX_LINK]; 30 | int m_nHoverLink; 31 | }; 32 | 33 | } // namespace DuiLib 34 | 35 | #endif //__UITEXT_H__ -------------------------------------------------------------------------------- /DuiLib/Control/UITreeView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UITreeView.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIWebBrowser.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UIWebBrowser.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIWebBrowser.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Control/UIWebBrowser.h -------------------------------------------------------------------------------- /DuiLib/Core/UIBase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Core/UIBase.cpp -------------------------------------------------------------------------------- /DuiLib/Core/UIBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Core/UIBase.h -------------------------------------------------------------------------------- /DuiLib/Core/UIContainer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Core/UIContainer.cpp -------------------------------------------------------------------------------- /DuiLib/Core/UIContainer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Core/UIContainer.h -------------------------------------------------------------------------------- /DuiLib/Core/UIControl.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Core/UIControl.cpp -------------------------------------------------------------------------------- /DuiLib/Core/UIControl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Core/UIControl.h -------------------------------------------------------------------------------- /DuiLib/Core/UIDefine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Core/UIDefine.h -------------------------------------------------------------------------------- /DuiLib/Core/UIDlgBuilder.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Core/UIDlgBuilder.cpp -------------------------------------------------------------------------------- /DuiLib/Core/UIDlgBuilder.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIDLGBUILDER_H__ 2 | #define __UIDLGBUILDER_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib { 7 | 8 | class IDialogBuilderCallback 9 | { 10 | public: 11 | virtual CControlUI* CreateControl(LPCTSTR pstrClass) = 0; 12 | }; 13 | 14 | 15 | class UILIB_API CDialogBuilder 16 | { 17 | public: 18 | CDialogBuilder(); 19 | CControlUI* Create(STRINGorID xml, LPCTSTR type = NULL, IDialogBuilderCallback* pCallback = NULL, 20 | CPaintManagerUI* pManager = NULL, CControlUI* pParent = NULL); 21 | CControlUI* Create(IDialogBuilderCallback* pCallback = NULL, CPaintManagerUI* pManager = NULL, 22 | CControlUI* pParent = NULL); 23 | 24 | CMarkup* GetMarkup(); 25 | 26 | void GetLastErrorMessage(LPTSTR pstrMessage, SIZE_T cchMax) const; 27 | void GetLastErrorLocation(LPTSTR pstrSource, SIZE_T cchMax) const; 28 | private: 29 | CControlUI* _Parse(CMarkupNode* parent, CControlUI* pParent = NULL, CPaintManagerUI* pManager = NULL); 30 | 31 | CMarkup m_xml; 32 | IDialogBuilderCallback* m_pCallback; 33 | LPCTSTR m_pstrtype; 34 | }; 35 | 36 | } // namespace DuiLib 37 | 38 | #endif // __UIDLGBUILDER_H__ 39 | -------------------------------------------------------------------------------- /DuiLib/Core/UIMarkup.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Core/UIMarkup.cpp -------------------------------------------------------------------------------- /DuiLib/Core/UIRender.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Core/UIRender.cpp -------------------------------------------------------------------------------- /DuiLib/Core/UIRender.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Core/UIRender.h -------------------------------------------------------------------------------- /DuiLib/Layout/UIChildLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UIChildLayout.h" 3 | 4 | namespace DuiLib 5 | { 6 | CChildLayoutUI::CChildLayoutUI() 7 | { 8 | 9 | } 10 | 11 | void CChildLayoutUI::Init() 12 | { 13 | if (!m_pstrXMLFile.IsEmpty()) 14 | { 15 | CDialogBuilder builder; 16 | CContainerUI* pChildWindow = static_cast(builder.Create(m_pstrXMLFile.GetData(), (UINT)0, NULL, m_pManager)); 17 | if (pChildWindow) 18 | { 19 | this->Add(pChildWindow); 20 | } 21 | else 22 | { 23 | this->RemoveAll(); 24 | } 25 | } 26 | } 27 | 28 | void CChildLayoutUI::SetAttribute( LPCTSTR pstrName, LPCTSTR pstrValue ) 29 | { 30 | if( _tcscmp(pstrName, _T("xmlfile")) == 0 ) 31 | SetChildLayoutXML(pstrValue); 32 | else 33 | CContainerUI::SetAttribute(pstrName,pstrValue); 34 | } 35 | 36 | void CChildLayoutUI::SetChildLayoutXML( DuiLib::CDuiString pXML ) 37 | { 38 | m_pstrXMLFile=pXML; 39 | } 40 | 41 | DuiLib::CDuiString CChildLayoutUI::GetChildLayoutXML() 42 | { 43 | return m_pstrXMLFile; 44 | } 45 | 46 | LPVOID CChildLayoutUI::GetInterface( LPCTSTR pstrName ) 47 | { 48 | if( _tcscmp(pstrName, DUI_CTR_CHILDLAYOUT) == 0 ) return static_cast(this); 49 | return CControlUI::GetInterface(pstrName); 50 | } 51 | 52 | LPCTSTR CChildLayoutUI::GetClass() const 53 | { 54 | return _T("ChildLayoutUI"); 55 | } 56 | } // namespace DuiLib 57 | -------------------------------------------------------------------------------- /DuiLib/Layout/UIChildLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UICHILDLAYOUT_H__ 2 | #define __UICHILDLAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CChildLayoutUI : public CContainerUI 9 | { 10 | public: 11 | CChildLayoutUI(); 12 | 13 | void Init(); 14 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 15 | void SetChildLayoutXML(CDuiString pXML); 16 | DuiLib::CDuiString GetChildLayoutXML(); 17 | virtual LPVOID GetInterface(LPCTSTR pstrName); 18 | virtual LPCTSTR GetClass() const; 19 | 20 | private: 21 | DuiLib::CDuiString m_pstrXMLFile; 22 | }; 23 | } // namespace DuiLib 24 | #endif // __UICHILDLAYOUT_H__ 25 | -------------------------------------------------------------------------------- /DuiLib/Layout/UIHorizontalLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIHORIZONTALLAYOUT_H__ 2 | #define __UIHORIZONTALLAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CHorizontalLayoutUI : public CContainerUI 9 | { 10 | public: 11 | CHorizontalLayoutUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | UINT GetControlFlags() const; 16 | 17 | void SetSepWidth(int iWidth); 18 | int GetSepWidth() const; 19 | void SetSepImmMode(bool bImmediately); 20 | bool IsSepImmMode() const; 21 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 22 | void DoEvent(TEventUI& event); 23 | 24 | void SetPos(RECT rc); 25 | void DoPostPaint(HDC hDC, const RECT& rcPaint); 26 | 27 | RECT GetThumbRect(bool bUseNew = false) const; 28 | 29 | protected: 30 | int m_iSepWidth; 31 | UINT m_uButtonState; 32 | POINT ptLastMouse; 33 | RECT m_rcNewPos; 34 | bool m_bImmMode; 35 | }; 36 | } 37 | #endif // __UIHORIZONTALLAYOUT_H__ 38 | -------------------------------------------------------------------------------- /DuiLib/Layout/UITabLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITABLAYOUT_H__ 2 | #define __UITABLAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CTabLayoutUI : public CContainerUI 9 | { 10 | public: 11 | CTabLayoutUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | 16 | bool Add(CControlUI* pControl); 17 | bool AddAt(CControlUI* pControl, int iIndex); 18 | bool Remove(CControlUI* pControl); 19 | void RemoveAll(); 20 | int GetCurSel() const; 21 | bool SelectItem(int iIndex); 22 | bool SelectItem(CControlUI* pControl); 23 | 24 | void SetPos(RECT rc); 25 | 26 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 27 | 28 | protected: 29 | int m_iCurSel; 30 | }; 31 | } 32 | #endif // __UITABLAYOUT_H__ 33 | -------------------------------------------------------------------------------- /DuiLib/Layout/UITileLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITILELAYOUT_H__ 2 | #define __UITILELAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CTileLayoutUI : public CContainerUI 9 | { 10 | public: 11 | CTileLayoutUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | 16 | void SetPos(RECT rc); 17 | 18 | SIZE GetItemSize() const; 19 | void SetItemSize(SIZE szItem); 20 | int GetColumns() const; 21 | void SetColumns(int nCols); 22 | 23 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 24 | 25 | protected: 26 | SIZE m_szItem; 27 | int m_nColumns; 28 | }; 29 | } 30 | #endif // __UITILELAYOUT_H__ 31 | -------------------------------------------------------------------------------- /DuiLib/Layout/UIVerticalLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIVERTICALLAYOUT_H__ 2 | #define __UIVERTICALLAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CVerticalLayoutUI : public CContainerUI 9 | { 10 | public: 11 | CVerticalLayoutUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | UINT GetControlFlags() const; 16 | 17 | void SetSepHeight(int iHeight); 18 | int GetSepHeight() const; 19 | void SetSepImmMode(bool bImmediately); 20 | bool IsSepImmMode() const; 21 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 22 | void DoEvent(TEventUI& event); 23 | 24 | void SetPos(RECT rc); 25 | void DoPostPaint(HDC hDC, const RECT& rcPaint); 26 | 27 | RECT GetThumbRect(bool bUseNew = false) const; 28 | 29 | protected: 30 | int m_iSepHeight; 31 | UINT m_uButtonState; 32 | POINT ptLastMouse; 33 | RECT m_rcNewPos; 34 | bool m_bImmMode; 35 | }; 36 | } 37 | #endif // __UIVERTICALLAYOUT_H__ 38 | -------------------------------------------------------------------------------- /DuiLib/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // UIlib.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "StdAfx.h" 6 | 7 | 8 | #pragma comment( lib, "winmm.lib" ) 9 | #pragma comment( lib, "comctl32.lib" ) 10 | -------------------------------------------------------------------------------- /DuiLib/StdAfx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/StdAfx.h -------------------------------------------------------------------------------- /DuiLib/UIlib.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010-2011, duilib develop team(www.duilib.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or 5 | // without modification, are permitted provided that the 6 | // following conditions are met. 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // 11 | // Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following 13 | // disclaimer in the documentation and/or other materials 14 | // provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 17 | // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 18 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 21 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // 31 | // DirectUI - UI Library 32 | // 33 | // Written by Bjarke Viksoe (bjarke@viksoe.dk) 34 | // Copyright (c) 2006-2007 Bjarke Viksoe. 35 | // 36 | // This code may be used in compiled form in any way you desire. These 37 | // source files may be redistributed by any means PROVIDING it is 38 | // not sold for profit without the authors written consent, and 39 | // providing that this notice and the authors name is included. 40 | // 41 | // This file is provided "as is" with no expressed or implied warranty. 42 | // The author accepts no liability if it causes any damage to you or your 43 | // computer whatsoever. It's free, so don't hassle me about it. 44 | // 45 | // Beware of bugs. 46 | // 47 | // 48 | 49 | 50 | #include "stdafx.h" 51 | #include "UIlib.h" 52 | 53 | 54 | BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID /*lpReserved*/) 55 | { 56 | switch( dwReason ) { 57 | case DLL_PROCESS_ATTACH: 58 | case DLL_THREAD_ATTACH: 59 | case DLL_THREAD_DETACH: 60 | case DLL_PROCESS_DETACH: 61 | ::DisableThreadLibraryCalls((HMODULE)hModule); 62 | break; 63 | } 64 | return TRUE; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /DuiLib/Utils/Flash11.tlb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Utils/Flash11.tlb -------------------------------------------------------------------------------- /DuiLib/Utils/FlashEventHandler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Utils/FlashEventHandler.h -------------------------------------------------------------------------------- /DuiLib/Utils/UIDelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | 3 | namespace DuiLib { 4 | 5 | CDelegateBase::CDelegateBase(void* pObject, void* pFn) 6 | { 7 | m_pObject = pObject; 8 | m_pFn = pFn; 9 | } 10 | 11 | CDelegateBase::CDelegateBase(const CDelegateBase& rhs) 12 | { 13 | m_pObject = rhs.m_pObject; 14 | m_pFn = rhs.m_pFn; 15 | } 16 | 17 | CDelegateBase::~CDelegateBase() 18 | { 19 | 20 | } 21 | 22 | bool CDelegateBase::Equals(const CDelegateBase& rhs) const 23 | { 24 | return m_pObject == rhs.m_pObject && m_pFn == rhs.m_pFn; 25 | } 26 | 27 | bool CDelegateBase::operator() (void* param) 28 | { 29 | return Invoke(param); 30 | } 31 | 32 | void* CDelegateBase::GetFn() 33 | { 34 | return m_pFn; 35 | } 36 | 37 | void* CDelegateBase::GetObject() 38 | { 39 | return m_pObject; 40 | } 41 | 42 | CEventSource::~CEventSource() 43 | { 44 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) { 45 | CDelegateBase* pObject = static_cast(m_aDelegates[i]); 46 | if( pObject) delete pObject; 47 | } 48 | } 49 | 50 | CEventSource::operator bool() 51 | { 52 | return m_aDelegates.GetSize() > 0; 53 | } 54 | 55 | void CEventSource::operator+= (const CDelegateBase& d) 56 | { 57 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) { 58 | CDelegateBase* pObject = static_cast(m_aDelegates[i]); 59 | if( pObject && pObject->Equals(d) ) return; 60 | } 61 | 62 | m_aDelegates.Add(d.Copy()); 63 | } 64 | 65 | void CEventSource::operator+= (FnType pFn) 66 | { 67 | (*this) += MakeDelegate(pFn); 68 | } 69 | 70 | void CEventSource::operator-= (const CDelegateBase& d) 71 | { 72 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) { 73 | CDelegateBase* pObject = static_cast(m_aDelegates[i]); 74 | if( pObject && pObject->Equals(d) ) { 75 | delete pObject; 76 | m_aDelegates.Remove(i); 77 | return; 78 | } 79 | } 80 | } 81 | void CEventSource::operator-= (FnType pFn) 82 | { 83 | (*this) -= MakeDelegate(pFn); 84 | } 85 | 86 | bool CEventSource::operator() (void* param) 87 | { 88 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) { 89 | CDelegateBase* pObject = static_cast(m_aDelegates[i]); 90 | if( pObject && !(*pObject)(param) ) return false; 91 | } 92 | return true; 93 | } 94 | 95 | } // namespace DuiLib 96 | -------------------------------------------------------------------------------- /DuiLib/Utils/UIDelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIDELEGATE_H__ 2 | #define __UIDELEGATE_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib { 7 | 8 | class UILIB_API CDelegateBase 9 | { 10 | public: 11 | CDelegateBase(void* pObject, void* pFn); 12 | CDelegateBase(const CDelegateBase& rhs); 13 | virtual ~CDelegateBase(); 14 | bool Equals(const CDelegateBase& rhs) const; 15 | bool operator() (void* param); 16 | virtual CDelegateBase* Copy() const = 0; // add const for gcc 17 | 18 | protected: 19 | void* GetFn(); 20 | void* GetObject(); 21 | virtual bool Invoke(void* param) = 0; 22 | 23 | private: 24 | void* m_pObject; 25 | void* m_pFn; 26 | }; 27 | 28 | class CDelegateStatic: public CDelegateBase 29 | { 30 | typedef bool (*Fn)(void*); 31 | public: 32 | CDelegateStatic(Fn pFn) : CDelegateBase(NULL, pFn) { } 33 | CDelegateStatic(const CDelegateStatic& rhs) : CDelegateBase(rhs) { } 34 | virtual CDelegateBase* Copy() const { return new CDelegateStatic(*this); } 35 | 36 | protected: 37 | virtual bool Invoke(void* param) 38 | { 39 | Fn pFn = (Fn)GetFn(); 40 | return (*pFn)(param); 41 | } 42 | }; 43 | 44 | template 45 | class CDelegate : public CDelegateBase 46 | { 47 | typedef bool (T::* Fn)(void*); 48 | public: 49 | CDelegate(O* pObj, Fn pFn) : CDelegateBase(pObj, &pFn), m_pFn(pFn) { } 50 | CDelegate(const CDelegate& rhs) : CDelegateBase(rhs) { m_pFn = rhs.m_pFn; } 51 | virtual CDelegateBase* Copy() const { return new CDelegate(*this); } 52 | 53 | protected: 54 | virtual bool Invoke(void* param) 55 | { 56 | O* pObject = (O*) GetObject(); 57 | return (pObject->*m_pFn)(param); 58 | } 59 | 60 | private: 61 | Fn m_pFn; 62 | }; 63 | 64 | template 65 | CDelegate MakeDelegate(O* pObject, bool (T::* pFn)(void*)) 66 | { 67 | return CDelegate(pObject, pFn); 68 | } 69 | 70 | inline CDelegateStatic MakeDelegate(bool (*pFn)(void*)) 71 | { 72 | return CDelegateStatic(pFn); 73 | } 74 | 75 | class UILIB_API CEventSource 76 | { 77 | typedef bool (*FnType)(void*); 78 | public: 79 | ~CEventSource(); 80 | operator bool(); 81 | void operator+= (const CDelegateBase& d); // add const for gcc 82 | void operator+= (FnType pFn); 83 | void operator-= (const CDelegateBase& d); 84 | void operator-= (FnType pFn); 85 | bool operator() (void* param); 86 | 87 | protected: 88 | CStdPtrArray m_aDelegates; 89 | }; 90 | 91 | } // namespace DuiLib 92 | 93 | #endif // __UIDELEGATE_H__ -------------------------------------------------------------------------------- /DuiLib/Utils/Utils.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Utils/Utils.cpp -------------------------------------------------------------------------------- /DuiLib/Utils/WebBrowserEventHandler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Utils/WebBrowserEventHandler.h -------------------------------------------------------------------------------- /DuiLib/Utils/WinImplBase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Utils/WinImplBase.cpp -------------------------------------------------------------------------------- /DuiLib/Utils/WinImplBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/DuiLib/Utils/WinImplBase.h -------------------------------------------------------------------------------- /HiRedis/HiRedis.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 源文件 29 | 30 | 31 | 源文件 32 | 33 | 34 | 源文件 35 | 36 | 37 | 源文件 38 | 39 | 40 | 源文件 41 | 42 | 43 | 源文件 44 | 45 | 46 | 源文件 47 | 48 | 49 | 源文件 50 | 51 | 52 | 53 | 54 | 头文件 55 | 56 | 57 | 头文件 58 | 59 | 60 | 头文件 61 | 62 | 63 | 头文件 64 | 65 | 66 | -------------------------------------------------------------------------------- /HiRedis/hiredis/.gitignore: -------------------------------------------------------------------------------- 1 | /hiredis-test 2 | /hiredis-example* 3 | /*.o 4 | /*.so 5 | /*.dylib 6 | /*.a 7 | -------------------------------------------------------------------------------- /HiRedis/hiredis/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 0.10.1 2 | 3 | * Makefile overhaul. Important to check out if you override one or more 4 | variables using environment variables or via arguments to the "make" tool. 5 | 6 | * Issue #45: Fix potential memory leak for a multi bulk reply with 0 elements 7 | being created by the default reply object functions. 8 | 9 | * Issue #43: Don't crash in an asynchronous context when Redis returns an error 10 | reply after the connection has been made (this happens when the maximum 11 | number of connections is reached). 12 | 13 | ### 0.10.0 14 | 15 | * See commit log. 16 | 17 | -------------------------------------------------------------------------------- /HiRedis/hiredis/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | set(LIB_NAME hiredis) 6 | 7 | 8 | set(LIB_SRCS 9 | hiredis.c 10 | net.c 11 | sds.c 12 | dict.c 13 | async.c 14 | ) 15 | 16 | #aux_source_directory(. LIB_SRCS) 17 | 18 | #set(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} "-std=c99 -pedantic") 19 | #set(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} "-std=c99 -pedantic") 20 | add_library(${LIB_NAME} STATIC ${LIB_SRCS}) 21 | 22 | -------------------------------------------------------------------------------- /HiRedis/hiredis/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2011, Salvatore Sanfilippo 2 | Copyright (c) 2010-2011, Pieter Noordhuis 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of Redis nor the names of its contributors may be used 17 | to endorse or promote products derived from this software without specific 18 | prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /HiRedis/hiredis/example-ae.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "hiredis.h" 6 | #include "async.h" 7 | #include "adapters/ae.h" 8 | 9 | /* Put event loop in the global scope, so it can be explicitly stopped */ 10 | static aeEventLoop *loop; 11 | 12 | void getCallback(redisAsyncContext *c, void *r, void *privdata) { 13 | redisReply *reply = r; 14 | if (reply == NULL) return; 15 | printf("argv[%s]: %s\n", (char*)privdata, reply->str); 16 | 17 | /* Disconnect after receiving the reply to GET */ 18 | redisAsyncDisconnect(c); 19 | } 20 | 21 | void connectCallback(const redisAsyncContext *c, int status) { 22 | if (status != REDIS_OK) { 23 | printf("Error: %s\n", c->errstr); 24 | return; 25 | } 26 | printf("Connected...\n"); 27 | } 28 | 29 | void disconnectCallback(const redisAsyncContext *c, int status) { 30 | if (status != REDIS_OK) { 31 | printf("Error: %s\n", c->errstr); 32 | return; 33 | } 34 | printf("Disconnected...\n"); 35 | } 36 | 37 | int main (int argc, char **argv) { 38 | signal(SIGPIPE, SIG_IGN); 39 | 40 | redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); 41 | if (c->err) { 42 | /* Let *c leak for now... */ 43 | printf("Error: %s\n", c->errstr); 44 | return 1; 45 | } 46 | 47 | loop = aeCreateEventLoop(); 48 | redisAeAttach(loop, c); 49 | redisAsyncSetConnectCallback(c,connectCallback); 50 | redisAsyncSetDisconnectCallback(c,disconnectCallback); 51 | redisAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1])); 52 | redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key"); 53 | aeMain(loop); 54 | return 0; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /HiRedis/hiredis/example-libev.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "hiredis.h" 6 | #include "async.h" 7 | #include "adapters/libev.h" 8 | 9 | void getCallback(redisAsyncContext *c, void *r, void *privdata) { 10 | redisReply *reply = r; 11 | if (reply == NULL) return; 12 | printf("argv[%s]: %s\n", (char*)privdata, reply->str); 13 | 14 | /* Disconnect after receiving the reply to GET */ 15 | redisAsyncDisconnect(c); 16 | } 17 | 18 | void connectCallback(const redisAsyncContext *c, int status) { 19 | if (status != REDIS_OK) { 20 | printf("Error: %s\n", c->errstr); 21 | return; 22 | } 23 | printf("Connected...\n"); 24 | } 25 | 26 | void disconnectCallback(const redisAsyncContext *c, int status) { 27 | if (status != REDIS_OK) { 28 | printf("Error: %s\n", c->errstr); 29 | return; 30 | } 31 | printf("Disconnected...\n"); 32 | } 33 | 34 | int main (int argc, char **argv) { 35 | signal(SIGPIPE, SIG_IGN); 36 | 37 | redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); 38 | if (c->err) { 39 | /* Let *c leak for now... */ 40 | printf("Error: %s\n", c->errstr); 41 | return 1; 42 | } 43 | 44 | redisLibevAttach(EV_DEFAULT_ c); 45 | redisAsyncSetConnectCallback(c,connectCallback); 46 | redisAsyncSetDisconnectCallback(c,disconnectCallback); 47 | redisAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1])); 48 | redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key"); 49 | ev_loop(EV_DEFAULT_ 0); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /HiRedis/hiredis/example-libevent.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "hiredis.h" 6 | #include "async.h" 7 | #include "adapters/libevent.h" 8 | 9 | void getCallback(redisAsyncContext *c, void *r, void *privdata) { 10 | redisReply *reply = r; 11 | if (reply == NULL) return; 12 | printf("argv[%s]: %s\n", (char*)privdata, reply->str); 13 | 14 | /* Disconnect after receiving the reply to GET */ 15 | redisAsyncDisconnect(c); 16 | } 17 | 18 | void connectCallback(const redisAsyncContext *c, int status) { 19 | if (status != REDIS_OK) { 20 | printf("Error: %s\n", c->errstr); 21 | return; 22 | } 23 | printf("Connected...\n"); 24 | } 25 | 26 | void disconnectCallback(const redisAsyncContext *c, int status) { 27 | if (status != REDIS_OK) { 28 | printf("Error: %s\n", c->errstr); 29 | return; 30 | } 31 | printf("Disconnected...\n"); 32 | } 33 | 34 | int main (int argc, char **argv) { 35 | signal(SIGPIPE, SIG_IGN); 36 | struct event_base *base = event_base_new(); 37 | 38 | redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); 39 | if (c->err) { 40 | /* Let *c leak for now... */ 41 | printf("Error: %s\n", c->errstr); 42 | return 1; 43 | } 44 | 45 | redisLibeventAttach(c,base); 46 | redisAsyncSetConnectCallback(c,connectCallback); 47 | redisAsyncSetDisconnectCallback(c,disconnectCallback); 48 | redisAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1])); 49 | redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key"); 50 | event_base_dispatch(base); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /HiRedis/hiredis/example.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "hiredis.h" 6 | 7 | int main(void) { 8 | unsigned int j; 9 | redisContext *c; 10 | redisReply *reply; 11 | 12 | struct timeval timeout = { 1, 500000 }; // 1.5 seconds 13 | c = redisConnectWithTimeout((char*)"127.0.0.2", 6379, timeout); 14 | if (c->err) { 15 | printf("Connection error: %s\n", c->errstr); 16 | exit(1); 17 | } 18 | 19 | /* PING server */ 20 | reply = redisCommand(c,"PING"); 21 | printf("PING: %s\n", reply->str); 22 | freeReplyObject(reply); 23 | 24 | /* Set a key */ 25 | reply = redisCommand(c,"SET %s %s", "foo", "hello world"); 26 | printf("SET: %s\n", reply->str); 27 | freeReplyObject(reply); 28 | 29 | /* Set a key using binary safe API */ 30 | reply = redisCommand(c,"SET %b %b", "bar", 3, "hello", 5); 31 | printf("SET (binary API): %s\n", reply->str); 32 | freeReplyObject(reply); 33 | 34 | /* Try a GET and two INCR */ 35 | reply = redisCommand(c,"GET foo"); 36 | printf("GET foo: %s\n", reply->str); 37 | freeReplyObject(reply); 38 | 39 | reply = redisCommand(c,"INCR counter"); 40 | printf("INCR counter: %lld\n", reply->integer); 41 | freeReplyObject(reply); 42 | /* again ... */ 43 | reply = redisCommand(c,"INCR counter"); 44 | printf("INCR counter: %lld\n", reply->integer); 45 | freeReplyObject(reply); 46 | 47 | /* Create a list of numbers, from 0 to 9 */ 48 | reply = redisCommand(c,"DEL mylist"); 49 | freeReplyObject(reply); 50 | for (j = 0; j < 10; j++) { 51 | char buf[64]; 52 | 53 | snprintf(buf,64,"%d",j); 54 | reply = redisCommand(c,"LPUSH mylist element-%s", buf); 55 | freeReplyObject(reply); 56 | } 57 | 58 | /* Let's check what we have inside the list */ 59 | reply = redisCommand(c,"LRANGE mylist 0 -1"); 60 | if (reply->type == REDIS_REPLY_ARRAY) { 61 | for (j = 0; j < reply->elements; j++) { 62 | printf("%u) %s\n", j, reply->element[j]->str); 63 | } 64 | } 65 | freeReplyObject(reply); 66 | 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /HiRedis/hiredis/fmacros.h: -------------------------------------------------------------------------------- 1 | #ifndef __HIREDIS_FMACRO_H 2 | #define __HIREDIS_FMACRO_H 3 | 4 | #if !defined(_BSD_SOURCE) 5 | #define _BSD_SOURCE 6 | #endif 7 | 8 | #if defined(__sun__) 9 | #define _POSIX_C_SOURCE 200112L 10 | #elif defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) 11 | #define _XOPEN_SOURCE 600 12 | #else 13 | #define _XOPEN_SOURCE 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /HiRedis/hiredis/net.h: -------------------------------------------------------------------------------- 1 | /* Extracted from anet.c to work properly with Hiredis error reporting. 2 | * 3 | * Copyright (c) 2006-2011, Salvatore Sanfilippo 4 | * Copyright (c) 2010-2011, Pieter Noordhuis 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * * Neither the name of Redis nor the names of its contributors may be used 17 | * to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef __NET_H 34 | #define __NET_H 35 | 36 | #include "hiredis.h" 37 | 38 | #if defined(__sun) 39 | #define AF_LOCAL AF_UNIX 40 | #endif 41 | 42 | int redisCheckSocketError(redisContext *c, int fd); 43 | int redisContextSetTimeout(redisContext *c, struct timeval tv); 44 | int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct timeval *timeout); 45 | int redisContextConnectUnix(redisContext *c, const char *path, struct timeval *timeout); 46 | #ifdef _WIN32 47 | int redisContextPreConnectTcp(redisContext *c, const char *addr, int port, struct timeval *timeout, struct sockaddr_in *sa); 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /HiRedis/win32fix/anet.h: -------------------------------------------------------------------------------- 1 | /* anet.c -- Basic TCP socket stuff made a bit less boring 2 | * 3 | * Copyright (c) 2006-2012, Salvatore Sanfilippo 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of Redis nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef ANET_H 32 | #define ANET_H 33 | 34 | #define ANET_OK 0 35 | #define ANET_ERR -1 36 | #define ANET_ERR_LEN 256 37 | 38 | #if defined(__sun) 39 | #define AF_LOCAL AF_UNIX 40 | #endif 41 | 42 | int anetTcpConnect(char *err, char *addr, int port); 43 | int anetTcpNonBlockConnect(char *err, char *addr, int port); 44 | int anetUnixConnect(char *err, char *path); 45 | int anetUnixNonBlockConnect(char *err, char *path); 46 | int anetRead(int fd, char *buf, int count); 47 | int anetResolve(char *err, char *host, char *ipbuf); 48 | int anetTcpServer(char *err, int port, char *bindaddr); 49 | int anetUnixServer(char *err, char *path, mode_t perm); 50 | int anetTcpAccept(char *err, int serversock, char *ip, int *port); 51 | int anetUnixAccept(char *err, int serversock); 52 | int anetWrite(int fd, char *buf, int count); 53 | int anetNonBlock(char *err, int fd); 54 | int anetEnableTcpNoDelay(char *err, int fd); 55 | int anetDisableTcpNoDelay(char *err, int fd); 56 | int anetTcpKeepAlive(char *err, int fd); 57 | int anetPeerToString(int fd, char *ip, int *port); 58 | int anetKeepAlive(char *err, int fd, int interval); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /HiRedis/win32fix/fmacros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2012, Salvatore Sanfilippo 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * * Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of Redis nor the names of its contributors may be used 14 | * to endorse or promote products derived from this software without 15 | * specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | * POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _REDIS_FMACRO_H 31 | #define _REDIS_FMACRO_H 32 | 33 | #define _BSD_SOURCE 34 | 35 | #if defined(__linux__) 36 | #define _GNU_SOURCE 37 | #endif 38 | 39 | #if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) 40 | #define _XOPEN_SOURCE 700 41 | #else 42 | #define _XOPEN_SOURCE 43 | #endif 44 | 45 | #define _LARGEFILE_SOURCE 46 | #define _FILE_OFFSET_BITS 64 47 | 48 | #ifdef _WIN32 49 | #define off off_t 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /HiRedis/win32fix/win32_wsiocp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c), Microsoft Open Technologies, Inc. 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * - Redistributions of source code must retain the above copyright notice, 7 | * this list of conditions and the following disclaimer. 8 | * - Redistributions in binary form must reproduce the above copyright notice, 9 | * this list of conditions and the following disclaimer in the documentation 10 | * and/or other materials provided with the distribution. 11 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 12 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 13 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 14 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 15 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 16 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 17 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 18 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 19 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 20 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef WIN32WSIOCP_H 24 | #define WIN32WSIOCP_H 25 | 26 | #ifdef _WIN32 27 | /* structs and functions for using IOCP with windows sockets */ 28 | 29 | /* structure used for async write requests. 30 | * contains overlapped, WSABuf, and callback info 31 | * NOTE: OVERLAPPED must be first member */ 32 | typedef struct asendreq { 33 | OVERLAPPED ov; 34 | WSABUF wbuf; 35 | aeWinSendReq req; 36 | aeFileProc *proc; 37 | aeEventLoop *eventLoop; 38 | } asendreq; 39 | 40 | /* structure used for async accept requests. 41 | * contains overlapped, accept socket, accept buffer 42 | * NOTE: OVERLAPPED must be first member */ 43 | typedef struct aacceptreq { 44 | OVERLAPPED ov; 45 | SOCKET accept; 46 | void *buf; 47 | struct aacceptreq *next; 48 | } aacceptreq; 49 | 50 | 51 | /* per socket information */ 52 | typedef struct aeSockState { 53 | int masks; 54 | int fd; 55 | aacceptreq *reqs; 56 | int wreqs; 57 | OVERLAPPED ov_read; 58 | list wreqlist; 59 | } aeSockState; 60 | 61 | typedef aeSockState * fnGetSockState(void *apistate, int fd); 62 | typedef void fnDelSockState(void *apistate, aeSockState *sockState); 63 | 64 | #define READ_QUEUED 0x000100 65 | #define SOCKET_ATTACHED 0x000400 66 | #define ACCEPT_PENDING 0x000800 67 | #define LISTEN_SOCK 0x001000 68 | #define CONNECT_PENDING 0x002000 69 | #define CLOSE_PENDING 0x004000 70 | 71 | void aeWinInit(void *state, HANDLE iocp, fnGetSockState *getSockState, fnDelSockState *delSockState); 72 | void aeWinCleanup(); 73 | 74 | #endif 75 | #endif 76 | -------------------------------------------------------------------------------- /HiRedis/win32fix/winfix.h: -------------------------------------------------------------------------------- 1 | #ifndef _WINFIX__H_ 2 | #define _WINFIX__H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "win32fixes.h" 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RedisStudio (Redis GUI Client) 2 | 3 | ## Download 4 | [![GitHub release](https://img.shields.io/github/release/cinience/RedisStudio.svg?style=flat-square)](https://github.com/cinience/RedisStudio/releases) 5 | 6 | ## Introduction 7 | 1. Redis Studio is Redis GUI Client,support Windows xp, windows 7, windows 8 8 | 2. Kernel is MSOpen hiredis, GUILIB is duilib 9 | 3. Support official Redis 2.6 2.7 2.8 new.. 10 | 11 | ![UI](https://raw.githubusercontent.com/cinience/RedisStudio/master/docs/redis.png "RedisStudio UI") 12 | 13 | ## Supported platforms 14 | 15 | * Windows xp 16 | * Windows Vista 17 | * Windows 7 18 | * Windows 8, 8.1 19 | * Windows 10 20 | 21 | ## Supported Redis version 22 | * Official Redis 2.6 23 | * Official Redis 2.7 24 | * Official Redis 2.8 25 | * Official Redis new 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /RedisStudio/AbstractUI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Environment.h" 4 | 5 | class AbstraceUI : public CContainerUI, public CNotifyPump 6 | { 7 | public: 8 | AbstraceUI(CPaintManagerUI* pm, Environment* env):m_hWnd(NULL),m_pPaintManager(pm),m_pEnv(env){}; 9 | 10 | virtual ~AbstraceUI(){}; 11 | 12 | virtual void Initialize() {}; 13 | 14 | virtual CDuiString GetVirtualwndName() = 0; 15 | 16 | virtual void RefreshWnd() = 0; 17 | 18 | virtual int GetIndex() = 0; 19 | 20 | virtual bool CanChange() 21 | { 22 | return true; 23 | } 24 | 25 | virtual LRESULT HandleCustomMessage( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) 26 | { 27 | bHandled = FALSE; 28 | return 0; 29 | } 30 | 31 | /// 设置窗口句柄 32 | inline void SetHWND(HWND hwnd) 33 | { 34 | m_hWnd = hwnd; 35 | } 36 | 37 | inline HWND GetHWND() 38 | { 39 | return m_hWnd; 40 | } 41 | 42 | inline CPaintManagerUI* GetPaintMgr() 43 | { 44 | return m_pPaintManager; 45 | } 46 | 47 | inline Environment* Env() 48 | { 49 | return m_pEnv; 50 | } 51 | private: 52 | CPaintManagerUI* m_pPaintManager; 53 | Environment* m_pEnv; 54 | HWND m_hWnd; 55 | }; 56 | -------------------------------------------------------------------------------- /RedisStudio/Base/CharacterSet.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "CharacterSet.h" 3 | 4 | namespace Base { 5 | 6 | std::string CharacterSet::UnicodeConvert( const std::wstring& strWide, UINT uCodePage ) 7 | { 8 | std::string strANSI; 9 | int iLen = ::WideCharToMultiByte(uCodePage, 0, strWide.c_str(), -1, NULL, 0, NULL, NULL); 10 | 11 | if (iLen > 1) 12 | { 13 | strANSI.resize(iLen-1); 14 | ::WideCharToMultiByte(uCodePage, 0, strWide.c_str(), -1, &strANSI[0], iLen, NULL, NULL); 15 | } 16 | 17 | return strANSI; 18 | } 19 | 20 | std::string CharacterSet::UnicodeToUTF8( const std::wstring& strWide ) 21 | { 22 | return UnicodeConvert(strWide, CP_UTF8); 23 | } 24 | 25 | std::string CharacterSet::UnicodeToANSI( const std::wstring& strWide ) 26 | { 27 | return UnicodeConvert(strWide, CP_ACP); 28 | } 29 | 30 | std::wstring CharacterSet::ANSIToUnicode( const std::string& str ) 31 | { 32 | int uniocedeLen = ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0); 33 | wchar_t* pUnicode = new wchar_t[uniocedeLen + 1]; 34 | memset(pUnicode, 0 ,(uniocedeLen+1)*sizeof(wchar_t)); 35 | ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, (LPWSTR)pUnicode, uniocedeLen); 36 | 37 | wstring rt = (wchar_t*) pUnicode; 38 | delete pUnicode; 39 | 40 | return rt; 41 | } 42 | 43 | std::wstring CharacterSet::UTF8ToUnicode( const std::string& str ) 44 | { 45 | int uniocedeLen = ::MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.size(), NULL, 0); 46 | wchar_t* pUnicode = new wchar_t[uniocedeLen + 1]; 47 | memset(pUnicode, 0 ,(uniocedeLen+1)*sizeof(wchar_t)); 48 | ::MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.size(), (LPWSTR)pUnicode, uniocedeLen); 49 | 50 | wstring rt = (wchar_t*) pUnicode; 51 | delete pUnicode; 52 | 53 | return rt; 54 | } 55 | 56 | } // namespace Base 57 | -------------------------------------------------------------------------------- /RedisStudio/Base/CharacterSet.h: -------------------------------------------------------------------------------- 1 | #ifndef Base_CharacterSet_INCLUDED 2 | #define Base_CharacterSet_INCLUDED 3 | 4 | namespace Base { 5 | 6 | class CharacterSet 7 | { 8 | public: 9 | static std::string UnicodeConvert(const std::wstring& strWide, UINT uCodePage); 10 | 11 | static std::string UnicodeToUTF8(const std::wstring& strWide); 12 | 13 | static std::string UnicodeToANSI(const std::wstring& strWide); 14 | 15 | static std::wstring ANSIToUnicode(const std::string& str); 16 | 17 | static std::wstring UTF8ToUnicode(const std::string& str); 18 | 19 | }; 20 | 21 | } // namespace Base 22 | 23 | #endif -------------------------------------------------------------------------------- /RedisStudio/Base/Event.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Event.h" 3 | 4 | namespace Base { 5 | 6 | Event::Event(bool autoReset) 7 | { 8 | _event = CreateEventW(NULL, autoReset ? FALSE : TRUE, FALSE, NULL); 9 | if (!_event) 10 | throw std::exception("cannot create event"); 11 | } 12 | 13 | 14 | Event::~Event() 15 | { 16 | CloseHandle(_event); 17 | } 18 | 19 | 20 | void Event::wait() 21 | { 22 | switch (WaitForSingleObject(_event, INFINITE)) 23 | { 24 | case WAIT_OBJECT_0: 25 | return; 26 | default: 27 | throw std::exception("wait for event failed"); 28 | } 29 | } 30 | 31 | 32 | bool Event::wait(long milliseconds) 33 | { 34 | switch (WaitForSingleObject(_event, milliseconds + 1)) 35 | { 36 | case WAIT_TIMEOUT: 37 | return false; 38 | case WAIT_OBJECT_0: 39 | return true; 40 | default: 41 | throw std::exception("wait for event failed"); 42 | } 43 | } 44 | 45 | } //namespace Base -------------------------------------------------------------------------------- /RedisStudio/Base/Event.h: -------------------------------------------------------------------------------- 1 | #ifndef Base_Event_INCLUDED 2 | #define Base_Event_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | namespace Base { 8 | class Event 9 | { 10 | public: 11 | Event(bool autoReset); 12 | ~Event(); 13 | void set(); 14 | void wait(); 15 | bool wait(long milliseconds); 16 | void reset(); 17 | 18 | private: 19 | HANDLE _event; 20 | }; 21 | 22 | 23 | // 24 | // inlines 25 | // 26 | inline void Event::set() 27 | { 28 | if (!SetEvent(_event)) 29 | { 30 | throw std::exception("cannot signal event"); 31 | } 32 | } 33 | 34 | 35 | inline void Event::reset() 36 | { 37 | if (!ResetEvent(_event)) 38 | { 39 | throw std::exception("cannot reset event"); 40 | } 41 | } 42 | 43 | } //namespace Base 44 | 45 | #endif -------------------------------------------------------------------------------- /RedisStudio/Base/Http.h: -------------------------------------------------------------------------------- 1 | #ifndef Base_Http_INCLUDED 2 | #define Base_Http_INCLUDED 3 | 4 | #include "ScopedLock.h" 5 | 6 | namespace Base { 7 | 8 | class Http 9 | { 10 | public: 11 | class Response { 12 | public: 13 | int status; 14 | std::string data; 15 | }; 16 | 17 | Http(const std::string& hostname, int port); 18 | 19 | ~Http(); 20 | 21 | bool ping(); 22 | 23 | Response post(const std::string& path, const std::string& data); 24 | 25 | private: 26 | std::string _host; 27 | std::string _ip; 28 | int _port; 29 | }; 30 | 31 | } // namespace Base 32 | 33 | #endif -------------------------------------------------------------------------------- /RedisStudio/Base/Mutex.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Mutex.h" 3 | 4 | namespace Base { 5 | 6 | Mutex::Mutex() 7 | { 8 | InitializeCriticalSectionAndSpinCount(&_cs, 4000); 9 | } 10 | 11 | 12 | Mutex::~Mutex() 13 | { 14 | DeleteCriticalSection(&_cs); 15 | } 16 | 17 | } // namespace Mutex -------------------------------------------------------------------------------- /RedisStudio/Base/Mutex.h: -------------------------------------------------------------------------------- 1 | #ifndef Base_ScopedMutex_INCLUDED 2 | #define Base_ScopedMutex_INCLUDED 3 | 4 | #include "ScopedLock.h" 5 | 6 | namespace Base { 7 | 8 | class Mutex 9 | { 10 | public: 11 | typedef ScopedLock ScopedLock; 12 | public: 13 | Mutex(); 14 | ~Mutex(); 15 | void lock(); 16 | bool tryLock(); 17 | void unlock(); 18 | 19 | private: 20 | CRITICAL_SECTION _cs; 21 | }; 22 | 23 | inline void Mutex::lock() 24 | { 25 | try 26 | { 27 | EnterCriticalSection(&_cs); 28 | } 29 | catch (...) 30 | { 31 | throw std::exception("cannot lock mutex"); 32 | } 33 | } 34 | 35 | 36 | inline bool Mutex::tryLock() 37 | { 38 | try 39 | { 40 | return TryEnterCriticalSection(&_cs) != 0; 41 | } 42 | catch (...) 43 | { 44 | } 45 | throw std::exception("cannot lock mutex"); 46 | } 47 | 48 | 49 | inline void Mutex::unlock() 50 | { 51 | LeaveCriticalSection(&_cs); 52 | } 53 | 54 | } // namespace Base 55 | 56 | #endif -------------------------------------------------------------------------------- /RedisStudio/Base/Runnable.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Runnable.h" 3 | 4 | 5 | namespace Base { 6 | 7 | 8 | Runnable::Runnable() 9 | { 10 | } 11 | 12 | 13 | Runnable::~Runnable() 14 | { 15 | } 16 | 17 | 18 | } // namespace Base 19 | -------------------------------------------------------------------------------- /RedisStudio/Base/Runnable.h: -------------------------------------------------------------------------------- 1 | #ifndef Base_Runnable_INCLUDED 2 | #define Base_Runnable_INCLUDED 3 | 4 | namespace Base { 5 | 6 | class Runnable 7 | { 8 | public: 9 | Runnable(); 10 | virtual ~Runnable(); 11 | 12 | virtual void run() = 0; 13 | /// Do whatever the thread needs to do. Must 14 | /// be overridden by subclasses. 15 | }; 16 | 17 | 18 | } // namespace Base 19 | 20 | 21 | #endif // Base_Runnable_INCLUDED 22 | -------------------------------------------------------------------------------- /RedisStudio/Base/RunnableAdapter.h: -------------------------------------------------------------------------------- 1 | #ifndef Base_RunnableAdapter_INCLUDED 2 | #define Base_RunnableAdapter_INCLUDED 3 | 4 | #include "Base/Runnable.h" 5 | 6 | 7 | namespace Base { 8 | 9 | 10 | template 11 | class RunnableAdapter: public Runnable 12 | /// This adapter simplifies using ordinary methods as 13 | /// targets for threads. 14 | /// Usage: 15 | /// RunnableAdapter ra(myObject, &MyObject::doSomething)); 16 | /// Thread thr; 17 | /// thr.Start(ra); 18 | /// 19 | /// For using a freestanding or static member function as a thread 20 | /// target, please see the ThreadTarget class. 21 | { 22 | public: 23 | typedef void (C::*Callback)(); 24 | 25 | RunnableAdapter(C& object, Callback method): _pObject(&object), _method(method) 26 | { 27 | } 28 | 29 | RunnableAdapter(const RunnableAdapter& ra): _pObject(ra._pObject), _method(ra._method) 30 | { 31 | } 32 | 33 | ~RunnableAdapter() 34 | { 35 | } 36 | 37 | RunnableAdapter& operator = (const RunnableAdapter& ra) 38 | { 39 | _pObject = ra._pObject; 40 | _method = ra._method; 41 | return *this; 42 | } 43 | 44 | void run() 45 | { 46 | (_pObject->*_method)(); 47 | } 48 | 49 | private: 50 | RunnableAdapter(); 51 | 52 | C* _pObject; 53 | Callback _method; 54 | }; 55 | 56 | 57 | } // namespace Base 58 | 59 | 60 | #endif // Base_RunnableAdapter_INCLUDED 61 | -------------------------------------------------------------------------------- /RedisStudio/Base/ScopedLock.h: -------------------------------------------------------------------------------- 1 | #ifndef Base_ScopedLock_INCLUDED 2 | #define Base_ScopedLock_INCLUDED 3 | 4 | namespace Base { 5 | 6 | template 7 | class ScopedLock 8 | { 9 | public: 10 | ScopedLock(M& mutex): _mutex(mutex) 11 | { 12 | _mutex.lock(); 13 | } 14 | 15 | ~ScopedLock() 16 | { 17 | _mutex.unlock(); 18 | } 19 | 20 | private: 21 | M& _mutex; 22 | 23 | ScopedLock(); 24 | ScopedLock(const ScopedLock&); 25 | ScopedLock& operator = (const ScopedLock&); 26 | }; 27 | 28 | } // namespace 29 | 30 | #endif -------------------------------------------------------------------------------- /RedisStudio/Base/String.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "String.h" 3 | 4 | namespace Base { 5 | 6 | bool String::IsSpace( const char& ch ) 7 | { 8 | return ch==' '; 9 | } 10 | 11 | void String::Split(const std::string& str, const std::string& separators, TSeqStr& tokens, int options) 12 | { 13 | std::string::const_iterator it1 = str.begin(); 14 | std::string::const_iterator it2; 15 | std::string::const_iterator it3; 16 | std::string::const_iterator end = str.end(); 17 | 18 | while (it1 != end) 19 | { 20 | if (options & TOK_TRIM) 21 | { 22 | while (it1 != end && IsSpace(*it1)) ++it1; 23 | } 24 | it2 = it1; 25 | while (it2 != end && separators.find(*it2) == std::string::npos) ++it2; 26 | it3 = it2; 27 | if (it3 != it1 && (options & TOK_TRIM)) 28 | { 29 | --it3; 30 | while (it3 != it1 && IsSpace(*it3)) --it3; 31 | if (!IsSpace(*it3)) ++it3; 32 | } 33 | if (options & TOK_IGNORE_EMPTY) 34 | { 35 | if (it3 != it1) 36 | tokens.push_back(std::string(it1, it3)); 37 | } 38 | else 39 | { 40 | tokens.push_back(std::string(it1, it3)); 41 | } 42 | it1 = it2; 43 | if (it1 != end) ++it1; 44 | } 45 | } 46 | 47 | std::string String::Chrtos( char byte) 48 | { 49 | std::string str; 50 | size_t len = 0; 51 | char buf[24] = {0}; 52 | size_t size = 23; 53 | switch(byte) { 54 | case '\\': 55 | case '"': 56 | len = _snprintf(buf,size,"\\%c",byte); 57 | break; 58 | case '\n': len = _snprintf(buf,size,"\\n"); break; 59 | case '\r': len = _snprintf(buf,size,"\\r"); break; 60 | case '\t': len = _snprintf(buf,size,"\\t"); break; 61 | case '\a': len = _snprintf(buf,size,"\\a"); break; 62 | case '\b': len = _snprintf(buf,size,"\\b"); break; 63 | default: 64 | if (byte >= 33 && byte <=93) 65 | len = _snprintf(buf,size,"%c",byte); 66 | else 67 | len = _snprintf(buf,size,"\\x%02x",(unsigned char)byte); 68 | break; 69 | } 70 | str.assign(buf, len); 71 | return str; 72 | } 73 | 74 | } // namespace Base -------------------------------------------------------------------------------- /RedisStudio/Base/String.h: -------------------------------------------------------------------------------- 1 | #ifndef Base_String_INCLUDED 2 | #define Base_String_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | namespace Base { 8 | 9 | class String 10 | { 11 | public: 12 | typedef std::vector TSeqStr; 13 | public: 14 | enum Options 15 | { 16 | TOK_IGNORE_EMPTY = 1, /// ignore empty tokens 17 | TOK_TRIM = 2 /// remove leading and trailing whitespace from tokens 18 | }; 19 | 20 | static bool IsSpace(const char& ch); 21 | 22 | static void Split(const std::string& str, const std::string& separators, TSeqStr& tokens, int options=0); 23 | 24 | static std::string Chrtos(char byte); 25 | }; 26 | 27 | } // namespace Base 28 | 29 | #endif -------------------------------------------------------------------------------- /RedisStudio/Base/Util.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Util.h" 3 | #include 4 | #include 5 | #pragma comment(lib,"Iphlpapi.lib") /// for GetAdaptersInfo 6 | 7 | namespace Base { 8 | 9 | std::string Util::ConvertHumanTimeDuration(long long seconds) 10 | { 11 | std::stringstream sb; 12 | if (seconds == 0) { 13 | return "0 secs"; 14 | } 15 | if (seconds >= 86400) { 16 | sb << seconds / 86400; 17 | sb << " days"; 18 | seconds -= (seconds / 86400) * 86400; 19 | } 20 | if (seconds >= 3600) { 21 | if (sb.str().size() > 0) { 22 | sb << " "; 23 | } 24 | sb << seconds / 3600; 25 | sb << "hrs" ; 26 | seconds -= (seconds / 3600) * 3600; 27 | } 28 | if (seconds >= 60) { 29 | if (sb.str().size() > 0) { 30 | sb << " "; 31 | } 32 | sb << seconds / 60 << "mins"; 33 | seconds -= (seconds / 60) * 60; 34 | } 35 | if (seconds > 0) { 36 | if (sb.str().size() > 0) { 37 | sb << " "; 38 | } 39 | sb << seconds; 40 | sb << "secs"; 41 | } 42 | 43 | return sb.str(); 44 | } 45 | 46 | std::string Util::GetUniqueMachineID() 47 | { 48 | BYTE szSystemInfo[4096] = {0}; 49 | UINT uSystemInfoLen = 0; 50 | UINT uErrorCode = 0; 51 | IP_ADAPTER_INFO iai; 52 | ULONG uSize = 0; 53 | std::string nicID ; 54 | DWORD dwResult = GetAdaptersInfo( &iai, &uSize ); 55 | if( dwResult != ERROR_BUFFER_OVERFLOW ) 56 | { 57 | return nicID; 58 | } 59 | IP_ADAPTER_INFO* piai = ( IP_ADAPTER_INFO* )HeapAlloc( GetProcessHeap(), 0, uSize ); 60 | if( piai == NULL ) 61 | { 62 | return nicID; 63 | } 64 | dwResult = GetAdaptersInfo( piai, &uSize ); 65 | if(ERROR_SUCCESS == dwResult) 66 | { 67 | IP_ADAPTER_INFO* piai2 = piai; 68 | while( piai2 != NULL && ( uSystemInfoLen + piai2->AddressLength ) < 4096U ) 69 | { 70 | CopyMemory( szSystemInfo + uSystemInfoLen, piai2->Address, piai2->AddressLength ); 71 | uSystemInfoLen += piai2->AddressLength; 72 | piai2 = piai2->Next; 73 | } 74 | } 75 | HeapFree( GetProcessHeap(), 0, piai); 76 | char buf[124] = {0}; 77 | for (UINT idx = 0; idx < uSystemInfoLen; ++idx) 78 | { 79 | memset(buf, 0 , sizeof(buf)); 80 | sprintf(buf, "%02X",szSystemInfo[idx]); 81 | nicID += buf; 82 | } 83 | return nicID; 84 | } 85 | 86 | } // namespace Base 87 | -------------------------------------------------------------------------------- /RedisStudio/Base/Util.h: -------------------------------------------------------------------------------- 1 | #ifndef Base_Util_INCLUDED 2 | #define Base_Util_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | namespace Base { 8 | 9 | class Util { 10 | 11 | public: 12 | static std::string ConvertHumanTimeDuration(long long seconds); 13 | 14 | static std::string GetUniqueMachineID(); 15 | }; 16 | 17 | } // namespace Base 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /RedisStudio/ConnInfoSubWhd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class ConnInfoSubWhd : public WindowImplBase 7 | { 8 | private: 9 | typedef std::vector TSeqColumn; 10 | typedef std::map TDicTables; 11 | 12 | public: 13 | enum OperatorType 14 | { 15 | Type_Add, 16 | Type_Alt 17 | }; 18 | public: 19 | ConnInfoSubWhd(TDicTables* pDic, bool &needApply, OperatorType type, int celIdx=0); 20 | 21 | ~ConnInfoSubWhd(void); 22 | 23 | void InitWindow(); 24 | 25 | LPCTSTR GetWindowClassName() const; 26 | 27 | UINT GetClassStyle() const;; 28 | 29 | void OnFinalMessage(HWND hWnd);; 30 | 31 | virtual CDuiString GetSkinFolder(); 32 | 33 | virtual CDuiString GetSkinFile(); 34 | 35 | virtual UILIB_RESOURCETYPE GetResourceType() const; 36 | 37 | virtual LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 38 | 39 | DUI_DECLARE_MESSAGE_MAP() 40 | 41 | virtual void OnClick(TNotifyUI& msg); 42 | 43 | bool OnAddInfo(); 44 | 45 | bool OnAltInfo(); 46 | 47 | private: 48 | bool* m_bNeedApply; 49 | TDicTables* m_pdicServerInfo; 50 | 51 | CEditUI* m_pEditName; 52 | CEditUI* m_pEditHost; 53 | CEditUI* m_pEditPort; 54 | CEditUI* m_pEditAuth; 55 | int m_iCelIdx; 56 | OperatorType m_eType; 57 | }; 58 | -------------------------------------------------------------------------------- /RedisStudio/ConnInfoUI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "stdafx.h" 4 | #include 5 | #include 6 | #include 7 | #include "AbstractUI.h" 8 | #include "hiredis/hiredis.h" 9 | #include "Base/Event.h" 10 | #include "Base/Thread.h" 11 | #include "Base/RunnableAdapter.h" 12 | 13 | class ConnInfoUI : public AbstraceUI,public IListCallbackUI 14 | { 15 | public: 16 | ConnInfoUI(const CDuiString& strXML, CPaintManagerUI* pm, Environment* env); 17 | 18 | ~ConnInfoUI(); 19 | 20 | void Initialize(); 21 | 22 | int GetIndex(); 23 | 24 | CDuiString GetVirtualwndName(); 25 | 26 | void RefreshWnd(); 27 | 28 | bool LoadConfig(const std::string& path); 29 | 30 | bool SaveConfig(const std::string& path); 31 | 32 | LPCTSTR GetItemText(CControlUI* pControl, int iIndex, int iSubItem); 33 | 34 | DUI_DECLARE_MESSAGE_MAP() 35 | 36 | virtual void OnClick(TNotifyUI& msg); 37 | 38 | virtual void OnSelectChanged( TNotifyUI &msg ); 39 | 40 | virtual void OnItemClick( TNotifyUI &msg ); 41 | 42 | virtual void OnItemActive( TNotifyUI &msg ); 43 | 44 | void OnAddConnInfo(TNotifyUI& msg); 45 | 46 | void OnDelConnInfo(TNotifyUI& msg); 47 | 48 | void OnAltConnInfo(TNotifyUI& msg); 49 | 50 | void OnRfhConnInfo(TNotifyUI& msg); 51 | 52 | void DoConnect(); 53 | 54 | private: 55 | typedef std::vector TSeqColumn; 56 | typedef std::map TDicTables; 57 | TDicTables m_dicServerInfo; 58 | 59 | CListUI* m_pListUI; 60 | 61 | Base::Thread m_Thread; 62 | Base::Event m_Event; 63 | std::auto_ptr< Base::RunnableAdapter > m_pWork; 64 | 65 | public: 66 | void BackgroundWork(void); 67 | 68 | public: 69 | static const int kServerNameIndex = 0; 70 | static const int kServerIpIndex = 1; 71 | static const int kServerPortIndex = 2; 72 | static const int kServerAuthIndex = 3; 73 | 74 | private: 75 | CButtonUI* m_pAddBtn; 76 | CButtonUI* m_pDelBtn; 77 | CButtonUI* m_pAltBtn; 78 | CButtonUI* m_pRfhBtn; 79 | }; 80 | -------------------------------------------------------------------------------- /RedisStudio/DBClient.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "DBClient.h" 3 | 4 | #include "Redis/RedisClient.h" 5 | #include "SSDB/SSDBClient.h" 6 | 7 | DBClient* DBClient::Create(const std::string& ip, int port, const std::string& auth) 8 | { 9 | std::string info; 10 | DBClient* dbcli = new RedisClient(); 11 | dbcli->Connect(ip, port, auth); 12 | if (!dbcli->IsConnected()) { 13 | delete dbcli; 14 | return NULL; 15 | } 16 | if (!dbcli->Info(info)) { 17 | delete dbcli; 18 | return NULL; 19 | } 20 | dbcli->SetDBType("redis"); 21 | if (info.empty()) { 22 | delete dbcli; 23 | dbcli = new SSDBClient(); 24 | if (!dbcli->Connect(ip, port, auth)) 25 | { 26 | delete dbcli; 27 | dbcli = NULL; 28 | } 29 | dbcli->SetDBType("ssdb"); 30 | } 31 | return dbcli; 32 | } 33 | 34 | 35 | void DBClient::SetDBType(const std::string& dbtype) 36 | { 37 | m_DBType = dbtype; 38 | } 39 | 40 | std::string DBClient::DBType() 41 | { 42 | return m_DBType; 43 | } 44 | 45 | bool DBClient::DatabasesNum(int& num) 46 | { 47 | num = 1; 48 | return true; 49 | } 50 | 51 | int DBClient::DatabasesNum() 52 | { 53 | return 1; 54 | } 55 | 56 | bool DBClient::SelectDB(int dbindex) 57 | { 58 | return false; 59 | } 60 | 61 | bool DBClient::GetConfig(TDicConfig& dicConfig) 62 | { 63 | return false; 64 | } 65 | 66 | bool DBClient::SetConfig(const TDicConfig& dicConfig) 67 | { 68 | return false; 69 | } 70 | 71 | bool DBClient::ReWriteConfig() 72 | { 73 | return false; 74 | } 75 | 76 | void DBClient::SetLastError(const std::string& err) 77 | { 78 | m_Error = err; 79 | } 80 | 81 | std::string DBClient::GetLastError() 82 | { 83 | return m_Error; 84 | } 85 | -------------------------------------------------------------------------------- /RedisStudio/DBClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class RedisResult; 8 | 9 | class DBClient { 10 | public: 11 | typedef std::list TSeqArrayResults; 12 | typedef std::map TDicConfig; 13 | public: 14 | virtual ~DBClient() {}; 15 | 16 | static DBClient* Create(const std::string& ip, int port, const std::string& auth); 17 | 18 | void SetDBType(const std::string& dbtype); 19 | 20 | std::string DBType(); 21 | 22 | virtual bool Connect(const std::string& ip, int port, const std::string& auth) = 0; 23 | 24 | virtual bool Ping() = 0; 25 | 26 | virtual bool IsConnected() = 0; 27 | 28 | virtual void Quit() = 0; 29 | 30 | virtual bool Info(std::string& results) = 0; 31 | 32 | virtual bool keys(const std::string &, TSeqArrayResults& results) = 0; 33 | 34 | virtual bool Exists(const std::string& key) = 0; 35 | 36 | virtual bool Type(const std::string& key, string& type) = 0; 37 | 38 | virtual long long TTL(const std::string& key) = 0; 39 | 40 | virtual bool DatabasesNum(int& num); 41 | 42 | virtual int DatabasesNum(); 43 | 44 | virtual bool SelectDB(int dbindex); 45 | 46 | virtual long long DbSize() = 0; 47 | 48 | virtual bool GetConfig(TDicConfig& dicConfig); 49 | 50 | virtual bool SetConfig(const TDicConfig& dicConfig); 51 | 52 | virtual bool ReWriteConfig(); 53 | 54 | virtual bool GetData(const std::string& key, std::string& type, RedisResult& results) = 0; 55 | 56 | virtual bool UpdateData(const std::string& key, 57 | const std::string& oldValue, 58 | const std::string& newValue, 59 | int idx, 60 | const std::string& field="") = 0; 61 | 62 | virtual bool DelKey(const std::string& key) = 0; 63 | 64 | void SetLastError(const std::string& err); 65 | 66 | std::string GetLastError(); 67 | protected: 68 | std::string m_IP; 69 | int m_Port; 70 | std::string m_Auth; 71 | private: 72 | std::string m_Error; 73 | std::string m_DBType; 74 | }; 75 | -------------------------------------------------------------------------------- /RedisStudio/Environment.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Environment.h" 3 | #include "DBClient.h" 4 | 5 | Environment::Environment():m_DbClient(NULL),m_ConnIdx(0) 6 | { 7 | } 8 | 9 | Environment::~Environment() 10 | { 11 | if (m_DbClient) delete m_DbClient; 12 | } 13 | 14 | void Environment::SetDBClient(DBClient* cli) 15 | { 16 | Base::Mutex::ScopedLock scopedLock(m_Mutex); 17 | m_DbClient = cli; 18 | m_ConnIdx++; 19 | } 20 | 21 | DBClient* Environment::GetDBClient() 22 | { 23 | Base::Mutex::ScopedLock scopedLock(m_Mutex); 24 | return m_DbClient; 25 | } 26 | 27 | int Environment::GetDBIdx() 28 | { 29 | Base::Mutex::ScopedLock scopedLock(m_Mutex); 30 | return m_ConnIdx; 31 | } 32 | 33 | void Environment::SetDBName(const CDuiString& name) 34 | { 35 | Base::Mutex::ScopedLock scopedLock(m_Mutex); 36 | m_DbName = name; 37 | } 38 | 39 | DuiLib::CDuiString Environment::GetDBName() 40 | { 41 | Base::Mutex::ScopedLock scopedLock(m_Mutex); 42 | return m_DbName; 43 | } 44 | 45 | void Environment::SetDBServerInfo(const std::string& addr, int port, const std::string& auth/*=""*/) 46 | { 47 | Base::Mutex::ScopedLock scopedLock(m_Mutex); 48 | m_IP = addr; 49 | m_Port = port; 50 | m_Auth = auth; 51 | } 52 | 53 | std::string Environment::GetDBIP() 54 | { 55 | Base::Mutex::ScopedLock scopedLock(m_Mutex); 56 | return m_IP; 57 | } 58 | 59 | int Environment::GetDBPort() 60 | { 61 | Base::Mutex::ScopedLock scopedLock(m_Mutex); 62 | return m_Port; 63 | } 64 | 65 | std::string Environment::GetDBPasswd() 66 | { 67 | Base::Mutex::ScopedLock scopedLock(m_Mutex); 68 | return m_Auth; 69 | } 70 | -------------------------------------------------------------------------------- /RedisStudio/Environment.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Base/Mutex.h" 4 | 5 | class DBClient; 6 | 7 | class Environment { 8 | public: 9 | Environment(); 10 | 11 | ~Environment(); 12 | 13 | void SetDBClient(DBClient* cli); 14 | 15 | void SetDBServerInfo(const std::string& addr, int port, const std::string& auth=""); 16 | 17 | void SetDBName(const CDuiString& name); 18 | 19 | DBClient* GetDBClient(); 20 | 21 | int GetDBIdx(); 22 | 23 | CDuiString GetDBName(); 24 | 25 | std::string GetDBIP(); 26 | 27 | int GetDBPort(); 28 | 29 | std::string GetDBPasswd(); 30 | 31 | private: 32 | CDuiString m_DbName; 33 | std::string m_IP; 34 | int m_Port; 35 | std::string m_Auth; 36 | DBClient* m_DbClient; 37 | Base::Mutex m_Mutex; 38 | int m_ConnIdx; 39 | }; 40 | -------------------------------------------------------------------------------- /RedisStudio/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include 3 | #include "MainFrameWhd.h" 4 | #include "win32fix/winfix.h" 5 | 6 | 7 | void win32Cleanup(void) { 8 | /* Clear winsocks */ 9 | WSACleanup(); 10 | } 11 | 12 | int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow) 13 | { 14 | #if 0 15 | /* avoid UAC */ 16 | TCHAR szFileName[_MAX_PATH] = {0}; 17 | 18 | GetModuleFileName(NULL, szFileName, _MAX_PATH); 19 | for (int i = sizeof(szFileName)-1; i>=0; i--) 20 | { 21 | if (szFileName[i]=='\\') 22 | { 23 | szFileName[i] = 0; 24 | SetCurrentDirectory(szFileName); 25 | break; 26 | } 27 | } 28 | #endif 29 | 30 | if (!w32initWinSock()) { 31 | printf("Winsock init error %d", WSAGetLastError()); 32 | exit(1); 33 | }; 34 | 35 | atexit((void(*)(void)) win32Cleanup); 36 | 37 | CPaintManagerUI::SetInstance(hInstance); 38 | 39 | HRESULT Hr = ::CoInitialize(NULL); 40 | if ( FAILED(Hr) ) return 0; 41 | 42 | CMainFrameWnd* pFrame = new CMainFrameWnd(); 43 | 44 | if ( pFrame == NULL ) return 0; 45 | pFrame->Create(NULL, _T("Redis Studio"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 800, 572); 46 | pFrame->CenterWindow(); 47 | ::ShowWindow(*pFrame, SW_SHOW); 48 | 49 | CPaintManagerUI::MessageLoop(); 50 | 51 | ::CoUninitialize(); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /RedisStudio/MainFrameWhd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "stdafx.h" 4 | #include 5 | #include 6 | 7 | #include "Environment.h" 8 | 9 | class ConnInfoUI; 10 | class RedisInfoUI; 11 | 12 | class CMainFrameWnd : public WindowImplBase 13 | { 14 | public: 15 | CMainFrameWnd(); 16 | 17 | ~CMainFrameWnd(); 18 | 19 | LPCTSTR GetWindowClassName() const; 20 | 21 | UINT GetClassStyle() const; 22 | 23 | void OnFinalMessage(HWND hWnd); 24 | 25 | virtual CDuiString GetSkinFolder(); 26 | 27 | virtual CDuiString GetSkinFile(); 28 | 29 | virtual UILIB_RESOURCETYPE GetResourceType() const; 30 | 31 | virtual LPCTSTR GetResourceID() const;; 32 | 33 | void InitWindow() ; 34 | 35 | CControlUI* CreateControl(LPCTSTR pstrClassName); 36 | 37 | void Notify(TNotifyUI& msg); 38 | 39 | virtual LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 40 | 41 | DUI_DECLARE_MESSAGE_MAP() 42 | 43 | virtual void OnClick(TNotifyUI& msg); 44 | 45 | virtual void OnSelectChanged( TNotifyUI &msg ); 46 | 47 | virtual void OnItemClick( TNotifyUI &msg ); 48 | 49 | LRESULT OnConnected(HWND hwnd, WPARAM wParam, LPARAM lParam); 50 | 51 | LRESULT OnUnConnected(HWND hwnd, WPARAM wParam, LPARAM lParam); 52 | 53 | LRESULT OnConnecting(HWND hwnd, WPARAM wParam, LPARAM lParam); 54 | 55 | LRESULT OnUpdate(HWND hwnd, WPARAM wParam, LPARAM lParam); 56 | 57 | public: 58 | void DoConnectEvent(void* data); 59 | 60 | void DoUnConnectEvent(void* data); 61 | 62 | public: 63 | static DWORD WINAPI BackgroundWork(LPVOID lpParameter); 64 | static HWND m_hwnd; 65 | static void OndisConnectCallback(const CDuiString& name); 66 | 67 | private: 68 | CButtonUI* m_pCloseBtn; 69 | CButtonUI* m_pMaxBtn; 70 | CButtonUI* m_pRestoreBtn; 71 | CButtonUI* m_pMinBtn; 72 | 73 | CHorizontalLayoutUI* m_pLayConnect; 74 | CHorizontalLayoutUI* m_pLayConnecting; 75 | CHorizontalLayoutUI* m_pLayUnconect; 76 | CTextUI* m_pConnectControl ; 77 | CTextUI* m_pUnConnectControl ; 78 | CTextUI* m_pConnectingControl ; 79 | CTextUI* m_pVersionControl; 80 | 81 | CStdStringPtrMap m_oTabContainer; 82 | Environment m_pEnv; 83 | }; 84 | -------------------------------------------------------------------------------- /RedisStudio/MessageBoxWhd.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "MessageBoxWhd.h" 3 | #include 4 | #include "Base/CharacterSet.h" 5 | 6 | DUI_BEGIN_MESSAGE_MAP(MessageBoxWhd, WindowImplBase) 7 | DUI_ON_MSGTYPE(DUI_MSGTYPE_CLICK,OnClick) 8 | DUI_END_MESSAGE_MAP() 9 | 10 | MessageBoxWhd::MessageBoxWhd(MsgType type, UINT code, CDuiString msg) 11 | { 12 | m_uType = type; 13 | m_uMsgCode = code; 14 | m_dstrExMsg = msg; 15 | } 16 | 17 | MessageBoxWhd::~MessageBoxWhd(void) 18 | { 19 | } 20 | 21 | void MessageBoxWhd::InitWindow() 22 | { 23 | CLabelUI* pLbl = NULL; 24 | CControlUI* pCtl = NULL; 25 | if (m_uType == Info) 26 | { 27 | pLbl = static_cast (m_PaintManager.FindControl(_T("lab_msg_info"))); 28 | pCtl = static_cast (m_PaintManager.FindControl(_T("ctl_msg_info"))); 29 | } 30 | else if (m_uType == Warn) 31 | { 32 | pLbl = static_cast (m_PaintManager.FindControl(_T("lab_msg_warn"))); 33 | pCtl = static_cast (m_PaintManager.FindControl(_T("ctl_msg_warn"))); 34 | } 35 | else if (m_uType == Error) 36 | { 37 | pLbl = static_cast (m_PaintManager.FindControl(_T("lab_msg_error"))); 38 | pCtl = static_cast (m_PaintManager.FindControl(_T("ctl_msg_error"))); 39 | } 40 | pLbl->SetVisible(true); 41 | pCtl->SetVisible(true); 42 | 43 | std::stringstream ss; 44 | ss<<"lbl_msg_"< (m_PaintManager.FindControl(Base::CharacterSet::ANSIToUnicode(ss.str()).c_str())); 46 | if (pTextUI) 47 | { 48 | pTextUI->SetVisible(true); 49 | if (!m_dstrExMsg.IsEmpty()) 50 | { 51 | CDuiString theMsg = pTextUI->GetText(); 52 | theMsg.Replace(_T("$"), m_dstrExMsg); 53 | pTextUI->SetText(theMsg); 54 | } 55 | } 56 | } 57 | 58 | LPCTSTR MessageBoxWhd::GetWindowClassName() const 59 | { 60 | return _T("MessageBoxWhd"); 61 | } 62 | 63 | UINT MessageBoxWhd::GetClassStyle() const 64 | { 65 | return UI_CLASSSTYLE_DIALOG; 66 | } 67 | 68 | 69 | void MessageBoxWhd::OnFinalMessage( HWND hWnd) 70 | { 71 | delete this; 72 | } 73 | 74 | DuiLib::CDuiString MessageBoxWhd::GetSkinFolder() 75 | { 76 | return _T("skin\\"); 77 | } 78 | 79 | DuiLib::CDuiString MessageBoxWhd::GetSkinFile() 80 | { 81 | return _T("MessageBox.xml"); 82 | } 83 | 84 | DuiLib::UILIB_RESOURCETYPE MessageBoxWhd::GetResourceType() const 85 | { 86 | return UILIB_FILE; 87 | } 88 | 89 | void MessageBoxWhd::OnClick( TNotifyUI& msg ) 90 | { 91 | if (msg.pSender->GetName() == _T("btn_msg_ok")) 92 | { 93 | Close(); 94 | } 95 | if (msg.pSender->GetName() == _T("closebtn")) 96 | { 97 | Close(); 98 | } 99 | } -------------------------------------------------------------------------------- /RedisStudio/MessageBoxWhd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class MessageBoxWhd : public WindowImplBase 4 | { 5 | public: 6 | enum MsgType 7 | { 8 | Info, 9 | Warn, 10 | Error 11 | }; 12 | 13 | public: 14 | MessageBoxWhd(MsgType type, UINT code, CDuiString msg); 15 | 16 | ~MessageBoxWhd(void); 17 | 18 | void InitWindow(); 19 | 20 | LPCTSTR GetWindowClassName() const; 21 | 22 | UINT GetClassStyle() const; 23 | 24 | void OnFinalMessage(HWND hWnd);; 25 | 26 | virtual CDuiString GetSkinFolder(); 27 | 28 | virtual CDuiString GetSkinFile(); 29 | 30 | virtual UILIB_RESOURCETYPE GetResourceType() const; 31 | 32 | DUI_DECLARE_MESSAGE_MAP() 33 | 34 | virtual void OnClick(TNotifyUI& msg); 35 | 36 | private: 37 | MsgType m_uType; 38 | CDuiString m_dstrExMsg; 39 | UINT m_uMsgCode; 40 | }; 41 | -------------------------------------------------------------------------------- /RedisStudio/Redis/AbstractRedisModel.h: -------------------------------------------------------------------------------- 1 | #ifndef AbstractRedisModel_INCLUDED 2 | #define AbstractRedisModel_INCLUDED 3 | 4 | #include "RedisResult.h" 5 | #include "RedisClient.h" 6 | 7 | class AbstractRedisModel 8 | { 9 | public: 10 | AbstractRedisModel(RedisClient* client) : m_pClient(client) {} 11 | 12 | virtual ~AbstractRedisModel() {} 13 | 14 | virtual bool GetData(const std::string& key, RedisResult& results) = 0; 15 | 16 | virtual bool UpdateData(const std::string& key, 17 | const std::string& oldValue, 18 | const std::string& newValue, 19 | int idx = 0, 20 | const std::string& field="") = 0; 21 | 22 | RedisClient* GetClient() 23 | { 24 | return m_pClient; 25 | } 26 | 27 | private: 28 | RedisClient* m_pClient; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisClient.h: -------------------------------------------------------------------------------- 1 | #ifndef RedisClient_INCLUDED 2 | #define RedisClient_INCLUDED 3 | 4 | #include "hiredis/hiredis.h" 5 | #include 6 | #include 7 | #include 8 | #include "../Base/Mutex.h" 9 | #include "ScopedRedisReply.h" 10 | #include "RedisModelFactory.h" 11 | #include "../DBClient.h" 12 | 13 | class RedisResult; 14 | 15 | class RedisClient : public DBClient 16 | { 17 | public: 18 | RedisClient(); 19 | 20 | ~RedisClient(); 21 | 22 | bool Connect(const std::string& ip, int port, const std::string& auth); 23 | 24 | bool Ping(); 25 | 26 | bool IsConnected(); 27 | 28 | void Quit(); 29 | 30 | bool Info(std::string& results); 31 | 32 | bool keys(const std::string &, TSeqArrayResults& results); 33 | 34 | bool Exists(const std::string& key); 35 | 36 | bool Type(const std::string& key, string& type); 37 | 38 | long long TTL(const std::string& key); 39 | 40 | bool DatabasesNum(int& num); 41 | 42 | int DatabasesNum(); 43 | 44 | bool SelectDB(int dbindex); 45 | 46 | long long DbSize(); 47 | 48 | bool GetConfig(TDicConfig& dicConfig); 49 | 50 | bool SetConfig(const TDicConfig& dicConfig); 51 | 52 | bool ReWriteConfig(); 53 | 54 | bool GetData(const std::string& key, std::string& type, RedisResult& results); 55 | 56 | bool UpdateData(const std::string& key, 57 | const std::string& oldValue, 58 | const std::string& newValue, 59 | int idx, 60 | const std::string& field=""); 61 | 62 | bool DelKey(const std::string& key); 63 | 64 | redisReply* Command(const char* fmt, ...); 65 | 66 | private: 67 | redisContext* m_pClient; 68 | bool m_bReConnect; 69 | int m_iDatabases; 70 | bool m_bConnected; 71 | Base::Mutex m_oMutex; 72 | std::auto_ptr m_pModelFactory; 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisHashModel.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "RedisHashModel.h" 3 | 4 | RedisHashModel::RedisHashModel( RedisClient* client ) : AbstractRedisModel(client) 5 | { 6 | 7 | } 8 | 9 | bool RedisHashModel::GetData( const std::string& key, RedisResult& results ) 10 | { 11 | bool retVal = false; 12 | redisReply* reply = GetClient()->Command("HKEYS %s", key.c_str()); 13 | if (!reply) return retVal; 14 | results.NewColumn("Field "); 15 | results.NewColumn("Value"); 16 | if (reply->type == REDIS_REPLY_ARRAY) 17 | { 18 | std::size_t i = 0; 19 | redisReply* tmpReply ; 20 | bool isOK = true; 21 | while (i < reply->elements) 22 | { 23 | tmpReply = reply->element[i]; 24 | redisReply* theReply = GetClient()->Command("HGET %s %s", key.c_str(), tmpReply->str); 25 | if (!theReply) break; 26 | if (theReply->type != REDIS_REPLY_STRING) 27 | { 28 | isOK = false; 29 | freeReplyObject(theReply); 30 | break; 31 | } 32 | results.NewRow(); 33 | 34 | string& myFiled = results.Value(results.RowSize()-1, 0) ; 35 | myFiled.assign(tmpReply->str, tmpReply->len); 36 | 37 | string& myvalue = results.Value(results.RowSize()-1, 1) ; 38 | myvalue.assign(theReply->str, theReply->len); 39 | freeReplyObject(theReply); 40 | i++; 41 | } 42 | if (isOK) 43 | retVal = true; 44 | } 45 | freeReplyObject(reply); 46 | return retVal; 47 | } 48 | 49 | bool RedisHashModel::UpdateData( const std::string& key, 50 | const std::string& oldValue, 51 | const std::string& newValue, 52 | int idx, 53 | const std::string& field) 54 | { 55 | /// 如果哈希表中域 field 已经存在且旧值已被新值覆盖,返回 0 。 56 | ScopedRedisReply reply(GetClient()->Command("HSET %s %s %s", key.c_str(), field.c_str(), newValue.c_str())); 57 | if(reply.IsNull() || reply->type != REDIS_REPLY_INTEGER || reply->integer!=0) 58 | return false; 59 | return true; 60 | } 61 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisHashModel.h: -------------------------------------------------------------------------------- 1 | #ifndef RedisHashModel_INCLUDED 2 | #define RedisHashModel_INCLUDED 3 | 4 | #include "AbstractRedisModel.h" 5 | 6 | class RedisHashModel : public AbstractRedisModel 7 | { 8 | public: 9 | RedisHashModel(RedisClient* client); 10 | 11 | virtual bool GetData(const std::string& key, RedisResult& results); 12 | 13 | virtual bool UpdateData(const std::string& key, 14 | const std::string& oldValue, 15 | const std::string& newValue, 16 | int idx, 17 | const std::string& field=""); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisListModel.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "RedisListModel.h" 3 | 4 | RedisListModel::RedisListModel( RedisClient* client ) : AbstractRedisModel(client) 5 | { 6 | 7 | } 8 | 9 | bool RedisListModel::GetData( const std::string& key, RedisResult& results ) 10 | { 11 | bool retVal = false; 12 | ScopedRedisReply lenreply = GetClient()->Command("LLEN %s", key.c_str()); 13 | if (lenreply.IsNull()) 14 | { 15 | return false; 16 | } 17 | if (lenreply->type == REDIS_REPLY_INTEGER) 18 | { 19 | long long llen = lenreply->integer; 20 | results.NewColumn("Value"); 21 | for (int idx=0; idxCommand("LRANGE %s %d %d", key.c_str(), idx, idx+1000 > llen ? idx+1000 : llen - idx); 24 | if (!reply) return retVal; 25 | 26 | if (reply->type == REDIS_REPLY_ARRAY) 27 | { 28 | std::size_t i = 0; 29 | redisReply* tmpReply ; 30 | while (i < reply->elements) 31 | { 32 | tmpReply = reply->element[i]; 33 | results.NewRow(); 34 | string& myvalue = results.Value(results.RowSize()-1, 0); 35 | myvalue.assign(tmpReply->str, tmpReply->len); 36 | i++; 37 | } 38 | retVal = true; 39 | } 40 | freeReplyObject(reply); 41 | idx+=1000; 42 | } 43 | } 44 | 45 | return retVal; 46 | } 47 | 48 | bool RedisListModel::UpdateData( const std::string& key, 49 | const std::string& oldValue, 50 | const std::string& newValue, 51 | int idx, 52 | const std::string& field) 53 | { 54 | ScopedRedisReply reply(GetClient()->Command("LSET %s %d %s", key.c_str(), idx, newValue.c_str())); 55 | 56 | if (reply.IsNull() || reply->type != REDIS_REPLY_STATUS) return false; 57 | return true; 58 | } 59 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisListModel.h: -------------------------------------------------------------------------------- 1 | #ifndef RedisListModel_INCLUDED 2 | #define RedisListModel_INCLUDED 3 | 4 | #include "AbstractRedisModel.h" 5 | 6 | class RedisListModel : public AbstractRedisModel 7 | { 8 | public: 9 | RedisListModel(RedisClient* client); 10 | 11 | virtual bool GetData(const std::string& key, RedisResult& results); 12 | 13 | virtual bool UpdateData(const std::string& key, 14 | const std::string& oldValue, 15 | const std::string& newValue, 16 | int idx, 17 | const std::string& field=""); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisModelFactory.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "RedisModelFactory.h" 3 | #include "AbstractRedisModel.h" 4 | #include "RedisStringModel.h" 5 | #include "RedisListModel.h" 6 | #include "RedisSetModel.h" 7 | #include "RedisZSetModel.h" 8 | #include "RedisHashModel.h" 9 | 10 | RedisModelFactory::RedisModelFactory(RedisClient* client) 11 | { 12 | Register("string", new RedisStringModel(client)); 13 | Register("list", new RedisListModel(client)); 14 | Register("set", new RedisSetModel(client)); 15 | Register("zset", new RedisZSetModel(client)); 16 | Register("hash", new RedisHashModel(client)); 17 | } 18 | 19 | RedisModelFactory::~RedisModelFactory() 20 | { 21 | TDicModels::iterator it = m_oModels.begin(); 22 | for (; it!=m_oModels.end(); ++it) 23 | { 24 | delete it->second; 25 | } 26 | } 27 | 28 | void RedisModelFactory::Register( const std::string& type, AbstractRedisModel* p ) 29 | { 30 | if (m_oModels.find(type) != m_oModels.end()) 31 | { 32 | UnregisterModel(type); 33 | } 34 | m_oModels.insert(std::make_pair(type, p)); 35 | } 36 | 37 | void RedisModelFactory::UnregisterModel( const std::string& type ) 38 | { 39 | TDicModels::iterator it = m_oModels.find(type); 40 | if (it != m_oModels.end()) 41 | { 42 | delete it->second; 43 | m_oModels.erase(it); 44 | } 45 | } 46 | 47 | AbstractRedisModel* RedisModelFactory::GetRedisModel( const std::string& type ) 48 | { 49 | if (m_oModels.find(type) != m_oModels.end()) 50 | { 51 | return m_oModels[type]; 52 | } 53 | return NULL; 54 | } 55 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisModelFactory.h: -------------------------------------------------------------------------------- 1 | #ifndef RedisModelFactory_INCLUDED 2 | #define RedisModelFactory_INCLUDED 3 | #include 4 | 5 | class RedisClient; 6 | class AbstractRedisModel; 7 | 8 | class RedisModelFactory 9 | { 10 | public: 11 | RedisModelFactory(RedisClient* client); 12 | 13 | ~RedisModelFactory(); 14 | 15 | void Register(const std::string& type, AbstractRedisModel* p); 16 | 17 | void UnregisterModel(const std::string& type); 18 | 19 | AbstractRedisModel* GetRedisModel(const std::string& type); 20 | private: 21 | typedef std::map TDicModels; 22 | TDicModels m_oModels; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisResult.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "RedisResult.h" 3 | 4 | 5 | RedisResult::RedisResult(void) 6 | { 7 | } 8 | 9 | RedisResult::~RedisResult(void) 10 | { 11 | } 12 | 13 | 14 | void RedisResult::Clear() 15 | { 16 | m_ResultTable.clear(); 17 | m_ResultName.clear(); 18 | } 19 | 20 | void RedisResult::NewColumn( const string& name ) 21 | { 22 | m_ResultName.push_back(name); 23 | if (ColumnSize() > 0) 24 | { 25 | m_ResultTable.resize(ColumnSize()); 26 | m_ResultTable[ColumnSize()-1].resize(RowSize()); 27 | } 28 | else 29 | { 30 | m_ResultTable.resize(ColumnSize()); 31 | } 32 | } 33 | 34 | void RedisResult::NewRow() 35 | { 36 | TSeqResultTable::iterator it = m_ResultTable.begin(); 37 | TSeqResultTable::iterator itend = m_ResultTable.end(); 38 | 39 | for (; it!=itend; ++it) 40 | { 41 | it->push_back(NullString); 42 | } 43 | } 44 | 45 | std::size_t RedisResult::ColumnSize() 46 | { 47 | return m_ResultName.size(); 48 | } 49 | 50 | std::size_t RedisResult::RowSize() 51 | { 52 | if (!m_ResultName.empty()) 53 | return m_ResultTable[0].size(); 54 | 55 | return 0; 56 | } 57 | 58 | const std::string& RedisResult::ColumnName( std::size_t idx ) 59 | { 60 | if (idx < m_ResultName.size()) 61 | { 62 | return m_ResultName[idx]; 63 | } 64 | return NullString; 65 | } 66 | 67 | std::string& RedisResult::Value( std::size_t rowidx, std::size_t colidx ) 68 | { 69 | return m_ResultTable[colidx][rowidx]; 70 | } 71 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisResult.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | 7 | class RedisResult 8 | { 9 | public: 10 | const string NullString; 11 | typedef std::vector TSeqResultName; 12 | typedef std::vector TSeqResultColumn; 13 | typedef std::vector< TSeqResultColumn > TSeqResultTable; 14 | 15 | public: 16 | RedisResult(void); 17 | 18 | ~RedisResult(void); 19 | 20 | void Clear(); 21 | 22 | void NewColumn(const string& name); 23 | 24 | void NewRow(); 25 | 26 | std::size_t ColumnSize(); 27 | 28 | std::size_t RowSize(); 29 | 30 | const std::string& ColumnName(std::size_t idx); 31 | 32 | std::string& Value(std::size_t rowidx, std::size_t colidx); 33 | 34 | private: 35 | TSeqResultName m_ResultName; 36 | TSeqResultTable m_ResultTable; 37 | }; 38 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisSetModel.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "RedisSetModel.h" 3 | 4 | RedisSetModel::RedisSetModel( RedisClient* client ) : AbstractRedisModel(client) 5 | { 6 | 7 | } 8 | 9 | bool RedisSetModel::GetData( const std::string& key, RedisResult& results ) 10 | { 11 | bool retVal = false; 12 | redisReply* reply = GetClient()->Command("SMEMBERS %s", key.c_str()); 13 | if (!reply) return retVal; 14 | results.NewColumn("Value"); 15 | if (reply->type == REDIS_REPLY_ARRAY) 16 | { 17 | std::size_t i = 0; 18 | redisReply* tmpReply ; 19 | while (i < reply->elements) 20 | { 21 | tmpReply = reply->element[i]; 22 | results.NewRow(); 23 | string& myvalue = results.Value(results.RowSize()-1, 0); 24 | myvalue.assign(tmpReply->str, tmpReply->len); 25 | i++; 26 | } 27 | retVal = true; 28 | 29 | } 30 | freeReplyObject(reply); 31 | return retVal; 32 | } 33 | 34 | bool RedisSetModel::UpdateData( const std::string& key, 35 | const std::string& oldValue, 36 | const std::string& newValue, 37 | int idx, 38 | const std::string& field ) 39 | { 40 | ScopedRedisReply reply(GetClient()->Command("SREM %s %s", key.c_str(), oldValue.c_str())); 41 | if(reply.IsNull() || reply->type != REDIS_REPLY_INTEGER || reply->integer==0) 42 | return false; 43 | 44 | ScopedRedisReply addReply(GetClient()->Command("SADD %s %s", key.c_str(), newValue.c_str())); 45 | if (addReply.IsNull() || addReply->type != REDIS_REPLY_INTEGER || reply->integer==0) 46 | return false; 47 | return true; 48 | } 49 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisSetModel.h: -------------------------------------------------------------------------------- 1 | #ifndef RedisSetModel_INCLUDED 2 | #define RedisSetModel_INCLUDED 3 | 4 | #include "AbstractRedisModel.h" 5 | 6 | class RedisSetModel : public AbstractRedisModel 7 | { 8 | public: 9 | RedisSetModel(RedisClient* client); 10 | 11 | virtual bool GetData(const std::string& key, RedisResult& results); 12 | 13 | virtual bool UpdateData(const std::string& key, 14 | const std::string& oldValue, 15 | const std::string& newValue, 16 | int idx, 17 | const std::string& field=""); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisStringModel.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "RedisStringModel.h" 3 | 4 | RedisStringModel::RedisStringModel( RedisClient* client ) : AbstractRedisModel(client) 5 | { 6 | 7 | } 8 | 9 | bool RedisStringModel::GetData( const std::string& key, RedisResult& results ) 10 | { 11 | bool retVal = false; 12 | redisReply* reply = GetClient()->Command("GET %s", key.c_str()); 13 | if (!reply) return retVal; 14 | results.NewColumn("Value"); 15 | if (reply->type == REDIS_REPLY_STRING) 16 | { 17 | results.NewRow(); 18 | string& myvalue = results.Value(results.RowSize()-1, 0); 19 | myvalue.assign(reply->str, reply->len); 20 | retVal = true; 21 | } 22 | freeReplyObject(reply); 23 | return retVal; 24 | } 25 | 26 | bool RedisStringModel::UpdateData( const std::string& key, 27 | const std::string& oldValue, 28 | const std::string& newValue, 29 | int idx, 30 | const std::string& field ) 31 | { 32 | ScopedRedisReply reply(GetClient()->Command("SET %s %s", key.c_str(), newValue.c_str())); 33 | if (reply.IsNull() || reply->type != REDIS_REPLY_STATUS) return false; 34 | return true; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisStringModel.h: -------------------------------------------------------------------------------- 1 | #ifndef RedisStringModel_INCLUDED 2 | #define RedisStringModel_INCLUDED 3 | 4 | #include "AbstractRedisModel.h" 5 | 6 | class RedisStringModel : public AbstractRedisModel 7 | { 8 | public: 9 | RedisStringModel(RedisClient* client); 10 | 11 | virtual bool GetData(const std::string& key, RedisResult& results); 12 | 13 | virtual bool UpdateData(const std::string& key, 14 | const std::string& oldValue, 15 | const std::string& newValue, 16 | int idx, 17 | const std::string& field=""); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisZSetModel.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "RedisZSetModel.h" 3 | 4 | RedisZSetModel::RedisZSetModel( RedisClient* client ) : AbstractRedisModel(client) 5 | { 6 | 7 | } 8 | 9 | bool RedisZSetModel::GetData( const std::string& key, RedisResult& results ) 10 | { 11 | bool retVal = false; 12 | redisReply* reply = GetClient()->Command("ZREVRANGE %s %d %d WITHSCORES", key.c_str(), 0, -1); 13 | if (!reply) return retVal; 14 | 15 | results.NewColumn("Score"); 16 | results.NewColumn("Value"); 17 | if (reply->type == REDIS_REPLY_ARRAY) 18 | { 19 | std::size_t i = 0; 20 | redisReply* tmpReply ; 21 | while (i < reply->elements) 22 | { 23 | tmpReply = reply->element[i]; 24 | if (i%2 == 0) 25 | { 26 | results.NewRow(); 27 | 28 | string& myvalue = results.Value(results.RowSize()-1, 1); 29 | myvalue.assign(tmpReply->str, tmpReply->len); 30 | } 31 | else 32 | { 33 | string& myvalue = results.Value(results.RowSize()-1, 0); 34 | myvalue.assign(tmpReply->str, tmpReply->len); 35 | } 36 | i++; 37 | } 38 | retVal = true; 39 | } 40 | freeReplyObject(reply); 41 | return retVal; 42 | } 43 | 44 | bool RedisZSetModel::UpdateData(const std::string& key, 45 | const std::string& oldValue, 46 | const std::string& newValue, 47 | int idx, 48 | const std::string& field) 49 | { 50 | ScopedRedisReply reply(GetClient()->Command("ZREM %s %s", key.c_str(), oldValue.c_str())); 51 | if(reply.IsNull() || reply->type != REDIS_REPLY_INTEGER || reply->integer==0) 52 | return false; 53 | 54 | ScopedRedisReply addReply(GetClient()->Command("ZADD %s %s %s", key.c_str(), field.c_str(), newValue.c_str())); 55 | if (addReply.IsNull() || addReply->type != REDIS_REPLY_INTEGER || reply->integer==0) 56 | return false; 57 | return true; 58 | } 59 | -------------------------------------------------------------------------------- /RedisStudio/Redis/RedisZSetModel.h: -------------------------------------------------------------------------------- 1 | #ifndef RedisZSetModel_INCLUDED 2 | #define RedisZSetModel_INCLUDED 3 | 4 | #include "AbstractRedisModel.h" 5 | 6 | class RedisZSetModel : public AbstractRedisModel 7 | { 8 | public: 9 | RedisZSetModel(RedisClient* client); 10 | 11 | virtual bool GetData(const std::string& key, RedisResult& results); 12 | 13 | virtual bool UpdateData(const std::string& key, 14 | const std::string& oldValue, 15 | const std::string& newValue, 16 | int idx, 17 | const std::string& field=""); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /RedisStudio/Redis/ScopedRedisReply.h: -------------------------------------------------------------------------------- 1 | #ifndef ScopedRedisReply_INCLUDED 2 | #define ScopedRedisReply_INCLUDED 3 | 4 | #include "hiredis/hiredis.h" 5 | 6 | class ScopedRedisReply 7 | { 8 | public: 9 | ScopedRedisReply(redisReply* reply) : m_pReply(reply){} 10 | 11 | ~ScopedRedisReply() 12 | { 13 | if (m_pReply) freeReplyObject(m_pReply); 14 | } 15 | 16 | bool IsNull() 17 | { 18 | if (m_pReply) return false; 19 | return true; 20 | } 21 | 22 | redisReply* operator -> () 23 | { 24 | if (m_pReply) 25 | return m_pReply; 26 | else 27 | throw std::exception("NullPointer"); 28 | } 29 | 30 | private: 31 | redisReply* m_pReply; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /RedisStudio/RedisConfigUI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "AbstractUI.h" 4 | 5 | #include "Redis/RedisClient.h" 6 | 7 | class RedisConfigUI : public AbstraceUI 8 | { 9 | public: 10 | RedisConfigUI(const CDuiString& strXML, CPaintManagerUI* pm, Environment* env); 11 | 12 | ~RedisConfigUI(void); 13 | 14 | void Initialize(); 15 | 16 | virtual CDuiString GetVirtualwndName(); 17 | 18 | virtual void RefreshWnd(); 19 | 20 | virtual int GetIndex(); 21 | 22 | DUI_DECLARE_MESSAGE_MAP() 23 | 24 | public: 25 | virtual void OnClick(TNotifyUI& msg); 26 | 27 | virtual void OnSelectChanged( TNotifyUI &msg ); 28 | 29 | virtual void OnItemClick( TNotifyUI &msg ); 30 | 31 | virtual void OnItemActive( TNotifyUI &msg ); 32 | 33 | private: 34 | bool GetConfig(); 35 | 36 | bool SetConfig(const RedisClient::TDicConfig& config); 37 | 38 | void DoFillData(); 39 | 40 | void DoApplyData(); 41 | 42 | private: 43 | RedisClient::TDicConfig m_dicConfig; 44 | }; 45 | -------------------------------------------------------------------------------- /RedisStudio/RedisHelpUI.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "RedisHelpUI.h" 3 | 4 | DUI_BEGIN_MESSAGE_MAP(RedisHelpUI, CNotifyPump) 5 | DUI_ON_MSGTYPE(DUI_MSGTYPE_CLICK,OnClick) 6 | DUI_END_MESSAGE_MAP() 7 | 8 | RedisHelpUI::RedisHelpUI(const CDuiString& strXML, CPaintManagerUI* pm, Environment* env) : AbstraceUI(pm, env) 9 | { 10 | CDialogBuilder builder; 11 | /// 这里必须传入m_PaintManager,不然子XML不能使用默认滚动条等信息。 12 | CControlUI* pContainer = builder.Create(strXML.GetData(), NULL, NULL, GetPaintMgr(), NULL); 13 | if (pContainer) 14 | { 15 | this->Add(pContainer); 16 | } 17 | else { 18 | this->RemoveAll(); 19 | return; 20 | } 21 | } 22 | 23 | RedisHelpUI::~RedisHelpUI(void) 24 | { 25 | } 26 | 27 | void RedisHelpUI::Initialize() 28 | { 29 | CActiveXUI* pActiveXUI = static_cast(GetPaintMgr()->FindControl(_T("ie"))); 30 | if( pActiveXUI ) { 31 | IWebBrowser2* pWebBrowser = NULL; 32 | pActiveXUI->GetControl(IID_IWebBrowser2, (void**)&pWebBrowser); 33 | // 忽略js错误 34 | pWebBrowser->put_Silent(true); 35 | if( pWebBrowser != NULL ) { 36 | pWebBrowser->Navigate(L"http://redis.io/commands",NULL,NULL,NULL,NULL); 37 | //pWebBrowser->Navigate(L"about:blank",NULL,NULL,NULL,NULL); 38 | pWebBrowser->Release(); 39 | } 40 | } 41 | } 42 | 43 | int RedisHelpUI::GetIndex() 44 | { 45 | return 5; 46 | } 47 | 48 | DuiLib::CDuiString RedisHelpUI::GetVirtualwndName() 49 | { 50 | return _T("RedisHelp"); 51 | } 52 | 53 | void RedisHelpUI::RefreshWnd() 54 | { 55 | 56 | } 57 | 58 | void RedisHelpUI::OnClick( TNotifyUI& msg ) 59 | { 60 | 61 | } 62 | -------------------------------------------------------------------------------- /RedisStudio/RedisHelpUI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "AbstractUI.h" 4 | 5 | class RedisHelpUI : public AbstraceUI 6 | { 7 | public: 8 | RedisHelpUI(const CDuiString& strXML, CPaintManagerUI* pm, Environment* env); 9 | 10 | ~RedisHelpUI(void); 11 | 12 | void Initialize(); 13 | 14 | int GetIndex(); 15 | 16 | CDuiString GetVirtualwndName(); 17 | 18 | void RefreshWnd(); 19 | 20 | DUI_DECLARE_MESSAGE_MAP() 21 | 22 | void OnClick(TNotifyUI& msg); 23 | }; 24 | -------------------------------------------------------------------------------- /RedisStudio/RedisInfoUI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "stdafx.h" 4 | #include "AbstractUI.h" 5 | 6 | #include "Base/RunnableAdapter.h" 7 | #include "Base/Thread.h" 8 | 9 | class CTreeView; 10 | 11 | class RedisInfoUI : public AbstraceUI 12 | { 13 | public: 14 | RedisInfoUI(const CDuiString& strXML, CPaintManagerUI* pm, Environment* env); 15 | 16 | ~RedisInfoUI(); 17 | 18 | void Initialize(); 19 | 20 | int GetIndex(); 21 | 22 | CDuiString GetVirtualwndName(); 23 | 24 | void RefreshWnd(); 25 | 26 | DUI_DECLARE_MESSAGE_MAP() 27 | 28 | virtual LRESULT HandleCustomMessage( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ); 29 | 30 | virtual void OnClick(TNotifyUI& msg); 31 | 32 | virtual void OnSelectChanged( TNotifyUI &msg ); 33 | 34 | virtual void OnItemClick( TNotifyUI &msg ); 35 | 36 | public: 37 | LRESULT OnInfoRefresh(HWND hwnd, WPARAM wParam, LPARAM lParam); 38 | 39 | public: 40 | void DoRefreshWork(); 41 | 42 | void BackgroundWork(); 43 | 44 | private: 45 | void RefreshInfo(); 46 | 47 | private: 48 | CButtonUI* m_RefreshStart; 49 | CButtonUI* m_RefreshStop; 50 | CTreeNodeUI* m_pServerInfoNode; 51 | bool m_bIsRefresh; 52 | Base::Thread m_oThread; 53 | std::auto_ptr< Base::RunnableAdapter > m_pWork; 54 | }; 55 | -------------------------------------------------------------------------------- /RedisStudio/RedisMgrUI.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "RedisMgrUI.h" 3 | 4 | DUI_BEGIN_MESSAGE_MAP(RedisMgrUI, CNotifyPump) 5 | DUI_ON_MSGTYPE(DUI_MSGTYPE_CLICK,OnClick) 6 | DUI_END_MESSAGE_MAP() 7 | 8 | RedisMgrUI::RedisMgrUI(const CDuiString& strXML, CPaintManagerUI* pm, Environment* env) : AbstraceUI(pm, env) 9 | { 10 | CDialogBuilder builder; 11 | /// 这里必须传入m_PaintManager,不然子XML不能使用默认滚动条等信息。 12 | CControlUI* pContainer = builder.Create(strXML.GetData(), NULL, NULL, GetPaintMgr(), NULL); 13 | if( pContainer ) 14 | { 15 | this->Add(pContainer); 16 | } 17 | else { 18 | this->RemoveAll(); 19 | return; 20 | } 21 | } 22 | 23 | RedisMgrUI::~RedisMgrUI(void) 24 | { 25 | } 26 | 27 | void RedisMgrUI::Initialize() 28 | { 29 | 30 | } 31 | 32 | int RedisMgrUI::GetIndex() 33 | { 34 | return 4; 35 | } 36 | 37 | DuiLib::CDuiString RedisMgrUI::GetVirtualwndName() 38 | { 39 | return _T("RedisMgr"); 40 | } 41 | 42 | void RedisMgrUI::RefreshWnd() 43 | { 44 | 45 | } 46 | 47 | void RedisMgrUI::OnClick( TNotifyUI& msg ) 48 | { 49 | 50 | } 51 | -------------------------------------------------------------------------------- /RedisStudio/RedisMgrUI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "AbstractUI.h" 4 | 5 | class RedisMgrUI : public AbstraceUI 6 | { 7 | public: 8 | RedisMgrUI(const CDuiString& strXML, CPaintManagerUI* pm, Environment* env); 9 | 10 | ~RedisMgrUI(void); 11 | 12 | void Initialize(); 13 | 14 | int GetIndex(); 15 | 16 | CDuiString GetVirtualwndName(); 17 | 18 | void RefreshWnd(); 19 | 20 | DUI_DECLARE_MESSAGE_MAP() 21 | 22 | void OnClick(TNotifyUI& msg); 23 | }; 24 | -------------------------------------------------------------------------------- /RedisStudio/RedisStudio.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/RedisStudio/RedisStudio.rc -------------------------------------------------------------------------------- /RedisStudio/SSDB/AbstractSSDBModel.h: -------------------------------------------------------------------------------- 1 | #ifndef AbstractRedisModel_INCLUDED 2 | #define AbstractRedisModel_INCLUDED 3 | 4 | #include 5 | #include "SSDB.h" 6 | 7 | class RedisResult; 8 | 9 | class AbstractSSDBModel 10 | { 11 | public: 12 | AbstractSSDBModel(ssdb::Client* client) : m_pClient(client) {} 13 | 14 | ~AbstractSSDBModel() {} 15 | 16 | virtual bool GetData(const std::string& key, RedisResult& results) = 0; 17 | 18 | virtual bool UpdateData(const std::string& key, 19 | const std::string& oldValue, 20 | const std::string& newValue, 21 | int idx = 0, 22 | const std::string& field="") = 0; 23 | 24 | ssdb::Client* GetClient() 25 | { 26 | return m_pClient; 27 | } 28 | 29 | private: 30 | ssdb::Client* m_pClient; 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /RedisStudio/SSDB/SSDBClient.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDBClient_INCLUDED 2 | #define SSDBClient_INCLUDED 3 | 4 | #include "hiredis/hiredis.h" 5 | #include 6 | #include 7 | #include 8 | #include "../Base/Mutex.h" 9 | #include "SSDBModelFactory.h" 10 | #include "../DBClient.h" 11 | #include "SSDB.h" 12 | 13 | class RedisResult; 14 | 15 | class SSDBClient : public DBClient 16 | { 17 | public: 18 | SSDBClient(); 19 | 20 | ~SSDBClient(); 21 | 22 | bool Connect(const std::string& ip, int port, const std::string& auth); 23 | 24 | bool Ping(); 25 | 26 | bool IsConnected(); 27 | 28 | void Quit(); 29 | 30 | bool Info(std::string& results); 31 | 32 | bool keys(const std::string &, TSeqArrayResults& results); 33 | 34 | bool Exists(const std::string& key); 35 | 36 | bool Type(const std::string& key, string& type); 37 | 38 | long long TTL(const std::string& key); 39 | 40 | bool DatabasesNum(int& num); 41 | 42 | int DatabasesNum(); 43 | 44 | bool SelectDB(int dbindex); 45 | 46 | long long DbSize(); 47 | 48 | bool GetConfig(TDicConfig& dicConfig); 49 | 50 | bool SetConfig(const TDicConfig& dicConfig); 51 | 52 | bool ReWriteConfig(); 53 | 54 | bool GetData(const std::string& key, std::string& type, RedisResult& results); 55 | 56 | bool UpdateData(const std::string& key, 57 | const std::string& oldValue, 58 | const std::string& newValue, 59 | int idx, 60 | const std::string& field=""); 61 | 62 | bool DelKey(const std::string& key); 63 | 64 | std::string RealKey(const std::string& key); 65 | 66 | private: 67 | ssdb::Client* m_Client; 68 | 69 | std::map m_mapKeys; 70 | string m_strIP; 71 | int m_iPort; 72 | string m_strAuth; 73 | bool m_bConnected; 74 | 75 | Base::Mutex m_oMutex; 76 | std::auto_ptr m_pModelFactory; 77 | }; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /RedisStudio/SSDB/SSDBHashModel.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "SSDBHashModel.h" 3 | #include "../Redis/RedisResult.h" 4 | 5 | SSDBHashModel::SSDBHashModel(ssdb::Client* client ) : AbstractSSDBModel(client) 6 | { 7 | 8 | } 9 | 10 | bool SSDBHashModel::GetData( const std::string& key, RedisResult& results ) 11 | { 12 | std::vector hmkeys ; 13 | if (GetClient()->hkeys(key, "", "", 200000, &hmkeys).error()) 14 | { 15 | return false; 16 | } 17 | results.NewColumn("Field "); 18 | results.NewColumn("Value"); 19 | std::string val; 20 | for (std::size_t idx=0; idxhget(key, hmkeys[idx], &val).error()) 23 | { 24 | return false; 25 | } 26 | results.NewRow(); 27 | std::string& field = results.Value(results.RowSize()-1, 0); 28 | std::string& value = results.Value(results.RowSize()-1, 1); 29 | field = hmkeys[idx]; 30 | value = val; 31 | } 32 | return true; 33 | } 34 | 35 | bool SSDBHashModel::UpdateData( const std::string& key, 36 | const std::string& oldValue, 37 | const std::string& newValue, 38 | int idx, 39 | const std::string& field) 40 | { 41 | 42 | return true; 43 | } 44 | -------------------------------------------------------------------------------- /RedisStudio/SSDB/SSDBHashModel.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDBHashModel_INCLUDED 2 | #define SSDBHashModel_INCLUDED 3 | 4 | #include "AbstractSSDBModel.h" 5 | 6 | class SSDBHashModel : public AbstractSSDBModel 7 | { 8 | public: 9 | SSDBHashModel(ssdb::Client* client); 10 | 11 | virtual bool GetData(const std::string& key, RedisResult& results); 12 | 13 | virtual bool UpdateData(const std::string& key, 14 | const std::string& oldValue, 15 | const std::string& newValue, 16 | int idx, 17 | const std::string& field=""); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /RedisStudio/SSDB/SSDBModelFactory.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "SSDBModelFactory.h" 3 | #include "AbstractSSDBModel.h" 4 | #include "SSDBStringModel.h" 5 | #include "SSDBQueueModel.h" 6 | #include "SSDBZSetModel.h" 7 | #include "SSDBHashModel.h" 8 | 9 | SSDBModelFactory::SSDBModelFactory(ssdb::Client* client) 10 | { 11 | Register("string", new SSDBStringModel(client)); 12 | Register("queue", new SSDBQueueModel(client)); 13 | Register("zset", new SSDBZSetModel(client)); 14 | Register("hash", new SSDBHashModel(client)); 15 | } 16 | 17 | SSDBModelFactory::~SSDBModelFactory() 18 | { 19 | TDicModels::iterator it = m_oModels.begin(); 20 | for (; it!=m_oModels.end(); ++it) 21 | { 22 | delete it->second; 23 | } 24 | } 25 | 26 | void SSDBModelFactory::Register( const std::string& type, AbstractSSDBModel* p ) 27 | { 28 | if (m_oModels.find(type) != m_oModels.end()) 29 | { 30 | UnregisterModel(type); 31 | } 32 | m_oModels.insert(std::make_pair(type, p)); 33 | } 34 | 35 | void SSDBModelFactory::UnregisterModel( const std::string& type ) 36 | { 37 | TDicModels::iterator it = m_oModels.find(type); 38 | if (it != m_oModels.end()) 39 | { 40 | delete it->second; 41 | m_oModels.erase(it); 42 | } 43 | } 44 | 45 | AbstractSSDBModel* SSDBModelFactory::GetSSDBModel(const std::string& type ) 46 | { 47 | if (m_oModels.find(type) != m_oModels.end()) 48 | { 49 | return m_oModels[type]; 50 | } 51 | return NULL; 52 | } 53 | -------------------------------------------------------------------------------- /RedisStudio/SSDB/SSDBModelFactory.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDBModelFactory_INCLUDED 2 | #define SSDBModelFactory_INCLUDED 3 | #include 4 | 5 | namespace ssdb { 6 | class Client; 7 | } 8 | class AbstractSSDBModel; 9 | 10 | class SSDBModelFactory 11 | { 12 | public: 13 | SSDBModelFactory(ssdb::Client* client); 14 | 15 | ~SSDBModelFactory(); 16 | 17 | void Register(const std::string& type, AbstractSSDBModel* p); 18 | 19 | void UnregisterModel(const std::string& type); 20 | 21 | AbstractSSDBModel* GetSSDBModel(const std::string& type); 22 | private: 23 | typedef std::map TDicModels; 24 | TDicModels m_oModels; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /RedisStudio/SSDB/SSDBQueueModel.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "SSDBQueueModel.h" 3 | #include "../Redis/RedisResult.h" 4 | 5 | SSDBQueueModel::SSDBQueueModel(ssdb::Client* client):AbstractSSDBModel(client) 6 | { 7 | 8 | } 9 | 10 | bool SSDBQueueModel::GetData( const std::string& key, RedisResult& results ) 11 | { 12 | results.NewColumn("Value"); 13 | std::vector values ; 14 | if (GetClient()->qslice(key, 0, 20000, &values).ok()) 15 | { 16 | for (std::size_t idx=0; idxget(key, &val).ok()) 14 | { 15 | results.NewColumn("Value"); 16 | results.NewRow(); 17 | string& myvalue = results.Value(results.RowSize()-1, 0); 18 | myvalue = val; 19 | return true; 20 | } 21 | else 22 | { 23 | return false; 24 | } 25 | return true; 26 | } 27 | 28 | bool SSDBStringModel::UpdateData( const std::string& key, 29 | const std::string& oldValue, 30 | const std::string& newValue, 31 | int idx, 32 | const std::string& field ) 33 | { 34 | return true; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /RedisStudio/SSDB/SSDBStringModel.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDBStringModel_INCLUDED 2 | #define SSDBStringModel_INCLUDED 3 | 4 | #include "AbstractSSDBModel.h" 5 | 6 | class SSDBStringModel : public AbstractSSDBModel 7 | { 8 | public: 9 | SSDBStringModel(ssdb::Client* client); 10 | 11 | virtual bool GetData(const std::string& key, RedisResult& results); 12 | 13 | virtual bool UpdateData(const std::string& key, 14 | const std::string& oldValue, 15 | const std::string& newValue, 16 | int idx, 17 | const std::string& field=""); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /RedisStudio/SSDB/SSDBZSetModel.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "SSDBZSetModel.h" 3 | #include "strings.h" 4 | #include "../Redis/RedisResult.h" 5 | 6 | SSDBZSetModel::SSDBZSetModel(ssdb::Client* client ) : AbstractSSDBModel(client) 7 | { 8 | 9 | } 10 | 11 | bool SSDBZSetModel::GetData( const std::string& key, RedisResult& results ) 12 | { 13 | results.NewColumn("Score"); 14 | results.NewColumn("Value"); 15 | std::vector values ; 16 | if (GetClient()->zrange(key, 0, 20000, &values).ok()) 17 | { 18 | for (std::size_t idx=0; idxzget(key, values[idx], &score); 22 | results.NewRow(); 23 | std::string& scorestr = results.Value(results.RowSize()-1, 0); 24 | std::string& value = results.Value(results.RowSize()-1, 1); 25 | value = values[idx++]; 26 | scorestr = values[idx++]; 27 | } 28 | } 29 | else 30 | { 31 | return false; 32 | } 33 | return true; 34 | } 35 | 36 | bool SSDBZSetModel::UpdateData(const std::string& key, 37 | const std::string& oldValue, 38 | const std::string& newValue, 39 | int idx, 40 | const std::string& field) 41 | { 42 | return true; 43 | } 44 | -------------------------------------------------------------------------------- /RedisStudio/SSDB/SSDBZSetModel.h: -------------------------------------------------------------------------------- 1 | #ifndef SSDBZSetModel_INCLUDED 2 | #define SSDBZSetModel_INCLUDED 3 | 4 | #include "AbstractSSDBModel.h" 5 | 6 | class SSDBZSetModel : public AbstractSSDBModel 7 | { 8 | public: 9 | SSDBZSetModel(ssdb::Client* client); 10 | 11 | virtual bool GetData(const std::string& key, RedisResult& results); 12 | 13 | virtual bool UpdateData(const std::string& key, 14 | const std::string& oldValue, 15 | const std::string& newValue, 16 | int idx, 17 | const std::string& field=""); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /RedisStudio/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // App.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | #if defined _M_IX86 8 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") 9 | #elif defined _M_IA64 10 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") 11 | #elif defined _M_X64 12 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") 13 | #else 14 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 15 | #endif 16 | -------------------------------------------------------------------------------- /RedisStudio/StdAfx.h: -------------------------------------------------------------------------------- 1 |  2 | #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) 3 | #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ 4 | 5 | #pragma once 6 | 7 | #define WIN32_LEAN_AND_MEAN 8 | #define _CRT_SECURE_NO_DEPRECATE 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "..\DuiLib\UIlib.h" 15 | 16 | using namespace DuiLib; 17 | 18 | //#ifdef _DEBUG 19 | //# ifdef _UNICODE 20 | //# pragma comment(lib, "..\\bin\\DuiLib.lib") 21 | //# else 22 | //# pragma comment(lib, "..\\bin\\DuiLib.lib") 23 | //# endif 24 | //#else 25 | //# ifdef _UNICODE 26 | //# pragma comment(lib, "..\\bin\\DuiLib.lib") 27 | //# else 28 | //# pragma comment(lib, "..\\bin\\DuiLib.lib") 29 | //# endif 30 | //#endif 31 | 32 | //{{AFX_INSERT_LOCATION}} 33 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 34 | 35 | #endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) 36 | -------------------------------------------------------------------------------- /RedisStudio/UserMessage.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UserMessage.h" 3 | 4 | #include "MessageBoxWhd.h" 5 | 6 | void UserMessageBox(HWND hWnd, 7 | UINT ErrorCode, 8 | LPCTSTR lpExMsg, 9 | UINT uType) 10 | { 11 | MessageBoxWhd::MsgType type = MessageBoxWhd::Info; 12 | if (uType == MB_ICONWARNING) type = MessageBoxWhd::Warn; 13 | else if (uType == MB_ICONERROR) type = MessageBoxWhd::Error; 14 | else if (uType == MB_ICONINFORMATION) type = MessageBoxWhd::Info; 15 | 16 | MessageBoxWhd* pWhd = new MessageBoxWhd(type, ErrorCode, lpExMsg); 17 | if( pWhd == NULL ) { return; } 18 | pWhd->Create(hWnd, NULL, UI_CLASSSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL); 19 | pWhd->CenterWindow(); 20 | pWhd->ShowModal(); 21 | } -------------------------------------------------------------------------------- /RedisStudio/UserMessage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WM_USER_UPDATE WM_USER + 1 4 | 5 | #define WM_USER_CONNECTED WM_USER + 11 // 成功连接 6 | #define WM_USER_UNCONNECT WM_USER + 12 // 失败连接 7 | #define WM_USER_CONNECTING WM_USER + 13 // 失败连接 8 | 9 | 10 | #define WM_USER_INFOUPDATE WM_USER + 15 // info get 11 | 12 | 13 | 14 | #define WM_USER_TREEADD WM_USER + 20 // 15 | #define WM_USER_DATAADD WM_USER + 21 // 16 | #define WM_USER_DBADD WM_USER + 22 // 17 | 18 | #define WM_USER_TREEVERBOSE WM_USER + 30 19 | #define WM_USER_DATAVERBOSE WM_USER + 31 20 | 21 | #define WM_USER_MENU_KEYDEL WM_USER + 41 22 | #define WM_USER_MENU_KEYRENAME WM_USER + 42 23 | 24 | void UserMessageBox(HWND hWnd, 25 | UINT ErrorCode, 26 | LPCTSTR lpExMsg, 27 | UINT uType); -------------------------------------------------------------------------------- /RedisStudio/Version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define VERSION "0.1.5" 4 | -------------------------------------------------------------------------------- /RedisStudio/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by RedisStudio.rc 4 | // 5 | #define IDI_ICON1 101 6 | #define IDR_ZIP_SKIN 102 7 | #define IDI_ICON2 103 8 | 9 | // Next default values for new objects 10 | // 11 | #ifdef APSTUDIO_INVOKED 12 | #ifndef APSTUDIO_READONLY_SYMBOLS 13 | #define _APS_NEXT_RESOURCE_VALUE 104 14 | #define _APS_NEXT_COMMAND_VALUE 40001 15 | #define _APS_NEXT_CONTROL_VALUE 1001 16 | #define _APS_NEXT_SYMED_VALUE 101 17 | #endif 18 | #endif 19 | -------------------------------------------------------------------------------- /Skin/rs.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/Skin/rs.ico -------------------------------------------------------------------------------- /Skin/skin-en/1_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/Skin/skin-en/1_close.png -------------------------------------------------------------------------------- /Skin/skin-en/1_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/Skin/skin-en/1_open.png -------------------------------------------------------------------------------- /Skin/skin-en/Combo_nor.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/Skin/skin-en/Combo_nor.bmp -------------------------------------------------------------------------------- /Skin/skin-en/Combo_over.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cinience/RedisStudio/ad3349dfa99be6785e9c677fd0fa2540f371c777/Skin/skin-en/Combo_over.bmp -------------------------------------------------------------------------------- /Skin/skin-en/ConnSubInfo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |