-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 @@ -96,24 +96,26 @@ WORD hi,lo; m_bAdjustInnermost = app->GetProfileInt("Options","AdjustInnermost",m_bAdjustInnermost);
m_bIgnorelative = app->GetProfileInt("Options","IgnoreRelative",m_bIgnorelative);
m_impexPath = app->GetProfileString("Options","ImportExportPath",m_impexPath);
//{{AFX_DATA_INIT(CDipstickDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_bmpBack.LoadBitmap(IDB_DIABACK);
m_bmpBack.GetBitmap(&m_bitmapBack);
CString tmp;
VERIFY(tmp.LoadString(IDS_REGEX_HTMLURL));
VERIFY(m_reHTMLURL.Compile(tmp,CRegEx::regExtended|CRegEx::regIgnoreCase));
+ VERIFY(tmp.LoadString(IDS_REGEX_URL));
+ VERIFY(m_reURL.Compile(tmp,CRegEx::regExtended|CRegEx::regIgnoreCase));
}
CDipstickDlg::~CDipstickDlg()
{
}
void CDipstickDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDipstickDlg)
DDX_Control(pDX, IDC_ADVANCED, m_AdvancedCtl);
DDX_Control(pDX, ID_HELP, m_HelpCtl);
@@ -126,24 +128,25 @@ void CDipstickDlg::DoDataExchange(CDataExchange* pDX) DDX_Control(pDX, IDC_CLEAR, m_ClearListCtl);
DDX_Control(pDX, IDC_HOSTLIST, m_HostList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDipstickDlg, CDialog)
//{{AFX_MSG_MAP(CDipstickDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_OPTIONS, OnOptions)
+ ON_MESSAGE(WM_DNP_URLSPING, OnURLSPing)
ON_MESSAGE(WM_DNP_URLPING, OnUrlPing)
ON_MESSAGE(WM_DNP_ACTIVITYCOUNT, OnActivityCount)
ON_MESSAGE(WM_DNP_UPDATEHOSTDATA, OnUpdateHostData)
ON_MESSAGE(WM_DNP_HTML, OnHTMLTransfer)
ON_NOTIFY(LVN_COLUMNCLICK, IDC_HOSTLIST, OnColumnclickHostlist)
ON_WM_WINDOWPOSCHANGING()
ON_COMMAND(ID_DRAGPAD_OPTIONS, OnDragpadOptions)
ON_COMMAND(ID_DRAGPAD_SHOWMAINWINDOW, OnDragpadShowmainwindow)
ON_COMMAND(ID_DRAGPAD_HELP, OnDragpadHelp)
ON_COMMAND(ID_DRAGPAD_ABOUT, OnDragpadAbout)
ON_COMMAND(ID_DRAGPAD_EXIT, OnDragpadExit)
ON_BN_CLICKED(IDC_MANUALPING, OnManualping)
@@ -1176,24 +1179,25 @@ UINT cfNIF = RegisterClipboardFormat("Netscape Image Format"); _xferHTML* xf = new _xferHTML;
VERIFY(xf->src.Crack(sourceURL));
LPTSTR htmlBuff = xf->html.GetBuffer(endSelection-startSelection+2);
ASSERT(htmlBuff);
memmove(htmlBuff,&lps[startSelection],endSelection-startSelection+1);
htmlBuff[endSelection-startSelection+1]=0;
xf->html.ReleaseBuffer();
if(bTestOnly){
rv = m_reHTMLURL.Match(xf->html);
delete xf;
}else{
PostMessage(WM_DNP_HTML,0,(LPARAM)xf);
+ rv = TRUE;
}
}while(FALSE);
GlobalUnlock(hg);
GlobalFree(hg);
return rv;
}
if(pDO->IsDataAvailable(cfNIF)){
if(!bTestOnly){
HGLOBAL hg = pDO->GetGlobalData(cfNIF);
ASSERT(hg);
LPVOID lpv = GlobalLock(hg);
ASSERT(lpv);
@@ -1201,34 +1205,46 @@ UINT cfNIF = RegisterClipboardFormat("Netscape Image Format"); BYTE data[0x20];
DWORD m_offDescr;
DWORD m_offURL;
DWORD m_offToImage;
} *nif = (_nif*)lpv;
PostMessage(WM_DNP_URLPING,0,(LPARAM)new CString((LPCTSTR)&nif->data[nif->m_offURL]));
GlobalUnlock(hg);
GlobalFree(hg);
}
return TRUE;
}
if(pDO->IsDataAvailable(CF_TEXT)){
- if(!bTestOnly){
- HGLOBAL hg = pDO->GetGlobalData(CF_TEXT);
- ASSERT(hg);
- LPVOID lpv = GlobalLock(hg);
- ASSERT(lpv);
- PostMessage(WM_DNP_URLPING,0,(LPARAM)new CString((LPCTSTR)lpv));
- GlobalUnlock(hg);
- GlobalFree(hg);
+ BOOL rv = FALSE;
+ HGLOBAL hg = pDO->GetGlobalData(CF_TEXT);
+ ASSERT(hg);
+ LPVOID lpv = GlobalLock(hg);
+ ASSERT(lpv);
+ if(bTestOnly){
+ rv = m_reURL.Match((LPCSTR)lpv);
+ }else{
+ CString sel = (LPCSTR)lpv;
+ if(m_reURL.Match(sel)) {
+ rv = TRUE;
+ CString tmp = m_reURL.GetMatch(CRegEx::matchPostMatch);
+ if(m_reURL.Match(tmp)) {
+ PostMessage(WM_DNP_URLSPING,0,(LPARAM)new CString((LPCSTR)lpv));
+ }else{
+ PostMessage(WM_DNP_URLPING,0,(LPARAM)new CString((LPCTSTR)lpv));
+ }
+ }
}
- return TRUE;
+ GlobalUnlock(hg);
+ GlobalFree(hg);
+ return rv;
}
return FALSE;
}
LRESULT CDipstickDlg::OnHTMLTransfer(WPARAM wP, LPARAM lP)
{
_xferHTML* xf = (_xferHTML*)lP;
CSelectURLsDlg su;
su.m_bAdjust = m_bSmartAdjust;
su.m_bAdjustInnermost = m_bAdjustInnermost;
BeginWaitCursor();
while(m_reHTMLURL.Match(xf->html)){
@@ -1248,24 +1264,50 @@ CSelectURLsDlg su; EndWaitCursor();
delete xf;
if(su.DoModal()==IDOK){
POSITION p = su.m_URLs.GetHeadPosition();
while(p){
CString url = su.m_URLs.GetNext(p);
PostMessage(WM_DNP_URLPING,0,(LPARAM)new CString(url));
}
}
return 0;
}
+LRESULT CDipstickDlg::OnURLSPing(WPARAM wP,LPARAM lP)
+{
+CString *sel = (CString*)lP;
+TRACE1("URLS: %s\n",(LPCTSTR)*sel);
+CSelectURLsDlg su;
+ su.m_bAdjust = m_bSmartAdjust;
+ su.m_bAdjustInnermost = m_bAdjustInnermost;
+ BeginWaitCursor();
+ while(m_reURL.Match(*sel)){
+ CString url = m_reURL.GetMatch(CRegEx::matchMatch);
+ (*sel) = m_reURL.GetMatch(CRegEx::matchPostMatch);
+ if(!su.m_URLs.Find(url))
+ VERIFY(su.m_URLs.AddTail(url));
+ }
+ EndWaitCursor();
+ delete sel;
+ if(su.DoModal()==IDOK){
+ POSITION p = su.m_URLs.GetHeadPosition();
+ while(p){
+ CString url = su.m_URLs.GetNext(p);
+ PostMessage(WM_DNP_URLPING,0,(LPARAM)new CString(url));
+ }
+ }
+ return 0;
+}
+
UINT CPingyHost::PingProc(LPVOID pParam)
{
CPingyHost* pThis = (CPingyHost*)pParam;
ASSERT(pThis->m_Daddy);
return pThis->DoPing();
}
UINT CPingyHost::DoPing()
{
CSingleLock slock(&m_mutex);
if(!slock.Lock(2000)){
m_Status.LoadString(IDS_PS_FAILEDTOLOCK);
@@ -1574,13 +1616,13 @@ CSingleLock sl(&m_mutex); ASSERT(FALSE);
}
}
UINT CPingyHost::SuicideProc(LPVOID pParam)
{
CPingyHost* pThis = (CPingyHost*)pParam;
CSingleLock sl(&pThis->m_mutex);
sl.Lock();
VERIFY(sl.Unlock());
delete pThis;
return 0;
-}
+}
\ No newline at end of file |