author | Michael Krelin <hacker@klever.net> | 2005-07-25 22:45:28 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2005-07-25 22:45:28 (UTC) |
commit | d2f4327f3752ff30c3b0ec7fdd2e63bc1a1db5ee (patch) (unidiff) | |
tree | 1b5ddc636cee876fac8e90eb78ca3546a1a631b1 /DipstickDlg.cpp | |
parent | 10639b71121a3fe7de24fe141d8dbe399fa283ff (diff) | |
download | dipstick-d2f4327f3752ff30c3b0ec7fdd2e63bc1a1db5ee.zip dipstick-d2f4327f3752ff30c3b0ec7fdd2e63bc1a1db5ee.tar.gz dipstick-d2f4327f3752ff30c3b0ec7fdd2e63bc1a1db5ee.tar.bz2 |
added ability to parse multiple urls from plaintext selection and bumped versions
git-svn-id: http://svn.klever.net/kin/dipstick/trunk@126 fe716a7a-6dde-0310-88d9-d003556173a8
-rw-r--r-- | DipstickDlg.cpp | 62 |
1 files changed, 52 insertions, 10 deletions
diff --git a/DipstickDlg.cpp b/DipstickDlg.cpp index ace2aff..f27b219 100644 --- a/DipstickDlg.cpp +++ b/DipstickDlg.cpp | |||
@@ -100,16 +100,18 @@ WORD hi,lo; | |||
100 | //}}AFX_DATA_INIT | 100 | //}}AFX_DATA_INIT |
101 | // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 | 101 | // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 |
102 | m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); | 102 | m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); |
103 | m_bmpBack.LoadBitmap(IDB_DIABACK); | 103 | m_bmpBack.LoadBitmap(IDB_DIABACK); |
104 | m_bmpBack.GetBitmap(&m_bitmapBack); | 104 | m_bmpBack.GetBitmap(&m_bitmapBack); |
105 | CString tmp; | 105 | CString tmp; |
106 | VERIFY(tmp.LoadString(IDS_REGEX_HTMLURL)); | 106 | VERIFY(tmp.LoadString(IDS_REGEX_HTMLURL)); |
107 | VERIFY(m_reHTMLURL.Compile(tmp,CRegEx::regExtended|CRegEx::regIgnoreCase)); | 107 | VERIFY(m_reHTMLURL.Compile(tmp,CRegEx::regExtended|CRegEx::regIgnoreCase)); |
108 | VERIFY(tmp.LoadString(IDS_REGEX_URL)); | ||
109 | VERIFY(m_reURL.Compile(tmp,CRegEx::regExtended|CRegEx::regIgnoreCase)); | ||
108 | } | 110 | } |
109 | 111 | ||
110 | CDipstickDlg::~CDipstickDlg() | 112 | CDipstickDlg::~CDipstickDlg() |
111 | { | 113 | { |
112 | } | 114 | } |
113 | 115 | ||
114 | void CDipstickDlg::DoDataExchange(CDataExchange* pDX) | 116 | void CDipstickDlg::DoDataExchange(CDataExchange* pDX) |
115 | { | 117 | { |
@@ -130,16 +132,17 @@ void CDipstickDlg::DoDataExchange(CDataExchange* pDX) | |||
130 | 132 | ||
131 | BEGIN_MESSAGE_MAP(CDipstickDlg, CDialog) | 133 | BEGIN_MESSAGE_MAP(CDipstickDlg, CDialog) |
132 | //{{AFX_MSG_MAP(CDipstickDlg) | 134 | //{{AFX_MSG_MAP(CDipstickDlg) |
133 | ON_WM_SYSCOMMAND() | 135 | ON_WM_SYSCOMMAND() |
134 | ON_WM_PAINT() | 136 | ON_WM_PAINT() |
135 | ON_WM_QUERYDRAGICON() | 137 | ON_WM_QUERYDRAGICON() |
136 | ON_WM_DESTROY() | 138 | ON_WM_DESTROY() |
137 | ON_BN_CLICKED(IDC_OPTIONS, OnOptions) | 139 | ON_BN_CLICKED(IDC_OPTIONS, OnOptions) |
140 | ON_MESSAGE(WM_DNP_URLSPING, OnURLSPing) | ||
138 | ON_MESSAGE(WM_DNP_URLPING, OnUrlPing) | 141 | ON_MESSAGE(WM_DNP_URLPING, OnUrlPing) |
139 | ON_MESSAGE(WM_DNP_ACTIVITYCOUNT, OnActivityCount) | 142 | ON_MESSAGE(WM_DNP_ACTIVITYCOUNT, OnActivityCount) |
140 | ON_MESSAGE(WM_DNP_UPDATEHOSTDATA, OnUpdateHostData) | 143 | ON_MESSAGE(WM_DNP_UPDATEHOSTDATA, OnUpdateHostData) |
141 | ON_MESSAGE(WM_DNP_HTML, OnHTMLTransfer) | 144 | ON_MESSAGE(WM_DNP_HTML, OnHTMLTransfer) |
142 | ON_NOTIFY(LVN_COLUMNCLICK, IDC_HOSTLIST, OnColumnclickHostlist) | 145 | ON_NOTIFY(LVN_COLUMNCLICK, IDC_HOSTLIST, OnColumnclickHostlist) |
143 | ON_WM_WINDOWPOSCHANGING() | 146 | ON_WM_WINDOWPOSCHANGING() |
144 | ON_COMMAND(ID_DRAGPAD_OPTIONS, OnDragpadOptions) | 147 | ON_COMMAND(ID_DRAGPAD_OPTIONS, OnDragpadOptions) |
145 | ON_COMMAND(ID_DRAGPAD_SHOWMAINWINDOW, OnDragpadShowmainwindow) | 148 | ON_COMMAND(ID_DRAGPAD_SHOWMAINWINDOW, OnDragpadShowmainwindow) |
@@ -1180,16 +1183,17 @@ UINT cfNIF = RegisterClipboardFormat("Netscape Image Format"); | |||
1180 | memmove(htmlBuff,&lps[startSelection],endSelection-startSelection+1); | 1183 | memmove(htmlBuff,&lps[startSelection],endSelection-startSelection+1); |
1181 | htmlBuff[endSelection-startSelection+1]=0; | 1184 | htmlBuff[endSelection-startSelection+1]=0; |
1182 | xf->html.ReleaseBuffer(); | 1185 | xf->html.ReleaseBuffer(); |
1183 | if(bTestOnly){ | 1186 | if(bTestOnly){ |
1184 | rv = m_reHTMLURL.Match(xf->html); | 1187 | rv = m_reHTMLURL.Match(xf->html); |
1185 | delete xf; | 1188 | delete xf; |
1186 | }else{ | 1189 | }else{ |
1187 | PostMessage(WM_DNP_HTML,0,(LPARAM)xf); | 1190 | PostMessage(WM_DNP_HTML,0,(LPARAM)xf); |
1191 | rv = TRUE; | ||
1188 | } | 1192 | } |
1189 | }while(FALSE); | 1193 | }while(FALSE); |
1190 | GlobalUnlock(hg); | 1194 | GlobalUnlock(hg); |
1191 | GlobalFree(hg); | 1195 | GlobalFree(hg); |
1192 | return rv; | 1196 | return rv; |
1193 | } | 1197 | } |
1194 | if(pDO->IsDataAvailable(cfNIF)){ | 1198 | if(pDO->IsDataAvailable(cfNIF)){ |
1195 | if(!bTestOnly){ | 1199 | if(!bTestOnly){ |
@@ -1205,26 +1209,38 @@ UINT cfNIF = RegisterClipboardFormat("Netscape Image Format"); | |||
1205 | } *nif = (_nif*)lpv; | 1209 | } *nif = (_nif*)lpv; |
1206 | PostMessage(WM_DNP_URLPING,0,(LPARAM)new CString((LPCTSTR)&nif->data[nif->m_offURL])); | 1210 | PostMessage(WM_DNP_URLPING,0,(LPARAM)new CString((LPCTSTR)&nif->data[nif->m_offURL])); |
1207 | GlobalUnlock(hg); | 1211 | GlobalUnlock(hg); |
1208 | GlobalFree(hg); | 1212 | GlobalFree(hg); |
1209 | } | 1213 | } |
1210 | return TRUE; | 1214 | return TRUE; |
1211 | } | 1215 | } |
1212 | if(pDO->IsDataAvailable(CF_TEXT)){ | 1216 | if(pDO->IsDataAvailable(CF_TEXT)){ |
1213 | if(!bTestOnly){ | 1217 | BOOL rv = FALSE; |
1214 | HGLOBAL hg = pDO->GetGlobalData(CF_TEXT); | 1218 | HGLOBAL hg = pDO->GetGlobalData(CF_TEXT); |
1215 | ASSERT(hg); | 1219 | ASSERT(hg); |
1216 | LPVOID lpv = GlobalLock(hg); | 1220 | LPVOID lpv = GlobalLock(hg); |
1217 | ASSERT(lpv); | 1221 | ASSERT(lpv); |
1218 | PostMessage(WM_DNP_URLPING,0,(LPARAM)new CString((LPCTSTR)lpv)); | 1222 | if(bTestOnly){ |
1219 | GlobalUnlock(hg); | 1223 | rv = m_reURL.Match((LPCSTR)lpv); |
1220 | GlobalFree(hg); | 1224 | }else{ |
1225 | CString sel = (LPCSTR)lpv; | ||
1226 | if(m_reURL.Match(sel)) { | ||
1227 | rv = TRUE; | ||
1228 | CString tmp = m_reURL.GetMatch(CRegEx::matchPostMatch); | ||
1229 | if(m_reURL.Match(tmp)) { | ||
1230 | PostMessage(WM_DNP_URLSPING,0,(LPARAM)new CString((LPCSTR)lpv)); | ||
1231 | }else{ | ||
1232 | PostMessage(WM_DNP_URLPING,0,(LPARAM)new CString((LPCTSTR)lpv)); | ||
1233 | } | ||
1234 | } | ||
1221 | } | 1235 | } |
1222 | return TRUE; | 1236 | GlobalUnlock(hg); |
1237 | GlobalFree(hg); | ||
1238 | return rv; | ||
1223 | } | 1239 | } |
1224 | return FALSE; | 1240 | return FALSE; |
1225 | } | 1241 | } |
1226 | 1242 | ||
1227 | LRESULT CDipstickDlg::OnHTMLTransfer(WPARAM wP, LPARAM lP) | 1243 | LRESULT CDipstickDlg::OnHTMLTransfer(WPARAM wP, LPARAM lP) |
1228 | { | 1244 | { |
1229 | _xferHTML* xf = (_xferHTML*)lP; | 1245 | _xferHTML* xf = (_xferHTML*)lP; |
1230 | CSelectURLsDlg su; | 1246 | CSelectURLsDlg su; |
@@ -1252,16 +1268,42 @@ CSelectURLsDlg su; | |||
1252 | while(p){ | 1268 | while(p){ |
1253 | CString url = su.m_URLs.GetNext(p); | 1269 | CString url = su.m_URLs.GetNext(p); |
1254 | PostMessage(WM_DNP_URLPING,0,(LPARAM)new CString(url)); | 1270 | PostMessage(WM_DNP_URLPING,0,(LPARAM)new CString(url)); |
1255 | } | 1271 | } |
1256 | } | 1272 | } |
1257 | return 0; | 1273 | return 0; |
1258 | } | 1274 | } |
1259 | 1275 | ||
1276 | LRESULT CDipstickDlg::OnURLSPing(WPARAM wP,LPARAM lP) | ||
1277 | { | ||
1278 | CString *sel = (CString*)lP; | ||
1279 | TRACE1("URLS: %s\n",(LPCTSTR)*sel); | ||
1280 | CSelectURLsDlg su; | ||
1281 | su.m_bAdjust = m_bSmartAdjust; | ||
1282 | su.m_bAdjustInnermost = m_bAdjustInnermost; | ||
1283 | BeginWaitCursor(); | ||
1284 | while(m_reURL.Match(*sel)){ | ||
1285 | CString url = m_reURL.GetMatch(CRegEx::matchMatch); | ||
1286 | (*sel) = m_reURL.GetMatch(CRegEx::matchPostMatch); | ||
1287 | if(!su.m_URLs.Find(url)) | ||
1288 | VERIFY(su.m_URLs.AddTail(url)); | ||
1289 | } | ||
1290 | EndWaitCursor(); | ||
1291 | delete sel; | ||
1292 | if(su.DoModal()==IDOK){ | ||
1293 | POSITION p = su.m_URLs.GetHeadPosition(); | ||
1294 | while(p){ | ||
1295 | CString url = su.m_URLs.GetNext(p); | ||
1296 | PostMessage(WM_DNP_URLPING,0,(LPARAM)new CString(url)); | ||
1297 | } | ||
1298 | } | ||
1299 | return 0; | ||
1300 | } | ||
1301 | |||
1260 | UINT CPingyHost::PingProc(LPVOID pParam) | 1302 | UINT CPingyHost::PingProc(LPVOID pParam) |
1261 | { | 1303 | { |
1262 | CPingyHost* pThis = (CPingyHost*)pParam; | 1304 | CPingyHost* pThis = (CPingyHost*)pParam; |
1263 | ASSERT(pThis->m_Daddy); | 1305 | ASSERT(pThis->m_Daddy); |
1264 | return pThis->DoPing(); | 1306 | return pThis->DoPing(); |
1265 | } | 1307 | } |
1266 | 1308 | ||
1267 | UINT CPingyHost::DoPing() | 1309 | UINT CPingyHost::DoPing() |
@@ -1578,9 +1620,9 @@ CSingleLock sl(&m_mutex); | |||
1578 | UINT CPingyHost::SuicideProc(LPVOID pParam) | 1620 | UINT CPingyHost::SuicideProc(LPVOID pParam) |
1579 | { | 1621 | { |
1580 | CPingyHost* pThis = (CPingyHost*)pParam; | 1622 | CPingyHost* pThis = (CPingyHost*)pParam; |
1581 | CSingleLock sl(&pThis->m_mutex); | 1623 | CSingleLock sl(&pThis->m_mutex); |
1582 | sl.Lock(); | 1624 | sl.Lock(); |
1583 | VERIFY(sl.Unlock()); | 1625 | VERIFY(sl.Unlock()); |
1584 | delete pThis; | 1626 | delete pThis; |
1585 | return 0; | 1627 | return 0; |
1586 | } | 1628 | } \ No newline at end of file |