author | Michael Krelin <hacker@klever.net> | 2004-07-05 01:53:09 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2004-07-05 01:53:09 (UTC) |
commit | 955d4e00adc9f39ab93bf21f07506eb75b013c70 (patch) (unidiff) | |
tree | 92493a2c9ac206b822e24a9e5a6f6b1589be6afb | |
download | T42-955d4e00adc9f39ab93bf21f07506eb75b013c70.zip T42-955d4e00adc9f39ab93bf21f07506eb75b013c70.tar.gz T42-955d4e00adc9f39ab93bf21f07506eb75b013c70.tar.bz2 |
initial commit into svn repository
git-svn-id: http://svn.klever.net/kin/T42/trunk@1 fe716a7a-6dde-0310-88d9-d003556173a8
-rw-r--r-- | .gitignore | 36 | ||||
-rw-r--r-- | COPYING | 19 | ||||
-rw-r--r-- | CalleeDlg.cpp | 89 | ||||
-rw-r--r-- | CalleeDlg.h | 40 | ||||
-rw-r--r-- | ColorButton.cpp | 92 | ||||
-rw-r--r-- | ColorButton.h | 47 | ||||
-rw-r--r-- | FontsPage.cpp | 333 | ||||
-rw-r--r-- | FontsPage.h | 87 | ||||
-rw-r--r-- | GeneralPage.cpp | 100 | ||||
-rw-r--r-- | GeneralPage.h | 42 | ||||
-rw-r--r-- | KTAGS | 12 | ||||
-rw-r--r-- | README | 33 | ||||
-rw-r--r-- | SecretaryPage.cpp | 116 | ||||
-rw-r--r-- | SecretaryPage.h | 59 | ||||
-rw-r--r-- | SoundsPage.cpp | 148 | ||||
-rw-r--r-- | SoundsPage.h | 58 | ||||
-rw-r--r-- | T42.clw | 367 | ||||
-rw-r--r-- | T42.cpp | 468 | ||||
-rw-r--r-- | T42.h | 83 | ||||
-rw-r--r-- | T42.mak | 1691 | ||||
-rw-r--r-- | T42.rc | 837 | ||||
-rw-r--r-- | T42AnnounceDlg.cpp | 144 | ||||
-rw-r--r-- | T42AnnounceDlg.h | 55 | ||||
-rw-r--r-- | T42CallLog.h | 53 | ||||
-rw-r--r-- | T42Dlg.cpp | 1251 | ||||
-rw-r--r-- | T42Dlg.h | 159 | ||||
-rw-r--r-- | T42Document.cpp | 181 | ||||
-rw-r--r-- | T42Document.h | 81 | ||||
-rw-r--r-- | T42Frame.cpp | 1212 | ||||
-rw-r--r-- | T42Frame.h | 169 | ||||
-rw-r--r-- | T42Secretary.cpp | 121 | ||||
-rw-r--r-- | T42Secretary.h | 17 | ||||
-rw-r--r-- | T42View.cpp | 703 | ||||
-rw-r--r-- | T42View.h | 220 | ||||
-rw-r--r-- | help/T42.cnt | 16 | ||||
-rw-r--r-- | help/T42.hpj | 31 | ||||
-rw-r--r-- | help/T42.rtf | 194 | ||||
-rw-r--r-- | help/T42.xml | 183 | ||||
-rw-r--r-- | help/announce.bmp | bin | 0 -> 168390 bytes | |||
-rw-r--r-- | help/invite.bmp | bin | 0 -> 148374 bytes | |||
-rw-r--r-- | install/custom.rch | 10 | ||||
-rw-r--r-- | install/install.cpp | 68 | ||||
-rw-r--r-- | install/install.rc | 182 | ||||
-rw-r--r-- | install/resource.h | 24 | ||||
-rw-r--r-- | makehelp.bat | 34 | ||||
-rw-r--r-- | res/IDR_FLIP.ico | bin | 0 -> 4710 bytes | |||
-rw-r--r-- | res/IDR_FULL.ico | bin | 0 -> 4710 bytes | |||
-rw-r--r-- | res/IDR_T42F.ico | bin | 0 -> 4710 bytes | |||
-rw-r--r-- | res/T42-beep.wav | bin | 0 -> 848 bytes | |||
-rw-r--r-- | res/T42-boiling.wav | bin | 0 -> 9644 bytes | |||
-rw-r--r-- | res/T42-whistle.wav | bin | 0 -> 7736 bytes | |||
-rw-r--r-- | res/T42.ico | bin | 0 -> 4710 bytes | |||
-rw-r--r-- | res/T42.rc2 | 13 | ||||
-rw-r--r-- | res/T42calln.ico | bin | 0 -> 1078 bytes | |||
-rw-r--r-- | res/T42callp.ico | bin | 0 -> 1078 bytes | |||
-rw-r--r-- | res/fullcup.ico | bin | 0 -> 4710 bytes | |||
-rw-r--r-- | resource.h | 200 | ||||
-rw-r--r-- | shared-code/BTreendex.h | 595 | ||||
-rw-r--r-- | shared-code/BellsNWhistles.h | 146 | ||||
-rw-r--r-- | shared-code/BitSet.h | 105 | ||||
-rw-r--r-- | shared-code/Dynamide.h | 443 | ||||
-rw-r--r-- | shared-code/FindIFace.h | 125 | ||||
-rw-r--r-- | shared-code/LRUCache.h | 113 | ||||
-rw-r--r-- | shared-code/RegEx.cpp | 1697 | ||||
-rw-r--r-- | shared-code/RegEx.h | 158 | ||||
-rw-r--r-- | shared-code/SNMPExtDll.h | 252 | ||||
-rw-r--r-- | shared-code/SNMPOIDs.h | 221 | ||||
-rw-r--r-- | shared-code/SNMPeer.h | 286 | ||||
-rw-r--r-- | shared-code/install.h | 370 | ||||
-rw-r--r-- | shared-code/ip_icmp.h | 91 | ||||
-rw-r--r-- | shared-code/kHelpers.h | 159 | ||||
-rw-r--r-- | shared-code/kICMP.cpp | 300 | ||||
-rw-r--r-- | shared-code/kICMP.h | 80 | ||||
-rw-r--r-- | shared-code/kinhelp.xsl | 250 | ||||
-rw-r--r-- | shared-code/ms_icmp.h | 77 | ||||
-rw-r--r-- | shared-data/browse-icon.ico | bin | 0 -> 1078 bytes | |||
-rw-r--r-- | shared-data/install-icon.ico | bin | 0 -> 2998 bytes | |||
-rw-r--r-- | shared-data/klever-background.bmp | bin | 0 -> 2578 bytes | |||
-rw-r--r-- | shared-data/play-icon.ico | bin | 0 -> 1078 bytes | |||
-rw-r--r-- | stdafx.cpp | 6 | ||||
-rw-r--r-- | stdafx.h | 70 | ||||
-rw-r--r-- | talkd.h | 47 |
82 files changed, 15669 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..340de8d --- a/dev/null +++ b/.gitignore | |||
@@ -0,0 +1,36 @@ | |||
1 | |||
2 | # / | ||
3 | /Debug | ||
4 | /Release | ||
5 | /Releast | ||
6 | /debug | ||
7 | /release | ||
8 | /releast | ||
9 | /DEBUG | ||
10 | /RELEASE | ||
11 | /RELEAST | ||
12 | /*.mdp | ||
13 | /*.ncb | ||
14 | /*.aps | ||
15 | /redist | ||
16 | |||
17 | # /help/ | ||
18 | /help/T42.HLP | ||
19 | /help/T42.LOG | ||
20 | /help/T42.hm | ||
21 | /help/T42.GID | ||
22 | |||
23 | # /install/ | ||
24 | /install/debug | ||
25 | /install/pure | ||
26 | /install/canned | ||
27 | /install/static | ||
28 | /install/Debug | ||
29 | /install/Pure | ||
30 | /install/Canned | ||
31 | /install/Static | ||
32 | /install/DEBUG | ||
33 | /install/PURE | ||
34 | /install/CANNED | ||
35 | /install/STATIC | ||
36 | /install/*.aps | ||
@@ -0,0 +1,19 @@ | |||
1 | Copyright (c) 1998, 2002 Klever Group (http://www.klever.net/) | ||
2 | |||
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
4 | this software and associated documentation files (the "Software"), to deal in | ||
5 | the Software without restriction, including without limitation the rights to | ||
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
7 | of the Software, and to permit persons to whom the Software is furnished to do | ||
8 | so, subject to the following conditions: | ||
9 | |||
10 | The above copyright notice and this permission notice shall be included in all | ||
11 | copies or substantial portions of the Software. | ||
12 | |||
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
19 | SOFTWARE. | ||
diff --git a/CalleeDlg.cpp b/CalleeDlg.cpp new file mode 100644 index 0000000..971781e --- a/dev/null +++ b/CalleeDlg.cpp | |||
@@ -0,0 +1,89 @@ | |||
1 | // CalleeDlg.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "CalleeDlg.h" | ||
7 | |||
8 | #ifdef _DEBUG | ||
9 | #define new DEBUG_NEW | ||
10 | #undef THIS_FILE | ||
11 | static char THIS_FILE[] = __FILE__; | ||
12 | #endif | ||
13 | |||
14 | ///////////////////////////////////////////////////////////////////////////// | ||
15 | // CCalleeDlg dialog | ||
16 | |||
17 | |||
18 | CCalleeDlg::CCalleeDlg(CWnd* pParent /*=NULL*/) | ||
19 | : CDialog(CCalleeDlg::IDD, pParent) | ||
20 | { | ||
21 | //{{AFX_DATA_INIT(CCalleeDlg) | ||
22 | m_Callee = _T(""); | ||
23 | m_Caller = _T(""); | ||
24 | m_TTY = _T(""); | ||
25 | //}}AFX_DATA_INIT | ||
26 | } | ||
27 | |||
28 | |||
29 | void CCalleeDlg::DoDataExchange(CDataExchange* pDX) | ||
30 | { | ||
31 | CDialog::DoDataExchange(pDX); | ||
32 | //{{AFX_DATA_MAP(CCalleeDlg) | ||
33 | DDX_Control(pDX, IDC_CALLER, m_CallerCtl); | ||
34 | DDX_Control(pDX, IDC_CALLEE, m_CalleeCtl); | ||
35 | DDX_Text(pDX, IDC_CALLEE, m_Callee); | ||
36 | DDX_CBString(pDX, IDC_CALLER, m_Caller); | ||
37 | DDV_MaxChars(pDX, m_Caller, 11); | ||
38 | DDX_CBString(pDX, IDC_TTY, m_TTY); | ||
39 | DDV_MaxChars(pDX, m_TTY, 15); | ||
40 | //}}AFX_DATA_MAP | ||
41 | } | ||
42 | |||
43 | |||
44 | BEGIN_MESSAGE_MAP(CCalleeDlg, CDialog) | ||
45 | //{{AFX_MSG_MAP(CCalleeDlg) | ||
46 | //}}AFX_MSG_MAP | ||
47 | END_MESSAGE_MAP() | ||
48 | |||
49 | ///////////////////////////////////////////////////////////////////////////// | ||
50 | // CCalleeDlg message handlers | ||
51 | |||
52 | BOOL CCalleeDlg::OnInitDialog() | ||
53 | { | ||
54 | CDialog::OnInitDialog(); | ||
55 | |||
56 | CT42App* app = (CT42App*)AfxGetApp(); | ||
57 | ASSERT(app); | ||
58 | POSITION p = app->m_t42Callees.GetHeadPosition(); | ||
59 | m_CalleeCtl.ResetContent(); | ||
60 | while(p){ | ||
61 | CString callee = app->m_t42Callees.GetNext(p); | ||
62 | m_CalleeCtl.AddString(callee); | ||
63 | if(m_Callee.IsEmpty()) | ||
64 | m_Callee = callee; | ||
65 | } | ||
66 | m_CallerCtl.ResetContent(); | ||
67 | p = app->m_t42Callers.GetHeadPosition(); | ||
68 | while(p){ | ||
69 | CString caller = app->m_t42Callers.GetNext(p); | ||
70 | m_CallerCtl.AddString(caller); | ||
71 | if(m_Caller.IsEmpty()) | ||
72 | m_Caller = caller; | ||
73 | } | ||
74 | UpdateData(FALSE); | ||
75 | |||
76 | return TRUE; // return TRUE unless you set the focus to a control | ||
77 | // EXCEPTION: OCX Property Pages should return FALSE | ||
78 | } | ||
79 | |||
80 | void CCalleeDlg::OnOK() | ||
81 | { | ||
82 | UpdateData(TRUE); | ||
83 | if(m_Caller.IsEmpty()) | ||
84 | VERIFY(m_Caller.LoadString(IDS_DEFAULTCALLER)); | ||
85 | CT42App* app = (CT42App*)AfxGetApp(); | ||
86 | ASSERT(app); | ||
87 | app->LastCaller(m_Caller); | ||
88 | CDialog::OnOK(); | ||
89 | } | ||
diff --git a/CalleeDlg.h b/CalleeDlg.h new file mode 100644 index 0000000..0044ba1 --- a/dev/null +++ b/CalleeDlg.h | |||
@@ -0,0 +1,40 @@ | |||
1 | // CalleeDlg.h : header file | ||
2 | // | ||
3 | |||
4 | ///////////////////////////////////////////////////////////////////////////// | ||
5 | // CCalleeDlg dialog | ||
6 | |||
7 | class CCalleeDlg : public CDialog | ||
8 | { | ||
9 | // Construction | ||
10 | public: | ||
11 | CCalleeDlg(CWnd* pParent = NULL); // standard constructor | ||
12 | |||
13 | // Dialog Data | ||
14 | //{{AFX_DATA(CCalleeDlg) | ||
15 | enum { IDD = IDD_REMOTE }; | ||
16 | CComboBoxm_CallerCtl; | ||
17 | CComboBoxm_CalleeCtl; | ||
18 | CStringm_Callee; | ||
19 | CStringm_Caller; | ||
20 | CStringm_TTY; | ||
21 | //}}AFX_DATA | ||
22 | |||
23 | |||
24 | // Overrides | ||
25 | // ClassWizard generated virtual function overrides | ||
26 | //{{AFX_VIRTUAL(CCalleeDlg) | ||
27 | protected: | ||
28 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support | ||
29 | //}}AFX_VIRTUAL | ||
30 | |||
31 | // Implementation | ||
32 | protected: | ||
33 | |||
34 | // Generated message map functions | ||
35 | //{{AFX_MSG(CCalleeDlg) | ||
36 | virtual BOOL OnInitDialog(); | ||
37 | virtual void OnOK(); | ||
38 | //}}AFX_MSG | ||
39 | DECLARE_MESSAGE_MAP() | ||
40 | }; | ||
diff --git a/ColorButton.cpp b/ColorButton.cpp new file mode 100644 index 0000000..d702875 --- a/dev/null +++ b/ColorButton.cpp | |||
@@ -0,0 +1,92 @@ | |||
1 | // ColorButton.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "ColorButton.h" | ||
7 | |||
8 | #ifdef _DEBUG | ||
9 | #define new DEBUG_NEW | ||
10 | #undef THIS_FILE | ||
11 | static char THIS_FILE[] = __FILE__; | ||
12 | #endif | ||
13 | |||
14 | ///////////////////////////////////////////////////////////////////////////// | ||
15 | // CColorButton | ||
16 | |||
17 | CColorButton::CColorButton() | ||
18 | { | ||
19 | } | ||
20 | |||
21 | CColorButton::~CColorButton() | ||
22 | { | ||
23 | } | ||
24 | |||
25 | |||
26 | BEGIN_MESSAGE_MAP(CColorButton, CButton) | ||
27 | //{{AFX_MSG_MAP(CColorButton) | ||
28 | //}}AFX_MSG_MAP | ||
29 | END_MESSAGE_MAP() | ||
30 | |||
31 | ///////////////////////////////////////////////////////////////////////////// | ||
32 | // CColorButton message handlers | ||
33 | |||
34 | |||
35 | void CColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) | ||
36 | { | ||
37 | ASSERT(lpDrawItemStruct->CtlType==ODT_BUTTON); | ||
38 | CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); | ||
39 | CRect rc(lpDrawItemStruct->rcItem); | ||
40 | pDC->DrawFrameControl( | ||
41 | &rc, | ||
42 | DFC_BUTTON, | ||
43 | DFCS_BUTTONPUSH|( | ||
44 | (lpDrawItemStruct->itemState&ODS_DISABLED) | ||
45 | ? DFCS_INACTIVE | ||
46 | : ( | ||
47 | (lpDrawItemStruct->itemState&ODS_SELECTED) | ||
48 | ? DFCS_PUSHED | ||
49 | : 0 | ||
50 | ) | ||
51 | )|DFCS_ADJUSTRECT | ||
52 | ); | ||
53 | if(!(lpDrawItemStruct->itemState&ODS_DISABLED)){ | ||
54 | CBrush b(m_Color); | ||
55 | pDC->FillRect(rc,&b); | ||
56 | if(lpDrawItemStruct->itemState&ODS_FOCUS) | ||
57 | pDC->DrawFocusRect(rc); | ||
58 | } | ||
59 | CString txt; | ||
60 | GetWindowText(txt); | ||
61 | if((lpDrawItemStruct->itemState&ODS_DISABLED)){ | ||
62 | CSize sz = pDC->GetOutputTextExtent(txt); | ||
63 | if(txt.Find('&')>=0) | ||
64 | sz.cx-=pDC->GetOutputTextExtent("&",1).cx; | ||
65 | CRect rcc; | ||
66 | rcc.top=rcc.bottom=rc.CenterPoint().y; | ||
67 | rcc.left=rcc.right=rc.CenterPoint().x; | ||
68 | rcc.InflateRect(sz.cx/2,sz.cy/2); | ||
69 | pDC->DrawState(rcc.TopLeft(),rcc.Size(),(LPCTSTR)txt,DST_PREFIXTEXT|DSS_DISABLED,TRUE,0,(HBRUSH)NULL); | ||
70 | }else{ | ||
71 | COLORREF ocol = pDC->SetTextColor(/*RGB(255,255,255)^*/~m_Color); | ||
72 | int omo = pDC->SetBkMode(TRANSPARENT); | ||
73 | pDC->DrawText(txt,&rc,DT_CENTER|DT_SINGLELINE|DT_VCENTER); | ||
74 | pDC->SetBkMode(omo); | ||
75 | pDC->SetTextColor(ocol); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | COLORREF CColorButton::SelectColor(COLORREF color) | ||
80 | { | ||
81 | CColorDialog cd(color,CC_RGBINIT,this); | ||
82 | if(cd.DoModal()==IDOK) | ||
83 | return cd.GetColor(); | ||
84 | else | ||
85 | return color; | ||
86 | } | ||
87 | |||
88 | void CColorButton::SetColor() | ||
89 | { | ||
90 | m_Color=SelectColor(m_Color); | ||
91 | Invalidate(); | ||
92 | } | ||
diff --git a/ColorButton.h b/ColorButton.h new file mode 100644 index 0000000..98e2f62 --- a/dev/null +++ b/ColorButton.h | |||
@@ -0,0 +1,47 @@ | |||
1 | #ifndef__COLORBUTTON_H | ||
2 | #define__COLORBUTTON_H | ||
3 | |||
4 | // ColorButton.h : header file | ||
5 | // | ||
6 | |||
7 | ///////////////////////////////////////////////////////////////////////////// | ||
8 | // CColorButton window | ||
9 | |||
10 | class CColorButton : public CButton | ||
11 | { | ||
12 | // Construction | ||
13 | public: | ||
14 | void SetColor(); | ||
15 | COLORREF SelectColor(COLORREF color); | ||
16 | CBrush m_brColor; | ||
17 | COLORREF m_Color; | ||
18 | CColorButton(); | ||
19 | |||
20 | // Attributes | ||
21 | public: | ||
22 | |||
23 | // Operations | ||
24 | public: | ||
25 | |||
26 | // Overrides | ||
27 | // ClassWizard generated virtual function overrides | ||
28 | //{{AFX_VIRTUAL(CColorButton) | ||
29 | public: | ||
30 | virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); | ||
31 | //}}AFX_VIRTUAL | ||
32 | |||
33 | // Implementation | ||
34 | public: | ||
35 | virtual ~CColorButton(); | ||
36 | |||
37 | // Generated message map functions | ||
38 | protected: | ||
39 | //{{AFX_MSG(CColorButton) | ||
40 | //}}AFX_MSG | ||
41 | |||
42 | DECLARE_MESSAGE_MAP() | ||
43 | }; | ||
44 | |||
45 | ///////////////////////////////////////////////////////////////////////////// | ||
46 | |||
47 | #endif// __COLORBUTTON_H | ||
diff --git a/FontsPage.cpp b/FontsPage.cpp new file mode 100644 index 0000000..772f962 --- a/dev/null +++ b/FontsPage.cpp | |||
@@ -0,0 +1,333 @@ | |||
1 | // FontsPage.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "FontsPage.h" | ||
7 | |||
8 | #ifdef _DEBUG | ||
9 | #define new DEBUG_NEW | ||
10 | #undef THIS_FILE | ||
11 | static char THIS_FILE[] = __FILE__; | ||
12 | #endif | ||
13 | |||
14 | ///////////////////////////////////////////////////////////////////////////// | ||
15 | // CFontsPage property page | ||
16 | |||
17 | IMPLEMENT_DYNCREATE(CFontsPage, CPropertyPage) | ||
18 | |||
19 | CFontsPage::CFontsPage() : CPropertyPage(CFontsPage::IDD) | ||
20 | { | ||
21 | //{{AFX_DATA_INIT(CFontsPage) | ||
22 | //}}AFX_DATA_INIT | ||
23 | CRichEditCtrl tmp; | ||
24 | tmp.Create(WS_CHILD,CRect(0,0,0,0),AfxGetApp()->m_pMainWnd,0); | ||
25 | memset(&m_fmtChar,0,sizeof(m_fmtChar)); | ||
26 | m_fmtLast=NULL; | ||
27 | } | ||
28 | |||
29 | CFontsPage::~CFontsPage() | ||
30 | { | ||
31 | } | ||
32 | |||
33 | void CFontsPage::DoDataExchange(CDataExchange* pDX) | ||
34 | { | ||
35 | CPropertyPage::DoDataExchange(pDX); | ||
36 | //{{AFX_DATA_MAP(CFontsPage) | ||
37 | DDX_Control(pDX, IDC_TIP, m_TipCtl); | ||
38 | DDX_Control(pDX, IDC_FORECOLOR, m_fgColorCtl); | ||
39 | DDX_Control(pDX, IDC_BACKCOLOR, m_bgColorCtl); | ||
40 | DDX_Control(pDX, IDC_CHARSET, m_CharsetCtl); | ||
41 | DDX_Control(pDX, IDC_UNDERLINE, m_UnderlineCtl); | ||
42 | DDX_Control(pDX, IDC_STRIKEOUT, m_StrikeoutCtl); | ||
43 | DDX_Control(pDX, IDC_ITALIC, m_ItalicCtl); | ||
44 | DDX_Control(pDX, IDC_BOLD, m_BoldCtl); | ||
45 | DDX_Control(pDX, IDC_FONTSIZE, m_SizeCtl); | ||
46 | DDX_Control(pDX, IDC_FORMATNAME, m_FormatsCtl); | ||
47 | DDX_Control(pDX, IDC_FACES, m_FacesCtl); | ||
48 | DDX_Control(pDX, IDC_SAMPLE, m_SampleCtl); | ||
49 | //}}AFX_DATA_MAP | ||
50 | } | ||
51 | |||
52 | |||
53 | BEGIN_MESSAGE_MAP(CFontsPage, CPropertyPage) | ||
54 | //{{AFX_MSG_MAP(CFontsPage) | ||
55 | ON_CBN_SELENDOK(IDC_FACES, OnSelendokFaces) | ||
56 | ON_BN_CLICKED(IDC_BOLD, OnBold) | ||
57 | ON_CBN_SELENDOK(IDC_FONTSIZE, OnSelendokFontsize) | ||
58 | ON_CBN_EDITCHANGE(IDC_FONTSIZE, OnEditchangeFontsize) | ||
59 | ON_BN_CLICKED(IDC_ITALIC, OnItalic) | ||
60 | ON_BN_CLICKED(IDC_STRIKEOUT, OnStrikeout) | ||
61 | ON_BN_CLICKED(IDC_UNDERLINE, OnUnderline) | ||
62 | ON_CBN_SELENDOK(IDC_CHARSET, OnSelendokCharset) | ||
63 | ON_BN_CLICKED(IDC_BACKCOLOR, OnBackcolor) | ||
64 | ON_BN_CLICKED(IDC_FORECOLOR, OnForecolor) | ||
65 | ON_LBN_SELCHANGE(IDC_FORMATNAME, OnSelchangeFormatname) | ||
66 | //}}AFX_MSG_MAP | ||
67 | END_MESSAGE_MAP() | ||
68 | |||
69 | ///////////////////////////////////////////////////////////////////////////// | ||
70 | // CFontsPage message handlers | ||
71 | |||
72 | BOOL CFontsPage::OnInitDialog() | ||
73 | { | ||
74 | CPropertyPage::OnInitDialog(); | ||
75 | |||
76 | m_SampleCtl.GetDefaultCharFormat(m_fmtDefChar); | ||
77 | |||
78 | // Fill in faces combo | ||
79 | m_FacesCtl.ResetContent(); | ||
80 | CClientDC dc(NULL); | ||
81 | LOGFONT lf; | ||
82 | memset(&lf,0,sizeof(lf)); | ||
83 | lf.lfCharSet = DEFAULT_CHARSET; | ||
84 | EnumFontFamiliesEx(dc.m_hDC,&lf,(FONTENUMPROC)FillInFaces,(LPARAM)&m_FacesCtl,0); | ||
85 | |||
86 | // Fill in formats list | ||
87 | FillInFormats(); | ||
88 | |||
89 | return TRUE; // return TRUE unless you set the focus to a control | ||
90 | // EXCEPTION: OCX Property Pages should return FALSE | ||
91 | } | ||
92 | |||
93 | int CALLBACK CFontsPage::FillInFaces(const ENUMLOGFONTEX* lpelfe,const TEXTMETRIC* lpntme,const int FontType,const LPARAM lParam) | ||
94 | { | ||
95 | //if(FontType!=TRUETYPE_FONTTYPE) | ||
96 | // return 1; | ||
97 | CComboBox* cb = (CComboBox*)lParam; | ||
98 | ASSERT(cb); | ||
99 | if(cb->FindString(0,lpelfe->elfLogFont.lfFaceName)>=0) | ||
100 | return 1; | ||
101 | cb->AddString(lpelfe->elfLogFont.lfFaceName); | ||
102 | return 1; | ||
103 | } | ||
104 | |||
105 | |||
106 | void CFontsPage::UpdateFormat(BOOL bSave) | ||
107 | { | ||
108 | if(bSave){ | ||
109 | CString tmp; | ||
110 | m_FacesCtl.GetWindowText(tmp); | ||
111 | strcpy(m_fmtChar.szFaceName,tmp); m_fmtChar.dwMask|=CFM_FACE; | ||
112 | m_SizeCtl.GetWindowText(tmp); | ||
113 | m_fmtChar.yHeight = atoi(tmp)?(atoi(tmp)*REFS2PTS):m_fmtChar.yHeight; | ||
114 | m_fmtChar.dwMask|=CFM_SIZE; | ||
115 | if(m_BoldCtl.GetCheck()) | ||
116 | m_fmtChar.dwEffects|=CFE_BOLD; | ||
117 | else | ||
118 | m_fmtChar.dwEffects&=~CFE_BOLD; | ||
119 | m_fmtChar.dwMask|=CFM_BOLD; | ||
120 | if(m_ItalicCtl.GetCheck()) | ||
121 | m_fmtChar.dwEffects|=CFE_ITALIC; | ||
122 | else | ||
123 | m_fmtChar.dwEffects&=~CFE_ITALIC; | ||
124 | m_fmtChar.dwMask|=CFM_ITALIC; | ||
125 | if(m_StrikeoutCtl.GetCheck()) | ||
126 | m_fmtChar.dwEffects|=CFE_STRIKEOUT; | ||
127 | else | ||
128 | m_fmtChar.dwEffects&=~CFE_STRIKEOUT; | ||
129 | m_fmtChar.dwMask|=CFM_STRIKEOUT; | ||
130 | if(m_UnderlineCtl.GetCheck()) | ||
131 | m_fmtChar.dwEffects|=CFE_UNDERLINE; | ||
132 | else | ||
133 | m_fmtChar.dwEffects&=~CFE_UNDERLINE; | ||
134 | m_fmtChar.dwMask|=CFM_UNDERLINE; | ||
135 | if(m_CharsetCtl.IsWindowEnabled()) | ||
136 | m_fmtChar.bCharSet=m_CharsetCtl.GetItemData(m_CharsetCtl.GetCurSel()); | ||
137 | else | ||
138 | m_fmtChar.bCharSet=DEFAULT_CHARSET; | ||
139 | m_fmtChar.crTextColor = m_fgColorCtl.m_Color; | ||
140 | m_fmtChar.dwMask|=CFM_COLOR; | ||
141 | m_fmtChar.dwEffects&=~CFE_AUTOCOLOR; | ||
142 | UpdateSample(); | ||
143 | }else{ | ||
144 | if(m_fmtChar.cbSize!=sizeof(m_fmtChar)) | ||
145 | memmove(&m_fmtChar,&m_fmtDefChar,sizeof(m_fmtChar)); | ||
146 | if(m_fmtChar.dwMask&CFM_FACE) | ||
147 | m_FacesCtl.SelectString(0,m_fmtChar.szFaceName); | ||
148 | CString tmp; | ||
149 | if(m_fmtChar.dwMask&CFM_SIZE){ | ||
150 | tmp.Format("%d",m_fmtChar.yHeight/REFS2PTS); | ||
151 | m_SizeCtl.SetWindowText(tmp); | ||
152 | } | ||
153 | if(m_fmtChar.dwMask&CFM_BOLD) | ||
154 | m_BoldCtl.SetCheck((m_fmtChar.dwEffects&CFE_BOLD)?1:0); | ||
155 | if(m_fmtChar.dwMask&CFM_ITALIC) | ||
156 | m_ItalicCtl.SetCheck((m_fmtChar.dwEffects&CFE_ITALIC)?1:0); | ||
157 | if(m_fmtChar.dwMask&CFM_STRIKEOUT) | ||
158 | m_StrikeoutCtl.SetCheck((m_fmtChar.dwEffects&CFE_STRIKEOUT)?1:0); | ||
159 | if(m_fmtChar.dwMask&CFM_UNDERLINE) | ||
160 | m_UnderlineCtl.SetCheck((m_fmtChar.dwEffects&CFE_UNDERLINE)?1:0); | ||
161 | m_fgColorCtl.m_Color = (m_fmtChar.dwMask&CFM_COLOR)?m_fmtChar.crTextColor:0; | ||
162 | m_fgColorCtl.Invalidate(); | ||
163 | FillCharsets(); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | void CFontsPage::UpdateSample() | ||
168 | { | ||
169 | m_SampleCtl.SetReadOnly(TRUE); | ||
170 | m_SampleCtl.SetTargetDevice(NULL,0); | ||
171 | m_SampleCtl.SetSel(0,-1); | ||
172 | m_SampleCtl.ReplaceSel( | ||
173 | (m_fmtChar.dwMask&CFM_FACE) | ||
174 | ? ( | ||
175 | (*m_fmtChar.szFaceName) | ||
176 | ? m_fmtChar.szFaceName | ||
177 | : "Sample" | ||
178 | ) | ||
179 | : "Sample" | ||
180 | ); | ||
181 | m_SampleCtl.SetSel(0,-1); | ||
182 | m_SampleCtl.SetSelectionCharFormat(m_fmtChar); | ||
183 | PARAFORMAT pf; | ||
184 | memset(&pf,0,sizeof(pf)); | ||
185 | pf.cbSize = sizeof(pf); | ||
186 | pf.dwMask = PFM_ALIGNMENT; | ||
187 | pf.wAlignment = PFA_CENTER; | ||
188 | m_SampleCtl.SetParaFormat(pf); | ||
189 | m_SampleCtl.HideSelection(TRUE,TRUE); | ||
190 | if(m_bgColorCtl.IsWindowEnabled()) | ||
191 | m_SampleCtl.SetBackgroundColor(FALSE,m_bgColorCtl.m_Color); | ||
192 | } | ||
193 | |||
194 | void CFontsPage::OnSelendokFaces() | ||
195 | { | ||
196 | UpdateFormat(TRUE); | ||
197 | FillCharsets(); | ||
198 | } | ||
199 | |||
200 | void CFontsPage::OnSelendokFontsize() | ||
201 | { | ||
202 | CString tmp; | ||
203 | m_SizeCtl.GetLBText(m_SizeCtl.GetCurSel(),tmp); | ||
204 | m_SizeCtl.SetWindowText(tmp); | ||
205 | UpdateFormat(TRUE); | ||
206 | } | ||
207 | void CFontsPage::OnEditchangeFontsize() | ||
208 | { | ||
209 | UpdateFormat(TRUE); | ||
210 | } | ||
211 | |||
212 | void CFontsPage::OnBold() | ||
213 | { | ||
214 | UpdateFormat(TRUE); | ||
215 | } | ||
216 | void CFontsPage::OnItalic() | ||
217 | { | ||
218 | UpdateFormat(TRUE); | ||
219 | } | ||
220 | void CFontsPage::OnStrikeout() | ||
221 | { | ||
222 | UpdateFormat(TRUE); | ||
223 | } | ||
224 | void CFontsPage::OnUnderline() | ||
225 | { | ||
226 | UpdateFormat(TRUE); | ||
227 | } | ||
228 | |||
229 | void CFontsPage::FillCharsets() | ||
230 | { | ||
231 | m_CharsetCtl.EnableWindow(TRUE); | ||
232 | m_CharsetCtl.ResetContent(); | ||
233 | CString tmp; | ||
234 | tmp.LoadString(IDS_CHARSET_AUTO); | ||
235 | VERIFY(m_CharsetCtl.AddString(tmp)==0); | ||
236 | VERIFY(m_CharsetCtl.SetItemData(0,DEFAULT_CHARSET)!=LB_ERR); | ||
237 | if(m_fmtChar.dwMask&CFM_FACE && *m_fmtChar.szFaceName){ | ||
238 | CClientDC dc(NULL); | ||
239 | LOGFONT lf; | ||
240 | memset(&lf,0,sizeof(lf)); | ||
241 | lf.lfCharSet = DEFAULT_CHARSET; | ||
242 | strcpy(lf.lfFaceName,m_fmtChar.szFaceName); | ||
243 | EnumFontFamiliesEx(dc.m_hDC,&lf,(FONTENUMPROC)FillInCharsets,(LPARAM)&m_CharsetCtl,0); | ||
244 | } | ||
245 | int ii = m_CharsetCtl.GetCount(); | ||
246 | for(int i=0;i<ii;i++){ | ||
247 | if(m_CharsetCtl.GetItemData(i)==m_fmtChar.bCharSet){ | ||
248 | m_CharsetCtl.SetCurSel(i); | ||
249 | break; | ||
250 | } | ||
251 | } | ||
252 | m_CharsetCtl.EnableWindow(m_CharsetCtl.GetCount()>1); | ||
253 | } | ||
254 | |||
255 | int CALLBACK CFontsPage::FillInCharsets(const ENUMLOGFONTEX* lpelfe,const TEXTMETRIC* lpntme,const int FontType,const LPARAM lParam) | ||
256 | { | ||
257 | //if(FontType!=TRUETYPE_FONTTYPE) | ||
258 | // return 1; | ||
259 | CComboBox* cb = (CComboBox*)lParam; | ||
260 | ASSERT(cb); | ||
261 | if(cb->FindString(0,(char*)lpelfe->elfScript)>=0) | ||
262 | return 1; | ||
263 | int i = cb->AddString((char*)lpelfe->elfScript); | ||
264 | ASSERT(i>=0); | ||
265 | VERIFY(cb->SetItemData(i,lpelfe->elfLogFont.lfCharSet)!=LB_ERR); | ||
266 | return 1; | ||
267 | } | ||
268 | |||
269 | void CFontsPage::OnSelendokCharset() | ||
270 | { | ||
271 | UpdateFormat(TRUE); | ||
272 | } | ||
273 | |||
274 | void CFontsPage::FillInFormats() | ||
275 | { | ||
276 | AddFmt(IDS_FMT_T42LOCAL,&m_fmtT42Local); | ||
277 | AddFmt(IDS_FMT_T42REMOTE,&m_fmtT42Remote); | ||
278 | AddFmt(IDS_FMT_T42SYSTEM,&m_fmtT42System,0); | ||
279 | m_FormatsCtl.SetCurSel(0); | ||
280 | OnSelchangeFormatname(); | ||
281 | } | ||
282 | void CFontsPage::AddFmt(UINT name,CFontFormat* cf,UINT flags) | ||
283 | { | ||
284 | CString f; | ||
285 | VERIFY(f.LoadString(name)); | ||
286 | int lf = f.Find('\n'); | ||
287 | int i = m_FormatsCtl.AddString((lf<0)?f:f.Left(lf)); | ||
288 | ASSERT(i>=0); | ||
289 | m_FormatsCtl.SetItemData(i,(LPARAM)cf); | ||
290 | cf->m_Tip = (lf<0)?"":f.Mid(lf+1); | ||
291 | cf->m_Flags = flags; | ||
292 | } | ||
293 | void CFontsPage::OnSelchangeFormatname() | ||
294 | { | ||
295 | CFontFormat* fmt = (CFontFormat*)m_FormatsCtl.GetItemData(m_FormatsCtl.GetCurSel()); | ||
296 | if(m_fmtLast){ | ||
297 | memmove(&m_fmtLast->m_fmtChar,&m_fmtChar,sizeof(m_fmtLast->m_fmtChar)); | ||
298 | if(m_fmtLast->m_Flags&CFontFormat::flagBGColor) | ||
299 | m_fmtLast->m_bgColor = m_bgColorCtl.m_Color; | ||
300 | } | ||
301 | BOOL bBG = fmt->m_Flags&CFontFormat::flagBGColor; | ||
302 | m_bgColorCtl.EnableWindow(bBG); | ||
303 | m_TipCtl.SetWindowText(fmt->m_Tip); | ||
304 | m_fmtLast = fmt; | ||
305 | memmove(&m_fmtChar,&m_fmtLast->m_fmtChar,sizeof(m_fmtChar)); | ||
306 | if(bBG){ | ||
307 | m_bgColorCtl.m_Color = m_fmtLast->m_bgColor; | ||
308 | m_bgColorCtl.Invalidate(); | ||
309 | } | ||
310 | UpdateFormat(FALSE); | ||
311 | UpdateSample(); | ||
312 | } | ||
313 | |||
314 | void CFontsPage::OnBackcolor() | ||
315 | { | ||
316 | m_bgColorCtl.SetColor(); | ||
317 | UpdateFormat(TRUE); | ||
318 | } | ||
319 | void CFontsPage::OnForecolor() | ||
320 | { | ||
321 | m_fgColorCtl.SetColor(); | ||
322 | UpdateFormat(TRUE); | ||
323 | } | ||
324 | |||
325 | void CFontsPage::OnOK() | ||
326 | { | ||
327 | if(m_fmtLast){ | ||
328 | memmove(&m_fmtLast->m_fmtChar,&m_fmtChar,sizeof(m_fmtLast->m_fmtChar)); | ||
329 | if(m_fmtLast->m_Flags&CFontFormat::flagBGColor) | ||
330 | m_fmtLast->m_bgColor = m_bgColorCtl.m_Color; | ||
331 | } | ||
332 | CPropertyPage::OnOK(); | ||
333 | } | ||
diff --git a/FontsPage.h b/FontsPage.h new file mode 100644 index 0000000..96c2b97 --- a/dev/null +++ b/FontsPage.h | |||
@@ -0,0 +1,87 @@ | |||
1 | // FontsPage.h : header file | ||
2 | // | ||
3 | |||
4 | #include "ColorButton.h" | ||
5 | |||
6 | ///////////////////////////////////////////////////////////////////////////// | ||
7 | // CFontsPage dialog | ||
8 | |||
9 | struct CFontFormat{ | ||
10 | CHARFORMATm_fmtChar; | ||
11 | COLORREFm_bgColor; | ||
12 | enum _flags{ | ||
13 | flagBGColor = 1 | ||
14 | }; | ||
15 | int m_Flags; | ||
16 | CString m_Tip; | ||
17 | }; | ||
18 | |||
19 | class CFontsPage : public CPropertyPage | ||
20 | { | ||
21 | DECLARE_DYNCREATE(CFontsPage) | ||
22 | |||
23 | // Construction | ||
24 | public: | ||
25 | CHARFORMAT m_fmtDefChar; | ||
26 | CFontFormat* m_fmtLast; | ||
27 | void AddFmt(UINT name,CFontFormat* cf,UINT flags=CFontFormat::flagBGColor); | ||
28 | void FillInFormats(); | ||
29 | CFontFormat m_fmtT42System; | ||
30 | CFontFormat m_fmtT42Remote; | ||
31 | CFontFormat m_fmtT42Local; | ||
32 | static int CALLBACK FillInCharsets(const ENUMLOGFONTEX* lpelfe,const TEXTMETRIC* lpntme,const int FontType,const LPARAM lParam); | ||
33 | void FillCharsets(); | ||
34 | void UpdateSample(); | ||
35 | void UpdateFormat(BOOL bSave=FALSE); | ||
36 | CHARFORMAT m_fmtChar; | ||
37 | static int CALLBACK FillInFaces(const ENUMLOGFONTEX* lpelfe,const TEXTMETRIC* lpntme,const int FontType,const LPARAM lParam); | ||
38 | CFontsPage(); | ||
39 | ~CFontsPage(); | ||
40 | |||
41 | // Dialog Data | ||
42 | //{{AFX_DATA(CFontsPage) | ||
43 | enum { IDD = IDD_OPTIONS_FONTS }; | ||
44 | CStaticm_TipCtl; | ||
45 | CColorButtonm_fgColorCtl; | ||
46 | CColorButtonm_bgColorCtl; | ||
47 | CComboBoxm_CharsetCtl; | ||
48 | CButtonm_UnderlineCtl; | ||
49 | CButtonm_StrikeoutCtl; | ||
50 | CButtonm_ItalicCtl; | ||
51 | CButtonm_BoldCtl; | ||
52 | CComboBoxm_SizeCtl; | ||
53 | CListBoxm_FormatsCtl; | ||
54 | CComboBoxm_FacesCtl; | ||
55 | CRichEditCtrl m_SampleCtl; | ||
56 | //}}AFX_DATA | ||
57 | |||
58 | |||
59 | // Overrides | ||
60 | // ClassWizard generate virtual function overrides | ||
61 | //{{AFX_VIRTUAL(CFontsPage) | ||
62 | public: | ||
63 | virtual void OnOK(); | ||
64 | protected: | ||
65 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support | ||
66 | //}}AFX_VIRTUAL | ||
67 | |||
68 | // Implementation | ||
69 | protected: | ||
70 | // Generated message map functions | ||
71 | //{{AFX_MSG(CFontsPage) | ||
72 | virtual BOOL OnInitDialog(); | ||
73 | afx_msg void OnSelendokFaces(); | ||
74 | afx_msg void OnBold(); | ||
75 | afx_msg void OnSelendokFontsize(); | ||
76 | afx_msg void OnEditchangeFontsize(); | ||
77 | afx_msg void OnItalic(); | ||
78 | afx_msg void OnStrikeout(); | ||
79 | afx_msg void OnUnderline(); | ||
80 | afx_msg void OnSelendokCharset(); | ||
81 | afx_msg void OnBackcolor(); | ||
82 | afx_msg void OnForecolor(); | ||
83 | afx_msg void OnSelchangeFormatname(); | ||
84 | //}}AFX_MSG | ||
85 | DECLARE_MESSAGE_MAP() | ||
86 | |||
87 | }; | ||
diff --git a/GeneralPage.cpp b/GeneralPage.cpp new file mode 100644 index 0000000..78863fc --- a/dev/null +++ b/GeneralPage.cpp | |||
@@ -0,0 +1,100 @@ | |||
1 | // GeneralPage.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "GeneralPage.h" | ||
7 | |||
8 | #ifdef _DEBUG | ||
9 | #define new DEBUG_NEW | ||
10 | #undef THIS_FILE | ||
11 | static char THIS_FILE[] = __FILE__; | ||
12 | #endif | ||
13 | |||
14 | ///////////////////////////////////////////////////////////////////////////// | ||
15 | // CGeneralPage property page | ||
16 | |||
17 | IMPLEMENT_DYNCREATE(CGeneralPage, CPropertyPage) | ||
18 | |||
19 | CGeneralPage::CGeneralPage() : CPropertyPage(CGeneralPage::IDD) | ||
20 | { | ||
21 | //{{AFX_DATA_INIT(CGeneralPage) | ||
22 | //}}AFX_DATA_INIT | ||
23 | m_ntalkPort = 518; | ||
24 | } | ||
25 | |||
26 | CGeneralPage::~CGeneralPage() | ||
27 | { | ||
28 | } | ||
29 | |||
30 | void CGeneralPage::DoDataExchange(CDataExchange* pDX) | ||
31 | { | ||
32 | CPropertyPage::DoDataExchange(pDX); | ||
33 | //{{AFX_DATA_MAP(CGeneralPage) | ||
34 | DDX_Control(pDX, IDC_NTALKPORTSPIN, m_ntalkSpinCtl); | ||
35 | DDX_Control(pDX, IDC_NTALKPORT, m_ntalkPortCtl); | ||
36 | //}}AFX_DATA_MAP | ||
37 | if(pDX->m_bSaveAndValidate){ | ||
38 | pDX->PrepareEditCtrl(IDC_NTALKPORT); | ||
39 | CString ntp; | ||
40 | m_ntalkPortCtl.GetWindowText(ntp); | ||
41 | UINT p = atoi(ntp); | ||
42 | if(!p){ | ||
43 | servent* se = getservbyname((LPCTSTR)ntp,"udp"); | ||
44 | if(se) | ||
45 | p = ntohs(se->s_port); | ||
46 | else{ | ||
47 | AfxMessageBox(IDS_FAILVALIDATE_NTALKPORT,MB_OK|MB_ICONSTOP); | ||
48 | pDX->Fail(); | ||
49 | return; | ||
50 | } | ||
51 | } | ||
52 | m_ntalkPort = p; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | |||
57 | BEGIN_MESSAGE_MAP(CGeneralPage, CPropertyPage) | ||
58 | //{{AFX_MSG_MAP(CGeneralPage) | ||
59 | ON_NOTIFY(UDN_DELTAPOS, IDC_NTALKPORTSPIN, OnDeltaposNtalkportspin) | ||
60 | //}}AFX_MSG_MAP | ||
61 | END_MESSAGE_MAP() | ||
62 | |||
63 | ///////////////////////////////////////////////////////////////////////////// | ||
64 | // CGeneralPage message handlers | ||
65 | |||
66 | BOOL CGeneralPage::OnInitDialog() | ||
67 | { | ||
68 | CPropertyPage::OnInitDialog(); | ||
69 | |||
70 | m_ntalkSpinCtl.SetRange(1,min(UD_MAXVAL,65535)); | ||
71 | m_ntalkSpinCtl.SetPos(m_ntalkPort); | ||
72 | SetPortCtl(); | ||
73 | |||
74 | return TRUE; // return TRUE unless you set the focus to a control | ||
75 | // EXCEPTION: OCX Property Pages should return FALSE | ||
76 | } | ||
77 | |||
78 | void CGeneralPage::SetPortCtl() | ||
79 | { | ||
80 | servent* se = getservbyport(htons(m_ntalkPort),"udp"); | ||
81 | if(se) | ||
82 | m_ntalkPortCtl.SetWindowText(se->s_name); | ||
83 | else{ | ||
84 | CString tmp; | ||
85 | tmp.Format("%u",m_ntalkPort); | ||
86 | m_ntalkPortCtl.SetWindowText(tmp); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | void CGeneralPage::OnDeltaposNtalkportspin(NMHDR* pNMHDR, LRESULT* pResult) | ||
91 | { | ||
92 | NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; | ||
93 | |||
94 | TRACE3("UD iP %d, iD %d, p %d\n",pNMUpDown->iPos, | ||
95 | pNMUpDown->iDelta, m_ntalkSpinCtl.GetPos()); | ||
96 | m_ntalkPort = pNMUpDown->iPos+pNMUpDown->iDelta; | ||
97 | SetPortCtl(); | ||
98 | |||
99 | *pResult = 0; | ||
100 | } | ||
diff --git a/GeneralPage.h b/GeneralPage.h new file mode 100644 index 0000000..134e747 --- a/dev/null +++ b/GeneralPage.h | |||
@@ -0,0 +1,42 @@ | |||
1 | // GeneralPage.h : header file | ||
2 | // | ||
3 | |||
4 | ///////////////////////////////////////////////////////////////////////////// | ||
5 | // CGeneralPage dialog | ||
6 | |||
7 | class CGeneralPage : public CPropertyPage | ||
8 | { | ||
9 | DECLARE_DYNCREATE(CGeneralPage) | ||
10 | |||
11 | // Construction | ||
12 | public: | ||
13 | void SetPortCtl(); | ||
14 | UINT m_ntalkPort; | ||
15 | CGeneralPage(); | ||
16 | ~CGeneralPage(); | ||
17 | |||
18 | // Dialog Data | ||
19 | //{{AFX_DATA(CGeneralPage) | ||
20 | enum { IDD = IDD_OPTIONS_GENERAL }; | ||
21 | CSpinButtonCtrlm_ntalkSpinCtl; | ||
22 | CEditm_ntalkPortCtl; | ||
23 | //}}AFX_DATA | ||
24 | |||
25 | |||
26 | // Overrides | ||
27 | // ClassWizard generate virtual function overrides | ||
28 | //{{AFX_VIRTUAL(CGeneralPage) | ||
29 | protected: | ||
30 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support | ||
31 | //}}AFX_VIRTUAL | ||
32 | |||
33 | // Implementation | ||
34 | protected: | ||
35 | // Generated message map functions | ||
36 | //{{AFX_MSG(CGeneralPage) | ||
37 | virtual BOOL OnInitDialog(); | ||
38 | afx_msg void OnDeltaposNtalkportspin(NMHDR* pNMHDR, LRESULT* pResult); | ||
39 | //}}AFX_MSG | ||
40 | DECLARE_MESSAGE_MAP() | ||
41 | |||
42 | }; | ||
@@ -0,0 +1,12 @@ | |||
1 | about-date T42.rc /LTEXT\s\+"Copyright /;"kind:d | ||
2 | about-version T42.rc /LTEXT\s\+"T42, Version/;"kind:v | ||
3 | help-license-date ./help/T42.xml /<license\s/;"kind:d | ||
4 | help-news ./help/T42.xml/<newsfor\s/ | ||
5 | install-version ./install/install.cpp /^#define\s\+KINAME\s\+"/;"kind:v | ||
6 | install-vsinfo-date install/install.rc /^\s\+VALUE\s\+"LegalCopyright",/;"kind:d | ||
7 | install-vsinfo-numeric-version install/install.rc /^\s\+FILEVERSION\s\+/;"kind:v | ||
8 | install-vsinfo-string-version install/install.rc /^\s\+VALUE\s\+"FileVersion",/;"kind:v | ||
9 | license-date COPYING :1;"kind:d | ||
10 | vsinfo-date T42.rc /VALUE\s\+"LegalCopyright",/;"kind:d | ||
11 | vsinfo-numeric-version T42.rc /^\s\+FILEVERSION\s\+/;"kind:v | ||
12 | vsinfo-string-version T42.rc /^\s\+VALUE\s\+"FileVersion",/;"kind:v | ||
@@ -0,0 +1,33 @@ | |||
1 | |||
2 | Before compiling canned install executable the following files should be placed | ||
3 | in the build tree: | ||
4 | |||
5 | redist/mfc42.dl_ | ||
6 | |||
7 | Release checklist: | ||
8 | (These are tags stored in KTAGS file. please, keep in sync. Use vim to | ||
9 | jump to these tags. I haven't tried it on windows, though). | ||
10 | |||
11 | |help-news| - Release notes in help file | ||
12 | |||
13 | Version number in the following places: | ||
14 | |||
15 | |about-version| - About box | ||
16 | |vsinfo-numeric-version| - VERSIONINFO numerical File&Prod V | ||
17 | |vsinfo-string-version| - VERSIONINFO string File&Prod V | ||
18 | |install-version| - Version used in install | ||
19 | |install-vsinfo-numeric-version|- install's VERSIONINFO block | ||
20 | |install-vsinfo-string-version| - install's VERSIONINFO block | ||
21 | |||
22 | If the year flips check these: | ||
23 | |||
24 | |about-date| - About box | ||
25 | |help-license-date| - license in help file | ||
26 | |license-date| - license in COPYING file | ||
27 | |vsinfo-date| - Copyright in VERSIONINFO block | ||
28 | |install-vsinfo-date| - Copyright in install's VERSIONINFO | ||
29 | block | ||
30 | |||
31 | |||
32 | This is for vim (don't remove): | ||
33 | vim:set tags=KTAGS isk=!-~,^*,^\|,^\" ft=help: | ||
diff --git a/SecretaryPage.cpp b/SecretaryPage.cpp new file mode 100644 index 0000000..affac08 --- a/dev/null +++ b/SecretaryPage.cpp | |||
@@ -0,0 +1,116 @@ | |||
1 | // SecretaryPage.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "SecretaryPage.h" | ||
7 | |||
8 | #ifdef _DEBUG | ||
9 | #define new DEBUG_NEW | ||
10 | #undef THIS_FILE | ||
11 | static char THIS_FILE[] = __FILE__; | ||
12 | #endif | ||
13 | |||
14 | ///////////////////////////////////////////////////////////////////////////// | ||
15 | // CSecretaryPage property page | ||
16 | |||
17 | IMPLEMENT_DYNCREATE(CSecretaryPage, CPropertyPage) | ||
18 | |||
19 | CSecretaryPage::CSecretaryPage() : CPropertyPage(CSecretaryPage::IDD) | ||
20 | { | ||
21 | //{{AFX_DATA_INIT(CSecretaryPage) | ||
22 | m_limitBytes = 0; | ||
23 | m_bLimitBytes = FALSE; | ||
24 | m_bLimitTime = FALSE; | ||
25 | m_Greeting = _T(""); | ||
26 | m_limitTime = 0; | ||
27 | m_bLimitWin = FALSE; | ||
28 | m_limitWin = 0; | ||
29 | //}}AFX_DATA_INIT | ||
30 | } | ||
31 | |||
32 | CSecretaryPage::~CSecretaryPage() | ||
33 | { | ||
34 | } | ||
35 | |||
36 | void CSecretaryPage::DoDataExchange(CDataExchange* pDX) | ||
37 | { | ||
38 | CPropertyPage::DoDataExchange(pDX); | ||
39 | //{{AFX_DATA_MAP(CSecretaryPage) | ||
40 | DDX_Control(pDX, IDC_DOWINLIMIT, m_bLimitWinCtl); | ||
41 | DDX_Control(pDX, IDC_WINSPIN, m_WinSpinCtl); | ||
42 | DDX_Control(pDX, IDC_TIMESPIN, m_TimeSpinCtl); | ||
43 | DDX_Control(pDX, IDC_WINLIMIT, m_limitWinCtl); | ||
44 | DDX_Control(pDX, IDC_CHARSPIN, m_CharSpinCtl); | ||
45 | DDX_Control(pDX, IDC_TIMELIMIT, m_limitTimeCtl); | ||
46 | DDX_Control(pDX, IDC_DOTIMELIMIT, m_bLimitTimeCtl); | ||
47 | DDX_Control(pDX, IDC_DOBYTELIMIT, m_bLimitBytesCtl); | ||
48 | DDX_Control(pDX, IDC_BYTELIMIT, m_limitBytesCtl); | ||
49 | DDX_Text(pDX, IDC_BYTELIMIT, m_limitBytes); | ||
50 | DDX_Check(pDX, IDC_DOBYTELIMIT, m_bLimitBytes); | ||
51 | DDX_Check(pDX, IDC_DOTIMELIMIT, m_bLimitTime); | ||
52 | DDX_Text(pDX, IDC_GREETING, m_Greeting); | ||
53 | DDX_Text(pDX, IDC_TIMELIMIT, m_limitTime); | ||
54 | DDX_Check(pDX, IDC_DOWINLIMIT, m_bLimitWin); | ||
55 | DDX_Text(pDX, IDC_WINLIMIT, m_limitWin); | ||
56 | //}}AFX_DATA_MAP | ||
57 | } | ||
58 | |||
59 | |||
60 | BEGIN_MESSAGE_MAP(CSecretaryPage, CPropertyPage) | ||
61 | //{{AFX_MSG_MAP(CSecretaryPage) | ||
62 | ON_BN_CLICKED(IDC_DOBYTELIMIT, OnDobytelimit) | ||
63 | ON_BN_CLICKED(IDC_DOTIMELIMIT, OnDotimelimit) | ||
64 | ON_BN_CLICKED(IDC_DOWINLIMIT, OnDowinlimit) | ||
65 | //}}AFX_MSG_MAP | ||
66 | END_MESSAGE_MAP() | ||
67 | |||
68 | ///////////////////////////////////////////////////////////////////////////// | ||
69 | // CSecretaryPage message handlers | ||
70 | |||
71 | BOOL CSecretaryPage::OnInitDialog() | ||
72 | { | ||
73 | CPropertyPage::OnInitDialog(); | ||
74 | |||
75 | SetTimeLimit(); | ||
76 | SetBytesLimit(); | ||
77 | SetWinLimit(); | ||
78 | m_TimeSpinCtl.SetRange(0,60); | ||
79 | m_WinSpinCtl.SetRange(0,100); | ||
80 | m_CharSpinCtl.SetRange(0,UD_MAXVAL); | ||
81 | UDACCEL uda = {0,512}; | ||
82 | m_CharSpinCtl.SetAccel(1,&uda); | ||
83 | return TRUE; // return TRUE unless you set the focus to a control | ||
84 | // EXCEPTION: OCX Property Pages should return FALSE | ||
85 | } | ||
86 | |||
87 | void CSecretaryPage::SetTimeLimit() | ||
88 | { | ||
89 | m_limitTimeCtl.EnableWindow(m_bLimitTimeCtl.GetCheck()); | ||
90 | } | ||
91 | |||
92 | void CSecretaryPage::SetBytesLimit() | ||
93 | { | ||
94 | m_limitBytesCtl.EnableWindow(m_bLimitBytesCtl.GetCheck()); | ||
95 | } | ||
96 | |||
97 | void CSecretaryPage::SetWinLimit() | ||
98 | { | ||
99 | m_limitWinCtl.EnableWindow(m_bLimitWinCtl.GetCheck()); | ||
100 | } | ||
101 | |||
102 | void CSecretaryPage::OnDobytelimit() | ||
103 | { | ||
104 | SetBytesLimit(); | ||
105 | } | ||
106 | |||
107 | void CSecretaryPage::OnDotimelimit() | ||
108 | { | ||
109 | SetTimeLimit(); | ||
110 | } | ||
111 | |||
112 | void CSecretaryPage::OnDowinlimit() | ||
113 | { | ||
114 | SetWinLimit(); | ||
115 | } | ||
116 | |||
diff --git a/SecretaryPage.h b/SecretaryPage.h new file mode 100644 index 0000000..108d933 --- a/dev/null +++ b/SecretaryPage.h | |||
@@ -0,0 +1,59 @@ | |||
1 | // SecretaryPage.h : header file | ||
2 | // | ||
3 | |||
4 | ///////////////////////////////////////////////////////////////////////////// | ||
5 | // CSecretaryPage dialog | ||
6 | |||
7 | class CSecretaryPage : public CPropertyPage | ||
8 | { | ||
9 | DECLARE_DYNCREATE(CSecretaryPage) | ||
10 | |||
11 | // Construction | ||
12 | public: | ||
13 | void SetWinLimit(); | ||
14 | void SetBytesLimit(); | ||
15 | void SetTimeLimit(); | ||
16 | CSecretaryPage(); | ||
17 | ~CSecretaryPage(); | ||
18 | |||
19 | // Dialog Data | ||
20 | //{{AFX_DATA(CSecretaryPage) | ||
21 | enum { IDD = IDD_OPTIONS_SECRETARY }; | ||
22 | CButtonm_bLimitWinCtl; | ||
23 | CSpinButtonCtrlm_WinSpinCtl; | ||
24 | CSpinButtonCtrlm_TimeSpinCtl; | ||
25 | CEditm_limitWinCtl; | ||
26 | CSpinButtonCtrlm_CharSpinCtl; | ||
27 | CEditm_limitTimeCtl; | ||
28 | CButtonm_bLimitTimeCtl; | ||
29 | CButtonm_bLimitBytesCtl; | ||
30 | CEditm_limitBytesCtl; | ||
31 | UINTm_limitBytes; | ||
32 | BOOLm_bLimitBytes; | ||
33 | BOOLm_bLimitTime; | ||
34 | CStringm_Greeting; | ||
35 | UINTm_limitTime; | ||
36 | BOOLm_bLimitWin; | ||
37 | UINTm_limitWin; | ||
38 | //}}AFX_DATA | ||
39 | |||
40 | |||
41 | // Overrides | ||
42 | // ClassWizard generate virtual function overrides | ||
43 | //{{AFX_VIRTUAL(CSecretaryPage) | ||
44 | protected: | ||
45 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support | ||
46 | //}}AFX_VIRTUAL | ||
47 | |||
48 | // Implementation | ||
49 | protected: | ||
50 | // Generated message map functions | ||
51 | //{{AFX_MSG(CSecretaryPage) | ||
52 | virtual BOOL OnInitDialog(); | ||
53 | afx_msg void OnDobytelimit(); | ||
54 | afx_msg void OnDotimelimit(); | ||
55 | afx_msg void OnDowinlimit(); | ||
56 | //}}AFX_MSG | ||
57 | DECLARE_MESSAGE_MAP() | ||
58 | |||
59 | }; | ||
diff --git a/SoundsPage.cpp b/SoundsPage.cpp new file mode 100644 index 0000000..ba81736 --- a/dev/null +++ b/SoundsPage.cpp | |||
@@ -0,0 +1,148 @@ | |||
1 | // SoundsPage.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "SoundsPage.h" | ||
7 | |||
8 | #ifdef _DEBUG | ||
9 | #define new DEBUG_NEW | ||
10 | #undef THIS_FILE | ||
11 | static char THIS_FILE[] = __FILE__; | ||
12 | #endif | ||
13 | |||
14 | ///////////////////////////////////////////////////////////////////////////// | ||
15 | // CSoundsPage property page | ||
16 | |||
17 | IMPLEMENT_DYNCREATE(CSoundsPage, CPropertyPage) | ||
18 | |||
19 | CSoundsPage::CSoundsPage() : CPropertyPage(CSoundsPage::IDD) | ||
20 | { | ||
21 | //{{AFX_DATA_INIT(CSoundsPage) | ||
22 | m_T42Bell = _T(""); | ||
23 | m_T42Prompt = _T(""); | ||
24 | m_bT42PromptLoop = FALSE; | ||
25 | m_T42Wake = _T(""); | ||
26 | //}}AFX_DATA_INIT | ||
27 | } | ||
28 | |||
29 | CSoundsPage::~CSoundsPage() | ||
30 | { | ||
31 | } | ||
32 | |||
33 | void CSoundsPage::DoDataExchange(CDataExchange* pDX) | ||
34 | { | ||
35 | CPropertyPage::DoDataExchange(pDX); | ||
36 | //{{AFX_DATA_MAP(CSoundsPage) | ||
37 | DDX_Control(pDX, IDC_T42WAKE_PLAY, m_T42WakePlayCtl); | ||
38 | DDX_Control(pDX, IDC_T42PROMPT_PLAY, m_T42PromptPlayCtl); | ||
39 | DDX_Control(pDX, IDC_T42BELL_PLAY, m_T42BellPlayCtl); | ||
40 | DDX_Control(pDX, IDC_T42WAKE_BROWSE, m_T42WakeBrowseCtl); | ||
41 | DDX_Control(pDX, IDC_T42WAKE, m_T42WakeCtl); | ||
42 | DDX_Control(pDX, IDC_T42PROMPT_BROWSE, m_T42PromptBrowseCtl); | ||
43 | DDX_Control(pDX, IDC_T42PROMPT, m_T42PromptCtl); | ||
44 | DDX_Control(pDX, IDC_T42BELL_BROWSE, m_T42BellBrowseCtl); | ||
45 | DDX_Control(pDX, IDC_T42BELL, m_T42BellCtl); | ||
46 | DDX_CBString(pDX, IDC_T42BELL, m_T42Bell); | ||
47 | DDX_CBString(pDX, IDC_T42PROMPT, m_T42Prompt); | ||
48 | DDX_Check(pDX, IDC_T42PROMPT_LOOP, m_bT42PromptLoop); | ||
49 | DDX_CBString(pDX, IDC_T42WAKE, m_T42Wake); | ||
50 | //}}AFX_DATA_MAP | ||
51 | } | ||
52 | |||
53 | |||
54 | BEGIN_MESSAGE_MAP(CSoundsPage, CPropertyPage) | ||
55 | //{{AFX_MSG_MAP(CSoundsPage) | ||
56 | ON_BN_CLICKED(IDC_T42BELL_BROWSE, OnT42bellBrowse) | ||
57 | ON_BN_CLICKED(IDC_T42PROMPT_BROWSE, OnT42promptBrowse) | ||
58 | ON_BN_CLICKED(IDC_T42WAKE_BROWSE, OnT42wakeBrowse) | ||
59 | ON_BN_CLICKED(IDC_T42BELL_PLAY, OnT42bellPlay) | ||
60 | ON_BN_CLICKED(IDC_T42PROMPT_PLAY, OnT42promptPlay) | ||
61 | ON_BN_CLICKED(IDC_T42WAKE_PLAY, OnT42wakePlay) | ||
62 | //}}AFX_MSG_MAP | ||
63 | END_MESSAGE_MAP() | ||
64 | |||
65 | ///////////////////////////////////////////////////////////////////////////// | ||
66 | // CSoundsPage message handlers | ||
67 | |||
68 | BOOL CSoundsPage::OnInitDialog() | ||
69 | { | ||
70 | CPropertyPage::OnInitDialog(); | ||
71 | |||
72 | CT42App* app = (CT42App*)AfxGetApp(); | ||
73 | ASSERT(app); | ||
74 | m_T42BellCtl.ResetContent(); | ||
75 | m_T42BellCtl.AddString(app->m_sndTeaDrop); | ||
76 | m_T42PromptCtl.ResetContent(); | ||
77 | m_T42PromptCtl.AddString(app->m_sndBoilingTeapot); | ||
78 | m_T42WakeCtl.ResetContent(); | ||
79 | m_T42WakeCtl.AddString(app->m_sndTeapotWhistle); | ||
80 | |||
81 | HICON i = app->LoadIcon(IDI_BROWSE); | ||
82 | m_T42BellBrowseCtl.SetIcon(i); | ||
83 | m_T42PromptBrowseCtl.SetIcon(i); | ||
84 | m_T42WakeBrowseCtl.SetIcon(i); | ||
85 | i = app->LoadIcon(IDI_PREPLAY); | ||
86 | m_T42BellPlayCtl.SetIcon(i); | ||
87 | m_T42PromptPlayCtl.SetIcon(i); | ||
88 | m_T42WakePlayCtl.SetIcon(i); | ||
89 | |||
90 | UpdateData(FALSE); | ||
91 | |||
92 | return TRUE; // return TRUE unless you set the focus to a control | ||
93 | // EXCEPTION: OCX Property Pages should return FALSE | ||
94 | } | ||
95 | |||
96 | void CSoundsPage::OnT42bellBrowse() | ||
97 | { | ||
98 | BrowseForSound(m_T42BellCtl); | ||
99 | } | ||
100 | |||
101 | void CSoundsPage::OnT42promptBrowse() | ||
102 | { | ||
103 | BrowseForSound(m_T42PromptCtl); | ||
104 | } | ||
105 | |||
106 | void CSoundsPage::OnT42wakeBrowse() | ||
107 | { | ||
108 | BrowseForSound(m_T42WakeCtl); | ||
109 | } | ||
110 | |||
111 | void CSoundsPage::BrowseForSound(CComboBox& ctl) | ||
112 | { | ||
113 | CString f; | ||
114 | ctl.GetWindowText(f); | ||
115 | CString filter; | ||
116 | filter.LoadString(IDS_FILTER_WAV); | ||
117 | CFileDialog fd(TRUE,NULL,(LPCTSTR)f, | ||
118 | OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY | ||
119 | |OFN_LONGNAMES|OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST, | ||
120 | filter,this); | ||
121 | CString title; | ||
122 | title.LoadString(IDS_TITLE_WAV); | ||
123 | fd.m_ofn.lpstrTitle=(LPCTSTR)title; | ||
124 | if(fd.DoModal()==IDOK) | ||
125 | ctl.SetWindowText(fd.GetPathName()); | ||
126 | } | ||
127 | |||
128 | void CSoundsPage::OnT42bellPlay() | ||
129 | { | ||
130 | PlayIt(m_T42BellCtl); | ||
131 | } | ||
132 | void CSoundsPage::OnT42promptPlay() | ||
133 | { | ||
134 | PlayIt(m_T42PromptCtl); | ||
135 | } | ||
136 | void CSoundsPage::OnT42wakePlay() | ||
137 | { | ||
138 | PlayIt(m_T42WakeCtl); | ||
139 | } | ||
140 | |||
141 | void CSoundsPage::PlayIt(CComboBox& ctl,BOOL bLoop) | ||
142 | { | ||
143 | CString s; | ||
144 | ctl.GetWindowText(s); | ||
145 | CT42App* app = (CT42App*)AfxGetApp(); | ||
146 | ASSERT(app); | ||
147 | app->StartSound(s,bLoop); | ||
148 | } | ||
diff --git a/SoundsPage.h b/SoundsPage.h new file mode 100644 index 0000000..ea67fc3 --- a/dev/null +++ b/SoundsPage.h | |||
@@ -0,0 +1,58 @@ | |||
1 | // SoundsPage.h : header file | ||
2 | // | ||
3 | |||
4 | ///////////////////////////////////////////////////////////////////////////// | ||
5 | // CSoundsPage dialog | ||
6 | |||
7 | class CSoundsPage : public CPropertyPage | ||
8 | { | ||
9 | DECLARE_DYNCREATE(CSoundsPage) | ||
10 | |||
11 | // Construction | ||
12 | public: | ||
13 | void PlayIt(CComboBox& ctl,BOOL bLoop=FALSE); | ||
14 | void BrowseForSound(CComboBox& ctl); | ||
15 | CSoundsPage(); | ||
16 | ~CSoundsPage(); | ||
17 | |||
18 | // Dialog Data | ||
19 | //{{AFX_DATA(CSoundsPage) | ||
20 | enum { IDD = IDD_OPTIONS_SOUNDS }; | ||
21 | CButtonm_T42WakePlayCtl; | ||
22 | CButtonm_T42PromptPlayCtl; | ||
23 | CButtonm_T42BellPlayCtl; | ||
24 | CButtonm_T42WakeBrowseCtl; | ||
25 | CComboBoxm_T42WakeCtl; | ||
26 | CButtonm_T42PromptBrowseCtl; | ||
27 | CComboBoxm_T42PromptCtl; | ||
28 | CButtonm_T42BellBrowseCtl; | ||
29 | CComboBoxm_T42BellCtl; | ||
30 | CStringm_T42Bell; | ||
31 | CStringm_T42Prompt; | ||
32 | BOOLm_bT42PromptLoop; | ||
33 | CStringm_T42Wake; | ||
34 | //}}AFX_DATA | ||
35 | |||
36 | |||
37 | // Overrides | ||
38 | // ClassWizard generate virtual function overrides | ||
39 | //{{AFX_VIRTUAL(CSoundsPage) | ||
40 | protected: | ||
41 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support | ||
42 | //}}AFX_VIRTUAL | ||
43 | |||
44 | // Implementation | ||
45 | protected: | ||
46 | // Generated message map functions | ||
47 | //{{AFX_MSG(CSoundsPage) | ||
48 | virtual BOOL OnInitDialog(); | ||
49 | afx_msg void OnT42bellBrowse(); | ||
50 | afx_msg void OnT42promptBrowse(); | ||
51 | afx_msg void OnT42wakeBrowse(); | ||
52 | afx_msg void OnT42bellPlay(); | ||
53 | afx_msg void OnT42promptPlay(); | ||
54 | afx_msg void OnT42wakePlay(); | ||
55 | //}}AFX_MSG | ||
56 | DECLARE_MESSAGE_MAP() | ||
57 | |||
58 | }; | ||
@@ -0,0 +1,367 @@ | |||
1 | ; CLW file contains information for the MFC ClassWizard | ||
2 | |||
3 | [General Info] | ||
4 | Version=1 | ||
5 | LastClass=CT42Dlg | ||
6 | LastTemplate=CPropertyPage | ||
7 | NewFileInclude1=#include "stdafx.h" | ||
8 | NewFileInclude2=#include "T42.h" | ||
9 | |||
10 | ClassCount=16 | ||
11 | Class1=CT42App | ||
12 | Class2=CT42Dlg | ||
13 | Class3=CAboutDlg | ||
14 | |||
15 | ResourceCount=11 | ||
16 | Resource1=IDD_OPTIONS_FONTS | ||
17 | Resource2=IDM_POPUPS | ||
18 | Resource3=IDD_OPTIONS_SOUNDS | ||
19 | Class4=T42Frame | ||
20 | Class5=CCalleeDlg | ||
21 | Resource4=IDD_T42VIEW | ||
22 | Resource5=IDD_OPTIONS_GENERAL | ||
23 | Class6=T42View | ||
24 | Class7=T42Document | ||
25 | Class8=CSplitBar | ||
26 | Class9=CLocalCtl | ||
27 | Class10=CRemoteCtl | ||
28 | Resource6=IDD_REMOTE | ||
29 | Class11=T42AnnounceDlg | ||
30 | Resource7=IDD_OPTIONS_SECRETARY | ||
31 | Resource8=IDD_T42_DIALOG | ||
32 | Class12=CSoundsPage | ||
33 | Resource9=IDD_ANNOUNCE | ||
34 | Class13=CFontsPage | ||
35 | Class14=CColorButton | ||
36 | Class15=CSecretaryPage | ||
37 | Resource10=IDD_ABOUTBOX | ||
38 | Class16=CGeneralPage | ||
39 | Resource11=IDR_T42FRAME | ||
40 | |||
41 | [CLS:CT42App] | ||
42 | Type=0 | ||
43 | HeaderFile=T42.h | ||
44 | ImplementationFile=T42.cpp | ||
45 | Filter=N | ||
46 | LastObject=CT42App | ||
47 | |||
48 | [CLS:CT42Dlg] | ||
49 | Type=0 | ||
50 | HeaderFile=T42Dlg.h | ||
51 | ImplementationFile=T42Dlg.cpp | ||
52 | Filter=W | ||
53 | LastObject=CT42Dlg | ||
54 | BaseClass=CDialog | ||
55 | VirtualFilter=dWC | ||
56 | |||
57 | [CLS:CAboutDlg] | ||
58 | Type=0 | ||
59 | HeaderFile=T42Dlg.h | ||
60 | ImplementationFile=T42Dlg.cpp | ||
61 | Filter=D | ||
62 | BaseClass=CDialog | ||
63 | VirtualFilter=dWC | ||
64 | LastObject=IDC_KLEVERNET | ||
65 | |||
66 | [DLG:IDD_ABOUTBOX] | ||
67 | Type=1 | ||
68 | Class=CAboutDlg | ||
69 | ControlCount=6 | ||
70 | Control1=IDC_STATIC,static,1342308480 | ||
71 | Control2=IDC_STATIC,static,1342308352 | ||
72 | Control3=IDC_STATIC,static,1342177283 | ||
73 | Control4=IDC_STATIC,static,1342177283 | ||
74 | Control5=IDOK,button,1342373889 | ||
75 | Control6=IDC_KLEVERNET,button,1342242816 | ||
76 | |||
77 | [DLG:IDD_T42_DIALOG] | ||
78 | Type=1 | ||
79 | Class=CT42Dlg | ||
80 | ControlCount=12 | ||
81 | Control1=IDC_STATIC,static,1342308353 | ||
82 | Control2=IDC_ONCALL,combobox,1344339971 | ||
83 | Control3=IDC_STATIC,static,1342308353 | ||
84 | Control4=IDC_ONCALLAWAY,combobox,1344339971 | ||
85 | Control5=IDC_CALLS,SysListView32,1350631425 | ||
86 | Control6=IDC_PREVIEW,RICHEDIT,1344389508 | ||
87 | Control7=IDC_TALK,button,1342242816 | ||
88 | Control8=IDC_OPTIONS,button,1342242816 | ||
89 | Control9=IDOK,button,1342242816 | ||
90 | Control10=ID_HELP,button,1342242816 | ||
91 | Control11=IDCANCEL,button,1073807361 | ||
92 | Control12=IDC_AWAY,button,1342255107 | ||
93 | |||
94 | [CLS:T42Frame] | ||
95 | Type=0 | ||
96 | HeaderFile=T42Frame.h | ||
97 | ImplementationFile=T42Frame.cpp | ||
98 | BaseClass=CFrameWnd | ||
99 | Filter=W | ||
100 | LastObject=ID_CALLLOG_CALLBACK | ||
101 | VirtualFilter=fWC | ||
102 | |||
103 | [MNU:IDR_T42FRAME] | ||
104 | Type=1 | ||
105 | Class=? | ||
106 | Command1=ID_TALK_REMOTEUSER | ||
107 | Command2=ID_TALK_ABORT | ||
108 | Command3=ID_TALK_RECONNECT | ||
109 | Command4=ID_TEA_SAVE | ||
110 | Command5=ID_TALK_CLOSE | ||
111 | Command6=ID_EDIT_COPY | ||
112 | Command7=ID_EDIT_PASTE | ||
113 | Command8=ID_SLEEP_SLEEP | ||
114 | Command9=ID_SLEEP_SLEEPONMINIMIZE | ||
115 | Command10=ID_SLEEP_MINIMIZEONSLEEP | ||
116 | Command11=ID_SLEEP_WAKEUPACTION_MAKESOUND | ||
117 | Command12=ID_SLEEP_WAKEUPACTION_POPUP | ||
118 | Command13=ID_WINDOW_SPLITEQUALLY | ||
119 | Command14=ID_WINDOW_SAVELAYOUT | ||
120 | Command15=ID_WINDOW_AUTOSAVELAYOUT | ||
121 | Command16=ID_WINDOW_HORIZONTALSPLIT | ||
122 | Command17=ID_WINDOW_VERTICALSPLIT | ||
123 | Command18=ID_WINDOW_HIDEINTRAYONMINIMIZE | ||
124 | CommandCount=18 | ||
125 | |||
126 | [DLG:IDD_REMOTE] | ||
127 | Type=1 | ||
128 | Class=CCalleeDlg | ||
129 | ControlCount=9 | ||
130 | Control1=IDC_STATIC,static,1342308352 | ||
131 | Control2=IDC_CALLEE,combobox,1344340034 | ||
132 | Control3=IDC_STATIC,static,1342308352 | ||
133 | Control4=IDC_TTY,combobox,1344340034 | ||
134 | Control5=IDC_STATIC,static,1342308352 | ||
135 | Control6=IDC_STATIC,static,1342308352 | ||
136 | Control7=IDC_CALLER,combobox,1344340034 | ||
137 | Control8=IDOK,button,1342242817 | ||
138 | Control9=IDCANCEL,button,1342242816 | ||
139 | |||
140 | [CLS:CCalleeDlg] | ||
141 | Type=0 | ||
142 | HeaderFile=CalleeDlg.h | ||
143 | ImplementationFile=CalleeDlg.cpp | ||
144 | BaseClass=CDialog | ||
145 | Filter=D | ||
146 | LastObject=CCalleeDlg | ||
147 | VirtualFilter=dWC | ||
148 | |||
149 | [DLG:IDD_T42VIEW] | ||
150 | Type=1 | ||
151 | Class=T42View | ||
152 | ControlCount=1 | ||
153 | Control1=IDC_SPLIT,static,1342177547 | ||
154 | |||
155 | [CLS:T42View] | ||
156 | Type=0 | ||
157 | HeaderFile=T42View.h | ||
158 | ImplementationFile=T42View.cpp | ||
159 | BaseClass=CFormView | ||
160 | Filter=W | ||
161 | LastObject=ID_CALLLOG_CALLBACK | ||
162 | VirtualFilter=VWC | ||
163 | |||
164 | [CLS:T42Document] | ||
165 | Type=0 | ||
166 | HeaderFile=T42Document.h | ||
167 | ImplementationFile=T42Document.cpp | ||
168 | BaseClass=CDocument | ||
169 | Filter=N | ||
170 | VirtualFilter=DC | ||
171 | LastObject=ID_WINDOW_AUTOSAVELAYOUT | ||
172 | |||
173 | [CLS:CSplitBar] | ||
174 | Type=0 | ||
175 | HeaderFile=t42view.h | ||
176 | ImplementationFile=t42view.cpp | ||
177 | BaseClass=CStatic | ||
178 | Filter=W | ||
179 | LastObject=CSplitBar | ||
180 | VirtualFilter=WC | ||
181 | |||
182 | [CLS:CLocalCtl] | ||
183 | Type=0 | ||
184 | HeaderFile=t42view.h | ||
185 | ImplementationFile=t42view.cpp | ||
186 | BaseClass=CRichTalkCtl | ||
187 | Filter=W | ||
188 | LastObject=CLocalCtl | ||
189 | VirtualFilter=WC | ||
190 | |||
191 | [CLS:CRemoteCtl] | ||
192 | Type=0 | ||
193 | HeaderFile=t42view.h | ||
194 | ImplementationFile=t42view.cpp | ||
195 | BaseClass=CRichTalkCtl | ||
196 | Filter=W | ||
197 | LastObject=CRemoteCtl | ||
198 | VirtualFilter=WC | ||
199 | |||
200 | [ACL:IDR_T42FRAME] | ||
201 | Type=1 | ||
202 | Class=? | ||
203 | Command1=ID_EDIT_COPY | ||
204 | Command2=ID_SLEEP_SLEEP | ||
205 | Command3=ID_EDIT_PASTE | ||
206 | Command4=ID_EDIT_COPY | ||
207 | Command5=ID_EDIT_PASTE | ||
208 | CommandCount=5 | ||
209 | |||
210 | [DLG:IDD_ANNOUNCE] | ||
211 | Type=1 | ||
212 | Class=T42AnnounceDlg | ||
213 | ControlCount=11 | ||
214 | Control1=IDOK,button,1342242817 | ||
215 | Control2=IDC_SECRETARY,button,1342251008 | ||
216 | Control3=IDCANCEL,button,1342242816 | ||
217 | Control4=IDC_STATIC,static,1342308352 | ||
218 | Control5=IDC_CALLEE,static,1342308480 | ||
219 | Control6=IDC_TTY,static,1342308354 | ||
220 | Control7=IDC_STATIC,static,1342308352 | ||
221 | Control8=IDC_STATIC,static,1342308352 | ||
222 | Control9=IDC_CALLER,static,1342308482 | ||
223 | Control10=IDC_NOTHERE,button,1073741824 | ||
224 | Control11=IDC_REFUSE,button,1073741824 | ||
225 | |||
226 | [CLS:T42AnnounceDlg] | ||
227 | Type=0 | ||
228 | HeaderFile=T42AnnounceDlg.h | ||
229 | ImplementationFile=T42AnnounceDlg.cpp | ||
230 | BaseClass=CDialog | ||
231 | Filter=D | ||
232 | LastObject=IDC_CALLEE | ||
233 | VirtualFilter=dWC | ||
234 | |||
235 | [MNU:IDM_POPUPS] | ||
236 | Type=1 | ||
237 | Class=CT42Dlg | ||
238 | Command1=ID_TRAY_T42 | ||
239 | Command2=ID_TRAY_AWAY | ||
240 | Command3=ID_TRAY_SHOWMAINWINDOW | ||
241 | Command4=ID_TRAY_OPTIONS | ||
242 | Command5=ID_TRAY_EXIT | ||
243 | Command6=ID_CALLLOG_CALLBACK | ||
244 | Command7=ID_CALLLOG_DELETE | ||
245 | Command8=ID_CALLLOG_SAVETOFILE | ||
246 | Command9=ID_CALLLOG_MARKASNEW | ||
247 | Command10=ID_CALLLOG_MARKASPROCESSED | ||
248 | Command11=ID_CALLLOG_EMPTYLOG | ||
249 | CommandCount=11 | ||
250 | |||
251 | [DLG:IDD_OPTIONS_SOUNDS] | ||
252 | Type=1 | ||
253 | Class=CSoundsPage | ||
254 | ControlCount=16 | ||
255 | Control1=IDC_STATIC,static,1342308352 | ||
256 | Control2=IDC_T42BELL,combobox,1344340290 | ||
257 | Control3=IDC_T42BELL_BROWSE,button,1342246720 | ||
258 | Control4=IDC_STATIC,static,1342177296 | ||
259 | Control5=IDC_STATIC,static,1342308352 | ||
260 | Control6=IDC_T42PROMPT,combobox,1344340290 | ||
261 | Control7=IDC_T42PROMPT_BROWSE,button,1342246720 | ||
262 | Control8=IDC_T42PROMPT_LOOP,button,1342242819 | ||
263 | Control9=IDC_STATIC,static,1342177296 | ||
264 | Control10=IDC_STATIC,static,1342308352 | ||
265 | Control11=IDC_T42WAKE,combobox,1344340290 | ||
266 | Control12=IDC_T42WAKE_BROWSE,button,1342246720 | ||
267 | Control13=IDC_STATIC,static,1342177296 | ||
268 | Control14=IDC_T42BELL_PLAY,button,1342246720 | ||
269 | Control15=IDC_T42PROMPT_PLAY,button,1342246720 | ||
270 | Control16=IDC_T42WAKE_PLAY,button,1342246720 | ||
271 | |||
272 | [CLS:CSoundsPage] | ||
273 | Type=0 | ||
274 | HeaderFile=SoundsPage.h | ||
275 | ImplementationFile=SoundsPage.cpp | ||
276 | BaseClass=CPropertyPage | ||
277 | Filter=D | ||
278 | VirtualFilter=idWC | ||
279 | LastObject=CSoundsPage | ||
280 | |||
281 | [DLG:IDD_OPTIONS_FONTS] | ||
282 | Type=1 | ||
283 | Class=CFontsPage | ||
284 | ControlCount=16 | ||
285 | Control1=IDC_STATIC,static,1342308352 | ||
286 | Control2=IDC_FORMATNAME,listbox,1352728833 | ||
287 | Control3=IDC_STATIC,static,1342308352 | ||
288 | Control4=IDC_FACES,combobox,1344340227 | ||
289 | Control5=IDC_STATIC,static,1342308352 | ||
290 | Control6=IDC_FONTSIZE,combobox,1344340034 | ||
291 | Control7=IDC_BOLD,button,1342242819 | ||
292 | Control8=IDC_ITALIC,button,1342242819 | ||
293 | Control9=IDC_UNDERLINE,button,1342242819 | ||
294 | Control10=IDC_STRIKEOUT,button,1342242819 | ||
295 | Control11=IDC_CHARSET,combobox,1344340227 | ||
296 | Control12=IDC_FORECOLOR,button,1342242827 | ||
297 | Control13=IDC_BACKCOLOR,button,1342242827 | ||
298 | Control14=IDC_SAMPLE,RICHEDIT,1476510084 | ||
299 | Control15=IDC_STATIC,static,1342177296 | ||
300 | Control16=IDC_TIP,static,1342308352 | ||
301 | |||
302 | [CLS:CFontsPage] | ||
303 | Type=0 | ||
304 | HeaderFile=FontsPage.h | ||
305 | ImplementationFile=FontsPage.cpp | ||
306 | BaseClass=CPropertyPage | ||
307 | Filter=D | ||
308 | LastObject=CFontsPage | ||
309 | VirtualFilter=idWC | ||
310 | |||
311 | [CLS:CColorButton] | ||
312 | Type=0 | ||
313 | HeaderFile=ColorButton.h | ||
314 | ImplementationFile=ColorButton.cpp | ||
315 | BaseClass=CButton | ||
316 | Filter=W | ||
317 | LastObject=CColorButton | ||
318 | VirtualFilter=BWC | ||
319 | |||
320 | [DLG:IDD_OPTIONS_SECRETARY] | ||
321 | Type=1 | ||
322 | Class=CSecretaryPage | ||
323 | ControlCount=16 | ||
324 | Control1=IDC_STATIC,static,1342308352 | ||
325 | Control2=IDC_GREETING,edit,1352732868 | ||
326 | Control3=IDC_STATIC,static,1342308352 | ||
327 | Control4=IDC_DOBYTELIMIT,button,1342242819 | ||
328 | Control5=IDC_STATIC,static,1342308352 | ||
329 | Control6=IDC_BYTELIMIT,edit,1350639744 | ||
330 | Control7=IDC_CHARSPIN,msctls_updown32,1342177463 | ||
331 | Control8=IDC_DOTIMELIMIT,button,1342242819 | ||
332 | Control9=IDC_STATIC,static,1342308352 | ||
333 | Control10=IDC_TIMELIMIT,edit,1350639744 | ||
334 | Control11=IDC_TIMESPIN,msctls_updown32,1342177463 | ||
335 | Control12=IDC_DOWINLIMIT,button,1342242819 | ||
336 | Control13=IDC_STATIC,static,1342308352 | ||
337 | Control14=IDC_WINLIMIT,edit,1350639744 | ||
338 | Control15=IDC_WINSPIN,msctls_updown32,1342177463 | ||
339 | Control16=IDC_STATIC,static,1342177296 | ||
340 | |||
341 | [CLS:CSecretaryPage] | ||
342 | Type=0 | ||
343 | HeaderFile=SecretaryPage.h | ||
344 | ImplementationFile=SecretaryPage.cpp | ||
345 | BaseClass=CPropertyPage | ||
346 | Filter=D | ||
347 | LastObject=CSecretaryPage | ||
348 | VirtualFilter=idWC | ||
349 | |||
350 | [DLG:IDD_OPTIONS_GENERAL] | ||
351 | Type=1 | ||
352 | Class=CGeneralPage | ||
353 | ControlCount=4 | ||
354 | Control1=IDC_STATIC,static,1342308352 | ||
355 | Control2=IDC_NTALKPORT,edit,1350631568 | ||
356 | Control3=IDC_NTALKPORTSPIN,msctls_updown32,1342177332 | ||
357 | Control4=IDC_STATIC,static,1342308352 | ||
358 | |||
359 | [CLS:CGeneralPage] | ||
360 | Type=0 | ||
361 | HeaderFile=GeneralPage.h | ||
362 | ImplementationFile=GeneralPage.cpp | ||
363 | BaseClass=CPropertyPage | ||
364 | Filter=D | ||
365 | LastObject=IDC_NTALKPORTSPIN | ||
366 | VirtualFilter=idWC | ||
367 | |||
@@ -0,0 +1,468 @@ | |||
1 | // T42.cpp : Defines the class behaviors for the application. | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "T42Dlg.h" | ||
7 | |||
8 | #include "T42Frame.h" | ||
9 | #include "T42Document.h" | ||
10 | #include "T42View.h" | ||
11 | |||
12 | #include "SoundsPage.h" | ||
13 | #include "FontsPage.h" | ||
14 | #include "SecretaryPage.h" | ||
15 | #include "GeneralPage.h" | ||
16 | |||
17 | #ifdef _DEBUG | ||
18 | #define new DEBUG_NEW | ||
19 | #undef THIS_FILE | ||
20 | static char THIS_FILE[] = __FILE__; | ||
21 | #endif | ||
22 | |||
23 | ///////////////////////////////////////////////////////////////////////////// | ||
24 | // CT42App | ||
25 | |||
26 | BEGIN_MESSAGE_MAP(CT42App, CWinApp) | ||
27 | //{{AFX_MSG_MAP(CT42App) | ||
28 | //}}AFX_MSG | ||
29 | ON_COMMAND(ID_HELP, CWinApp::OnHelp) | ||
30 | END_MESSAGE_MAP() | ||
31 | |||
32 | ///////////////////////////////////////////////////////////////////////////// | ||
33 | // CT42App construction | ||
34 | |||
35 | CT42App::CT42App() | ||
36 | : m_T42STimeLimit(0,0,2,0), | ||
37 | m_T42SBytesLimit(2048), | ||
38 | m_T42SWinLimit(10) | ||
39 | { | ||
40 | m_maxT42Callees = 20; | ||
41 | m_maxT42Callers = 20; | ||
42 | m_bt42AutosaveLayout = FALSE; | ||
43 | m_nT42Calls = m_t42Call = -1; | ||
44 | m_pT42Dlg = NULL; | ||
45 | memset(&m_fmtT42Local,0,sizeof(m_fmtT42Local)); | ||
46 | memset(&m_fmtT42Remote,0,sizeof(m_fmtT42Remote)); | ||
47 | memset(&m_fmtT42System,0,sizeof(m_fmtT42System)); | ||
48 | m_crT42LocalBG=RGB(255,255,255); | ||
49 | m_crT42RemoteBG=RGB(255,255,192); | ||
50 | m_bAwayOnScreenSaver = TRUE; | ||
51 | m_T42LinesBusy = 0; | ||
52 | } | ||
53 | |||
54 | ///////////////////////////////////////////////////////////////////////////// | ||
55 | // The one and only CT42App object | ||
56 | |||
57 | CT42App theApp; | ||
58 | |||
59 | ///////////////////////////////////////////////////////////////////////////// | ||
60 | // CT42App initialization | ||
61 | |||
62 | BOOL CT42App::InitInstance() | ||
63 | { | ||
64 | if (!AfxSocketInit()) | ||
65 | { | ||
66 | AfxMessageBox(IDP_SOCKETS_INIT_FAILED); | ||
67 | return FALSE; | ||
68 | } | ||
69 | |||
70 | // Standard initialization | ||
71 | // If you are not using these features and wish to reduce the size | ||
72 | // of your final executable, you should remove from the following | ||
73 | // the specific initialization routines you do not need. | ||
74 | |||
75 | #ifdef _AFXDLL | ||
76 | Enable3dControls(); // Call this when using MFC in a shared DLL | ||
77 | #else | ||
78 | Enable3dControlsStatic();// Call this when linking to MFC statically | ||
79 | #endif | ||
80 | |||
81 | SetRegistryKey(IDS_REGISTRYKEY); | ||
82 | m_HelpFile = m_pszHelpFilePath; | ||
83 | m_HelpFile+=">Standard"; | ||
84 | m_pszHelpFilePath=(LPCTSTR)m_HelpFile; | ||
85 | |||
86 | m_pTemplate = new CMultiDocTemplate(IDR_T42FRAME, | ||
87 | RUNTIME_CLASS(T42Document), | ||
88 | RUNTIME_CLASS(T42Frame), | ||
89 | RUNTIME_CLASS(T42View) | ||
90 | ); | ||
91 | AddDocTemplate(m_pTemplate); | ||
92 | |||
93 | Initialize(); | ||
94 | LoadSettings(); | ||
95 | |||
96 | if(!OpenT42CallsLog()){ | ||
97 | AfxMessageBox(IDS_CALLOG_OPEN_FAILED,MB_OK|MB_ICONSTOP); | ||
98 | return FALSE; | ||
99 | } | ||
100 | |||
101 | CT42Dlg dlg; | ||
102 | m_pMainWnd = &dlg; | ||
103 | m_pT42Dlg = &dlg; | ||
104 | dlg.DoModal(); | ||
105 | m_pT42Dlg = NULL; | ||
106 | |||
107 | SaveSettings(); | ||
108 | |||
109 | if(!CloseT42CallsLog()) | ||
110 | AfxMessageBox(IDS_CALLOG_CLOSE_FAILED,MB_OK|MB_ICONSTOP); | ||
111 | |||
112 | |||
113 | // Since the dialog has been closed, return FALSE so that we exit the | ||
114 | // application, rather than start the application's message pump. | ||
115 | return FALSE; | ||
116 | } | ||
117 | |||
118 | BOOL CT42App::LastCallee(LPCTSTR callee) | ||
119 | { | ||
120 | POSITION p = m_t42Callees.Find(callee); | ||
121 | if(p){ | ||
122 | m_t42Callees.RemoveAt(p); | ||
123 | m_t42Callees.AddHead(callee); | ||
124 | return FALSE; | ||
125 | } | ||
126 | m_t42Callees.AddHead(callee); | ||
127 | while(m_t42Callees.GetCount()>m_maxT42Callees) | ||
128 | m_t42Callees.RemoveTail(); | ||
129 | return TRUE; | ||
130 | } | ||
131 | |||
132 | void CT42App::SaveSettings() | ||
133 | { | ||
134 | WriteProfileInt("Settings","AwayOnScreenSaver",m_bAwayOnScreenSaver); | ||
135 | |||
136 | Klever::SaveStringList(m_t42Callees,"T42HotList"); | ||
137 | Klever::SaveStringList(m_t42Callers,"T42Callers"); | ||
138 | WriteProfileInt("T42Window","AutosaveLayout",m_bt42AutosaveLayout); | ||
139 | WriteProfileInt("Settings","T42MaxCallers",m_maxT42Callers); | ||
140 | WriteProfileInt("Settings","T42MaxCallees",m_maxT42Callees); | ||
141 | WriteProfileString("Settings","T42CallsLog",m_t42CallsFile); | ||
142 | WriteProfileInt("Settings","T42TalkPort",m_T42TalkPort); | ||
143 | |||
144 | WriteProfileString("Sounds","T42Bell",m_sndT42Bell); | ||
145 | WriteProfileString("Sounds","T42Prompt",m_sndT42Prompt); | ||
146 | WriteProfileInt("Sounds","T42PromptLoop",m_bT42PromptLoop); | ||
147 | WriteProfileString("Sounds","T42Wake",m_sndT42Wake); | ||
148 | |||
149 | Klever::WriteProfileString("Secretary","T42Greeting",m_T42SGreeting); | ||
150 | WriteProfileInt("Secretary","T42BytesLimit",m_T42SBytesLimit); | ||
151 | WriteProfileInt("Secretary","T42TimeLimit",m_T42STimeLimit.GetTotalSeconds()); | ||
152 | WriteProfileInt("Secretary","T42WinLimit",m_T42SWinLimit); | ||
153 | |||
154 | WriteProfileInt("Fonts","T42LocalBG",m_crT42LocalBG); | ||
155 | WriteProfileInt("Fonts","T42RemoteBG",m_crT42RemoteBG); | ||
156 | WriteProfileBinary("Fonts","T42Local",(LPBYTE)&m_fmtT42Local,sizeof(m_fmtT42Local)); | ||
157 | WriteProfileBinary("Fonts","T42Remote",(LPBYTE)&m_fmtT42Remote,sizeof(m_fmtT42Remote)); | ||
158 | WriteProfileBinary("Fonts","T42System",(LPBYTE)&m_fmtT42System,sizeof(m_fmtT42System)); | ||
159 | |||
160 | FlushT42CallsLog(); | ||
161 | } | ||
162 | |||
163 | void CT42App::LoadSettings() | ||
164 | { | ||
165 | m_bAwayOnScreenSaver = GetProfileInt("Settings","AwayOnScreenSaver",m_bAwayOnScreenSaver); | ||
166 | |||
167 | Klever::LoadStringList(m_t42Callees,"T42HotList"); | ||
168 | Klever::LoadStringList(m_t42Callers,"T42Callers"); | ||
169 | m_bt42AutosaveLayout = GetProfileInt("T42Window","AutosaveLayout",m_bt42AutosaveLayout); | ||
170 | m_maxT42Callers = GetProfileInt("Settings","T42MaxCallers",m_maxT42Callers); | ||
171 | m_maxT42Callees = GetProfileInt("Settings","T42MaxCallees",m_maxT42Callees); | ||
172 | m_t42CallsFile = GetProfileString("Settings","T42CallsLog",m_t42CallsFile); | ||
173 | m_T42TalkPort = GetProfileInt("Settings","T42TalkPort",m_T42TalkPort); | ||
174 | |||
175 | m_sndT42Bell = GetProfileString("Sounds","T42Bell",m_sndT42Bell); | ||
176 | m_sndT42Prompt = GetProfileString("Sounds","T42Prompt",m_sndT42Prompt); | ||
177 | m_bT42PromptLoop = GetProfileInt("Sounds","T42PromptLoop",m_bT42PromptLoop); | ||
178 | m_sndT42Wake = GetProfileString("Sounds","T42Wake",m_sndT42Wake); | ||
179 | |||
180 | m_T42SGreeting = Klever::GetProfileString("Secretary","T42Greeting",m_T42SGreeting); | ||
181 | m_T42SBytesLimit = GetProfileInt("Secretary","T42BytesLimit",m_T42SBytesLimit); | ||
182 | m_T42STimeLimit = CTimeSpan(GetProfileInt("Secretary","T42TimeLimit",m_T42STimeLimit.GetTotalSeconds())); | ||
183 | m_T42SWinLimit = GetProfileInt("Secretary","T42WinLimit",m_T42SWinLimit); | ||
184 | |||
185 | m_crT42LocalBG = GetProfileInt("Fonts","T42LocalBG",m_crT42LocalBG); | ||
186 | m_crT42RemoteBG = GetProfileInt("Fonts","T42RemoteBG",m_crT42RemoteBG); | ||
187 | LPBYTE pdata; | ||
188 | UINT pbytes; | ||
189 | if(GetProfileBinary("Fonts","T42Local",&pdata,&pbytes)){ | ||
190 | if(pbytes==sizeof(m_fmtT42Local)) | ||
191 | memmove(&m_fmtT42Local,pdata,sizeof(m_fmtT42Local)); | ||
192 | delete pdata; | ||
193 | } | ||
194 | if(GetProfileBinary("Fonts","T42Remote",&pdata,&pbytes)){ | ||
195 | if(pbytes==sizeof(m_fmtT42Remote)) | ||
196 | memmove(&m_fmtT42Remote,pdata,sizeof(m_fmtT42Remote)); | ||
197 | delete pdata; | ||
198 | } | ||
199 | if(GetProfileBinary("Fonts","T42System",&pdata,&pbytes)){ | ||
200 | if(pbytes==sizeof(m_fmtT42System)) | ||
201 | memmove(&m_fmtT42System,pdata,sizeof(m_fmtT42System)); | ||
202 | delete pdata; | ||
203 | } | ||
204 | } | ||
205 | |||
206 | BOOL CT42App::LastCaller(LPCTSTR caller) | ||
207 | { | ||
208 | POSITION p = m_t42Callers.Find(caller); | ||
209 | if(p){ | ||
210 | m_t42Callers.RemoveAt(p); | ||
211 | m_t42Callers.AddHead(caller); | ||
212 | return FALSE; | ||
213 | } | ||
214 | m_t42Callers.AddHead(caller); | ||
215 | while(m_t42Callers.GetCount()>m_maxT42Callers) | ||
216 | m_t42Callers.RemoveTail(); | ||
217 | return TRUE; | ||
218 | } | ||
219 | |||
220 | void CT42App::Initialize() | ||
221 | { | ||
222 | VERIFY(m_T42SGreeting.LoadString(IDS_DEFAULTGREETING)); | ||
223 | |||
224 | VERIFY( | ||
225 | m_sndTeaDrop.LoadString(IDS_SND_TEADROP) | ||
226 | && m_sndBoilingTeapot.LoadString(IDS_SND_BOILINGTEAPOT) | ||
227 | && m_sndTeapotWhistle.LoadString(IDS_SND_TEAPOTWHISTLE) | ||
228 | ); | ||
229 | |||
230 | m_sndT42Bell = m_sndTeaDrop; | ||
231 | m_sndT42Prompt = m_sndBoilingTeapot; | ||
232 | m_bT42PromptLoop = TRUE; | ||
233 | m_sndT42Wake = m_sndTeapotWhistle; | ||
234 | |||
235 | VERIFY(m_t42CallsFile.LoadString(IDS_FILE_T42CALLS)); | ||
236 | CString exepa; | ||
237 | VERIFY(GetModuleFileName(m_hInstance,exepa.GetBuffer(_MAX_PATH),_MAX_PATH)); | ||
238 | exepa.ReleaseBuffer(); | ||
239 | int bs = exepa.ReverseFind('\\'); | ||
240 | VERIFY(bs>=0); | ||
241 | exepa = exepa.Left(bs); | ||
242 | m_t42CallsFile = Klever::GluePathAndFile(exepa,m_t42CallsFile); | ||
243 | |||
244 | servent* se = getservbyname("ntalk","udp"); | ||
245 | if(se) | ||
246 | m_T42TalkPort = ntohs(se->s_port); | ||
247 | else | ||
248 | m_T42TalkPort = 518; | ||
249 | } | ||
250 | |||
251 | BOOL CT42App::StartSound(LPCTSTR snd,BOOL bLoop) | ||
252 | { | ||
253 | // Return TRUE if looped sound started. | ||
254 | LPCSTR s = snd; | ||
255 | UINT flags = SND_ASYNC|SND_NODEFAULT|SND_NOWAIT|SND_RESOURCE; | ||
256 | if(!m_sndTeaDrop.Compare(s)){ | ||
257 | s = MAKEINTRESOURCE(IDW_BEEP_DROP); | ||
258 | }else if(!m_sndBoilingTeapot.Compare(s)){ | ||
259 | s = MAKEINTRESOURCE(IDW_ANNOUNCE_BOILING); | ||
260 | }else if(!m_sndTeapotWhistle.Compare(s)){ | ||
261 | s = MAKEINTRESOURCE(IDW_WAKE_WHISTLE); | ||
262 | }else{ | ||
263 | flags&=~SND_RESOURCE; | ||
264 | flags|=SND_FILENAME; | ||
265 | } | ||
266 | if(bLoop) | ||
267 | flags|=SND_LOOP; | ||
268 | if(PlaySound(s,AfxGetInstanceHandle(),flags)) | ||
269 | return bLoop; | ||
270 | MessageBeep(0xFFFFFFFF); | ||
271 | return FALSE; | ||
272 | } | ||
273 | |||
274 | void CT42App::StopSound(LPCTSTR snd) | ||
275 | { | ||
276 | LPCSTR s = snd; | ||
277 | UINT flags = SND_ASYNC|SND_NODEFAULT|SND_NOWAIT|SND_RESOURCE|SND_PURGE; | ||
278 | if(!m_sndTeaDrop.Compare(s)){ | ||
279 | s = MAKEINTRESOURCE(IDW_BEEP_DROP); | ||
280 | }else if(!m_sndBoilingTeapot.Compare(s)){ | ||
281 | s = MAKEINTRESOURCE(IDW_ANNOUNCE_BOILING); | ||
282 | }else if(!m_sndTeapotWhistle.Compare(s)){ | ||
283 | s = MAKEINTRESOURCE(IDW_WAKE_WHISTLE); | ||
284 | }else{ | ||
285 | flags&=~SND_RESOURCE; | ||
286 | flags|=SND_FILENAME; | ||
287 | } | ||
288 | PlaySound(s,AfxGetInstanceHandle(),flags); | ||
289 | } | ||
290 | |||
291 | void CT42App::Options(CWnd* pParent) | ||
292 | { | ||
293 | CSoundsPage sp; | ||
294 | CFontsPage fp; | ||
295 | CSecretaryPage sep; | ||
296 | CGeneralPage gp; | ||
297 | CPropertySheet ps(IDS_TITLE_OPTIONS,pParent); | ||
298 | ps.AddPage(&gp); | ||
299 | ps.AddPage(&fp); | ||
300 | ps.AddPage(&sp); | ||
301 | ps.AddPage(&sep); | ||
302 | |||
303 | gp.m_ntalkPort = m_T42TalkPort; | ||
304 | |||
305 | sp.m_T42Bell = m_sndT42Bell; | ||
306 | sp.m_T42Prompt = m_sndT42Prompt; | ||
307 | sp.m_bT42PromptLoop = m_bT42PromptLoop; | ||
308 | sp.m_T42Wake = m_sndT42Wake; | ||
309 | |||
310 | memmove(&fp.m_fmtT42Local.m_fmtChar,&m_fmtT42Local,sizeof(fp.m_fmtT42Local.m_fmtChar)); | ||
311 | memmove(&fp.m_fmtT42Remote.m_fmtChar,&m_fmtT42Remote,sizeof(fp.m_fmtT42Remote.m_fmtChar)); | ||
312 | memmove(&fp.m_fmtT42System.m_fmtChar,&m_fmtT42System,sizeof(fp.m_fmtT42System.m_fmtChar)); | ||
313 | fp.m_fmtT42Local.m_bgColor=m_crT42LocalBG; | ||
314 | fp.m_fmtT42Remote.m_bgColor=m_crT42RemoteBG; | ||
315 | |||
316 | sep.m_bLimitTime = m_T42STimeLimit.GetTotalSeconds()?TRUE:FALSE; | ||
317 | sep.m_limitTime = m_T42STimeLimit.GetTotalSeconds()/60; | ||
318 | sep.m_bLimitBytes = m_T42SBytesLimit?TRUE:FALSE; | ||
319 | sep.m_limitBytes = m_T42SBytesLimit; | ||
320 | sep.m_Greeting = m_T42SGreeting; | ||
321 | sep.m_limitWin = m_T42SWinLimit; | ||
322 | sep.m_bLimitWin = m_T42SWinLimit?TRUE:FALSE; | ||
323 | |||
324 | if(ps.DoModal()==IDOK){ | ||
325 | m_T42TalkPort = gp.m_ntalkPort; | ||
326 | |||
327 | m_sndT42Bell = sp.m_T42Bell; | ||
328 | m_sndT42Prompt = sp.m_T42Prompt; | ||
329 | m_bT42PromptLoop = sp.m_bT42PromptLoop; | ||
330 | m_sndT42Wake = sp.m_T42Wake; | ||
331 | |||
332 | memmove(&m_fmtT42Local,&fp.m_fmtT42Local.m_fmtChar,sizeof(m_fmtT42Local)); | ||
333 | memmove(&m_fmtT42Remote,&fp.m_fmtT42Remote.m_fmtChar,sizeof(m_fmtT42Remote)); | ||
334 | memmove(&m_fmtT42System,&fp.m_fmtT42System.m_fmtChar,sizeof(m_fmtT42System)); | ||
335 | m_crT42LocalBG=fp.m_fmtT42Local.m_bgColor; | ||
336 | m_crT42RemoteBG=fp.m_fmtT42Remote.m_bgColor; | ||
337 | |||
338 | m_T42STimeLimit = CTimeSpan(sep.m_bLimitTime?sep.m_limitTime*60:0); | ||
339 | m_T42SBytesLimit = sep.m_bLimitBytes?sep.m_limitBytes:0; | ||
340 | m_T42SWinLimit = sep.m_bLimitWin?sep.m_limitWin:0; | ||
341 | m_T42SGreeting = sep.m_Greeting; | ||
342 | } | ||
343 | } | ||
344 | |||
345 | BOOL CT42App::OpenT42CallsLog() | ||
346 | { | ||
347 | if(!m_T42Calls.Open(m_t42CallsFile,FALSE)){ | ||
348 | if(!m_T42Calls.Create(m_t42CallsFile)) | ||
349 | return FALSE; | ||
350 | FlushT42CallsLog(); | ||
351 | } | ||
352 | return TRUE; | ||
353 | } | ||
354 | |||
355 | BOOL CT42App::CloseT42CallsLog() | ||
356 | { | ||
357 | return m_T42Calls.Close(); | ||
358 | } | ||
359 | |||
360 | LONG CT42App::GetT42Calls() | ||
361 | { | ||
362 | if(m_nT42Calls<0){ | ||
363 | m_nT42Calls=0; | ||
364 | m_t42Call = -1; | ||
365 | if(!m_T42Calls.GoFirst()) | ||
366 | return 0; | ||
367 | m_nT42Calls++; | ||
368 | while(m_T42Calls.GoNext()) | ||
369 | m_nT42Calls++; | ||
370 | } | ||
371 | return m_nT42Calls; | ||
372 | } | ||
373 | |||
374 | BOOL CT42App::GetT42Call(LONG call,CT42CallLogEntry& entry) | ||
375 | { | ||
376 | LONG calls = GetT42Calls(); | ||
377 | if(calls<=0) | ||
378 | return FALSE; | ||
379 | call = calls-call-1; | ||
380 | if(call<0 || calls<=call) | ||
381 | return FALSE; | ||
382 | if(m_t42Call<0){ | ||
383 | if(call<(calls/2)){ | ||
384 | VERIFY(m_T42Calls.GoFirst()); | ||
385 | m_t42Call=0; | ||
386 | }else{ | ||
387 | VERIFY(m_T42Calls.GoLast()); | ||
388 | m_t42Call=calls-1; | ||
389 | } | ||
390 | } | ||
391 | if(call<m_t42Call){ | ||
392 | while(call<m_t42Call){ | ||
393 | VERIFY(m_T42Calls.GoPrev()); | ||
394 | m_t42Call--; | ||
395 | } | ||
396 | }else if(call>m_t42Call){ | ||
397 | while(call>m_t42Call){ | ||
398 | VERIFY(m_T42Calls.GoNext()); | ||
399 | m_t42Call++; | ||
400 | } | ||
401 | } | ||
402 | ASSERT(call==m_t42Call); | ||
403 | CTime ct; | ||
404 | VERIFY(m_T42Calls.GetThis(ct,entry)); | ||
405 | ASSERT(ct==entry.m_Time); | ||
406 | return TRUE; | ||
407 | } | ||
408 | |||
409 | BOOL CT42App::AddT42Call(CT42CallLogEntry& entry) | ||
410 | { | ||
411 | m_t42Call=-1; | ||
412 | if(GetT42Calls()<=0){ | ||
413 | if(m_T42Calls.Add(entry.m_Time,entry)){ | ||
414 | FlushT42CallsLog(); | ||
415 | ASSERT(!m_nT42Calls); | ||
416 | m_nT42Calls++; | ||
417 | ASSERT(m_pT42Dlg); | ||
418 | m_pT42Dlg->OnAddT42Call(); | ||
419 | return TRUE; | ||
420 | } | ||
421 | return FALSE; | ||
422 | } | ||
423 | CT42CallLogEntry cle; | ||
424 | CTimeSpan inc(0,0,0,1); | ||
425 | while(m_T42Calls.Lookup(entry.m_Time,cle)) | ||
426 | entry.m_Time+=inc; | ||
427 | if(m_T42Calls.Add(entry.m_Time,entry)){ | ||
428 | FlushT42CallsLog(); | ||
429 | m_nT42Calls++; | ||
430 | ASSERT(m_pT42Dlg); | ||
431 | m_pT42Dlg->OnAddT42Call(); | ||
432 | return TRUE; | ||
433 | } | ||
434 | return FALSE; | ||
435 | } | ||
436 | |||
437 | |||
438 | BOOL CT42App::DelT42Call(CTime& time) | ||
439 | { | ||
440 | m_t42Call=-1; | ||
441 | if(GetT42Calls()<=0) | ||
442 | return FALSE; | ||
443 | if(m_T42Calls.Delete(time)){ | ||
444 | FlushT42CallsLog(); | ||
445 | m_nT42Calls--; | ||
446 | ASSERT(m_pT42Dlg); | ||
447 | m_pT42Dlg->OnDelT42Call(); | ||
448 | return TRUE; | ||
449 | } | ||
450 | return FALSE; | ||
451 | } | ||
452 | |||
453 | BOOL CT42App::UpdateT42Call(CT42CallLogEntry& entry) | ||
454 | { | ||
455 | m_t42Call=-1; | ||
456 | #ifdef_DEBUG | ||
457 | CT42CallLogEntry cle; | ||
458 | ASSERT(m_T42Calls.Lookup(entry.m_Time,cle)); | ||
459 | #endif | ||
460 | m_T42Calls.Add(entry.m_Time,entry); | ||
461 | FlushT42CallsLog(); | ||
462 | return TRUE; | ||
463 | } | ||
464 | |||
465 | void CT42App::FlushT42CallsLog() | ||
466 | { | ||
467 | m_T42Calls.m_BT.m_File->Flush(); | ||
468 | } | ||
@@ -0,0 +1,83 @@ | |||
1 | // T42.h : main header file for the T42 application | ||
2 | // | ||
3 | |||
4 | #ifndef __AFXWIN_H__ | ||
5 | #error include 'stdafx.h' before including this file for PCH | ||
6 | #endif | ||
7 | |||
8 | #include "resource.h" // main symbols | ||
9 | |||
10 | ///////////////////////////////////////////////////////////////////////////// | ||
11 | // CT42App: | ||
12 | // See T42.cpp for the implementation of this class | ||
13 | // | ||
14 | |||
15 | class CT42Dlg; | ||
16 | class CT42App : public CWinApp | ||
17 | { | ||
18 | public: | ||
19 | void FlushT42CallsLog(); | ||
20 | CString m_HelpFile; | ||
21 | UINT m_T42TalkPort; | ||
22 | UINT m_T42LinesBusy; | ||
23 | BOOL m_bAwayOnScreenSaver; | ||
24 | BOOL UpdateT42Call(CT42CallLogEntry& entry); | ||
25 | CT42Dlg* m_pT42Dlg; | ||
26 | BOOL DelT42Call(CTime& time); | ||
27 | BOOL AddT42Call(CT42CallLogEntry& entry); | ||
28 | LONG m_nT42Calls; | ||
29 | LONG GetT42Calls(); | ||
30 | BOOL GetT42Call(LONG call,CT42CallLogEntry& entry); | ||
31 | LONG m_t42Call; | ||
32 | BOOL CloseT42CallsLog(); | ||
33 | BOOL OpenT42CallsLog(); | ||
34 | CString m_t42CallsFile; | ||
35 | CT42CallLogm_T42Calls; | ||
36 | CStringm_T42SGreeting; | ||
37 | CTimeSpan m_T42STimeLimit; | ||
38 | UINT m_T42SWinLimit; | ||
39 | UINT m_T42SBytesLimit; | ||
40 | COLORREF m_crT42LocalBG; | ||
41 | COLORREF m_crT42RemoteBG; | ||
42 | CHARFORMAT m_fmtT42System; | ||
43 | CHARFORMAT m_fmtT42Remote; | ||
44 | CHARFORMAT m_fmtT42Local; | ||
45 | void Options(CWnd* pParent=NULL); | ||
46 | void StopSound(LPCTSTR snd); | ||
47 | BOOL StartSound(LPCTSTR snd,BOOL bLoop = FALSE); | ||
48 | void Initialize(); | ||
49 | CString m_sndTeapotWhistle; | ||
50 | CString m_sndBoilingTeapot; | ||
51 | CString m_sndTeaDrop; | ||
52 | CString m_sndT42Wake; | ||
53 | BOOL m_bT42PromptLoop; | ||
54 | CString m_sndT42Prompt; | ||
55 | CString m_sndT42Bell; | ||
56 | BOOL m_bt42AutosaveLayout; | ||
57 | UINT m_maxT42Callers; | ||
58 | CStringList m_t42Callers; | ||
59 | BOOL LastCaller(LPCTSTR caller); | ||
60 | void LoadSettings(); | ||
61 | void SaveSettings(); | ||
62 | UINT m_maxT42Callees; | ||
63 | BOOL LastCallee(LPCTSTR callee); | ||
64 | CStringList m_t42Callees; | ||
65 | CDocTemplate* m_pTemplate; | ||
66 | CT42App(); | ||
67 | |||
68 | // Overrides | ||
69 | // ClassWizard generated virtual function overrides | ||
70 | //{{AFX_VIRTUAL(CT42App) | ||
71 | public: | ||
72 | virtual BOOL InitInstance(); | ||
73 | //}}AFX_VIRTUAL | ||
74 | |||
75 | // Implementation | ||
76 | |||
77 | //{{AFX_MSG(CT42App) | ||
78 | //}}AFX_MSG | ||
79 | DECLARE_MESSAGE_MAP() | ||
80 | }; | ||
81 | |||
82 | |||
83 | ///////////////////////////////////////////////////////////////////////////// | ||
@@ -0,0 +1,1691 @@ | |||
1 | # Microsoft Developer Studio Generated NMAKE File, Format Version 4.20 | ||
2 | # ** DO NOT EDIT ** | ||
3 | |||
4 | # TARGTYPE "Win32 (x86) Application" 0x0101 | ||
5 | |||
6 | !IF "$(CFG)" == "" | ||
7 | CFG=Install - Win32 Debug | ||
8 | !MESSAGE No configuration specified. Defaulting to Install - Win32 Debug. | ||
9 | !ENDIF | ||
10 | |||
11 | !IF "$(CFG)" != "T42 - Win32 Debug" && "$(CFG)" != "T42 - Win32 Pure" &&\ | ||
12 | "$(CFG)" != "T42 - Win32 Static" && "$(CFG)" != "Install - Win32 Debug" &&\ | ||
13 | "$(CFG)" != "Install - Win32 Pure" && "$(CFG)" != "Install - Win32 Static" &&\ | ||
14 | "$(CFG)" != "Install - Win32 Canned" | ||
15 | !MESSAGE Invalid configuration "$(CFG)" specified. | ||
16 | !MESSAGE You can specify a configuration when running NMAKE on this makefile | ||
17 | !MESSAGE by defining the macro CFG on the command line. For example: | ||
18 | !MESSAGE | ||
19 | !MESSAGE NMAKE /f "T42.mak" CFG="Install - Win32 Debug" | ||
20 | !MESSAGE | ||
21 | !MESSAGE Possible choices for configuration are: | ||
22 | !MESSAGE | ||
23 | !MESSAGE "T42 - Win32 Debug" (based on "Win32 (x86) Application") | ||
24 | !MESSAGE "T42 - Win32 Pure" (based on "Win32 (x86) Application") | ||
25 | !MESSAGE "T42 - Win32 Static" (based on "Win32 (x86) Application") | ||
26 | !MESSAGE "Install - Win32 Debug" (based on "Win32 (x86) Application") | ||
27 | !MESSAGE "Install - Win32 Pure" (based on "Win32 (x86) Application") | ||
28 | !MESSAGE "Install - Win32 Static" (based on "Win32 (x86) Application") | ||
29 | !MESSAGE "Install - Win32 Canned" (based on "Win32 (x86) Application") | ||
30 | !MESSAGE | ||
31 | !ERROR An invalid configuration is specified. | ||
32 | !ENDIF | ||
33 | |||
34 | !IF "$(OS)" == "Windows_NT" | ||
35 | NULL= | ||
36 | !ELSE | ||
37 | NULL=nul | ||
38 | !ENDIF | ||
39 | ################################################################################ | ||
40 | # Begin Project | ||
41 | # PROP Target_Last_Scanned "Install - Win32 Canned" | ||
42 | CPP=cl.exe | ||
43 | RSC=rc.exe | ||
44 | MTL=mktyplib.exe | ||
45 | |||
46 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
47 | |||
48 | # PROP BASE Use_MFC 6 | ||
49 | # PROP BASE Use_Debug_Libraries 1 | ||
50 | # PROP BASE Output_Dir "Debug" | ||
51 | # PROP BASE Intermediate_Dir "Debug" | ||
52 | # PROP BASE Target_Dir "" | ||
53 | # PROP Use_MFC 6 | ||
54 | # PROP Use_Debug_Libraries 1 | ||
55 | # PROP Output_Dir "Debug" | ||
56 | # PROP Intermediate_Dir "Debug" | ||
57 | # PROP Target_Dir "" | ||
58 | OUTDIR=.\Debug | ||
59 | INTDIR=.\Debug | ||
60 | # Begin Custom Macros | ||
61 | OutDir=.\Debug | ||
62 | TargetName=T42 | ||
63 | # End Custom Macros | ||
64 | |||
65 | ALL : "$(OUTDIR)\T42.exe" "$(OUTDIR)\T42.ex_" "$(OUTDIR)\T42.hlp"\ | ||
66 | "$(OUTDIR)\T42.cnt" "$(OUTDIR)\T42.hl_" "$(OUTDIR)\T42.cn_" | ||
67 | |||
68 | CLEAN : | ||
69 | -@erase "$(INTDIR)\CalleeDlg.obj" | ||
70 | -@erase "$(INTDIR)\ColorButton.obj" | ||
71 | -@erase "$(INTDIR)\FontsPage.obj" | ||
72 | -@erase "$(INTDIR)\GeneralPage.obj" | ||
73 | -@erase "$(INTDIR)\RegEx.obj" | ||
74 | -@erase "$(INTDIR)\SecretaryPage.obj" | ||
75 | -@erase "$(INTDIR)\SoundsPage.obj" | ||
76 | -@erase "$(INTDIR)\StdAfx.obj" | ||
77 | -@erase "$(INTDIR)\T42.cn_" | ||
78 | -@erase "$(INTDIR)\T42.cnt" | ||
79 | -@erase "$(INTDIR)\T42.hl_" | ||
80 | -@erase "$(INTDIR)\T42.hlp" | ||
81 | -@erase "$(INTDIR)\T42.obj" | ||
82 | -@erase "$(INTDIR)\T42.pch" | ||
83 | -@erase "$(INTDIR)\T42.res" | ||
84 | -@erase "$(INTDIR)\T42AnnounceDlg.obj" | ||
85 | -@erase "$(INTDIR)\T42Dlg.obj" | ||
86 | -@erase "$(INTDIR)\T42Document.obj" | ||
87 | -@erase "$(INTDIR)\T42Frame.obj" | ||
88 | -@erase "$(INTDIR)\T42Secretary.obj" | ||
89 | -@erase "$(INTDIR)\T42View.obj" | ||
90 | -@erase "$(INTDIR)\vc40.idb" | ||
91 | -@erase "$(INTDIR)\vc40.pdb" | ||
92 | -@erase "$(OUTDIR)\T42.ex_" | ||
93 | -@erase "$(OUTDIR)\T42.exe" | ||
94 | -@erase "$(OUTDIR)\T42.ilk" | ||
95 | -@erase "$(OUTDIR)\T42.pdb" | ||
96 | |||
97 | "$(OUTDIR)" : | ||
98 | if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" | ||
99 | |||
100 | # ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c | ||
101 | # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c | ||
102 | CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\ | ||
103 | /D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/T42.pch" /Yu"stdafx.h" /Fo"$(INTDIR)/"\ | ||
104 | /Fd"$(INTDIR)/" /c | ||
105 | CPP_OBJS=.\Debug/ | ||
106 | CPP_SBRS=.\. | ||
107 | # ADD BASE MTL /nologo /D "_DEBUG" /win32 | ||
108 | # ADD MTL /nologo /D "_DEBUG" /win32 | ||
109 | MTL_PROJ=/nologo /D "_DEBUG" /win32 | ||
110 | # ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL" | ||
111 | # ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL" | ||
112 | RSC_PROJ=/l 0x409 /fo"$(INTDIR)/T42.res" /d "_DEBUG" /d "_AFXDLL" | ||
113 | BSC32=bscmake.exe | ||
114 | # ADD BASE BSC32 /nologo | ||
115 | # ADD BSC32 /nologo | ||
116 | BSC32_FLAGS=/nologo /o"$(OUTDIR)/T42.bsc" | ||
117 | BSC32_SBRS= \ | ||
118 | |||
119 | LINK32=link.exe | ||
120 | # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 | ||
121 | # ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 | ||
122 | LINK32_FLAGS=/nologo /subsystem:windows /incremental:yes\ | ||
123 | /pdb:"$(OUTDIR)/T42.pdb" /debug /machine:I386 /out:"$(OUTDIR)/T42.exe" | ||
124 | LINK32_OBJS= \ | ||
125 | "$(INTDIR)\CalleeDlg.obj" \ | ||
126 | "$(INTDIR)\ColorButton.obj" \ | ||
127 | "$(INTDIR)\FontsPage.obj" \ | ||
128 | "$(INTDIR)\GeneralPage.obj" \ | ||
129 | "$(INTDIR)\RegEx.obj" \ | ||
130 | "$(INTDIR)\SecretaryPage.obj" \ | ||
131 | "$(INTDIR)\SoundsPage.obj" \ | ||
132 | "$(INTDIR)\StdAfx.obj" \ | ||
133 | "$(INTDIR)\T42.obj" \ | ||
134 | "$(INTDIR)\T42.res" \ | ||
135 | "$(INTDIR)\T42AnnounceDlg.obj" \ | ||
136 | "$(INTDIR)\T42Dlg.obj" \ | ||
137 | "$(INTDIR)\T42Document.obj" \ | ||
138 | "$(INTDIR)\T42Frame.obj" \ | ||
139 | "$(INTDIR)\T42Secretary.obj" \ | ||
140 | "$(INTDIR)\T42View.obj" | ||
141 | |||
142 | "$(OUTDIR)\T42.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) | ||
143 | $(LINK32) @<< | ||
144 | $(LINK32_FLAGS) $(LINK32_OBJS) | ||
145 | << | ||
146 | |||
147 | # Begin Custom Build | ||
148 | OutDir=.\Debug | ||
149 | TargetName=T42 | ||
150 | InputPath=.\Debug\T42.exe | ||
151 | SOURCE=$(InputPath) | ||
152 | |||
153 | "$(OutDir)\$(TargetName).ex_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
154 | compress $(OutDir)\$(TargetName).exe $(OutDir)\$(TargetName).ex_ | ||
155 | |||
156 | # End Custom Build | ||
157 | |||
158 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
159 | |||
160 | # PROP BASE Use_MFC 6 | ||
161 | # PROP BASE Use_Debug_Libraries 0 | ||
162 | # PROP BASE Output_Dir "T42___Wi" | ||
163 | # PROP BASE Intermediate_Dir "T42___Wi" | ||
164 | # PROP BASE Target_Dir "" | ||
165 | # PROP Use_MFC 6 | ||
166 | # PROP Use_Debug_Libraries 0 | ||
167 | # PROP Output_Dir "RELEASE" | ||
168 | # PROP Intermediate_Dir "RELEASE" | ||
169 | # PROP Target_Dir "" | ||
170 | OUTDIR=.\RELEASE | ||
171 | INTDIR=.\RELEASE | ||
172 | # Begin Custom Macros | ||
173 | OutDir=.\RELEASE | ||
174 | TargetName=T42 | ||
175 | # End Custom Macros | ||
176 | |||
177 | ALL : "$(OUTDIR)\T42.exe" "$(OUTDIR)\T42.ex_" "$(OUTDIR)\T42.hlp"\ | ||
178 | "$(OUTDIR)\T42.cnt" "$(OUTDIR)\T42.hl_" "$(OUTDIR)\T42.cn_" | ||
179 | |||
180 | CLEAN : | ||
181 | -@erase "$(INTDIR)\CalleeDlg.obj" | ||
182 | -@erase "$(INTDIR)\ColorButton.obj" | ||
183 | -@erase "$(INTDIR)\FontsPage.obj" | ||
184 | -@erase "$(INTDIR)\GeneralPage.obj" | ||
185 | -@erase "$(INTDIR)\RegEx.obj" | ||
186 | -@erase "$(INTDIR)\SecretaryPage.obj" | ||
187 | -@erase "$(INTDIR)\SoundsPage.obj" | ||
188 | -@erase "$(INTDIR)\StdAfx.obj" | ||
189 | -@erase "$(INTDIR)\T42.cn_" | ||
190 | -@erase "$(INTDIR)\T42.cnt" | ||
191 | -@erase "$(INTDIR)\T42.hl_" | ||
192 | -@erase "$(INTDIR)\T42.hlp" | ||
193 | -@erase "$(INTDIR)\T42.obj" | ||
194 | -@erase "$(INTDIR)\T42.pch" | ||
195 | -@erase "$(INTDIR)\T42.res" | ||
196 | -@erase "$(INTDIR)\T42AnnounceDlg.obj" | ||
197 | -@erase "$(INTDIR)\T42Dlg.obj" | ||
198 | -@erase "$(INTDIR)\T42Document.obj" | ||
199 | -@erase "$(INTDIR)\T42Frame.obj" | ||
200 | -@erase "$(INTDIR)\T42Secretary.obj" | ||
201 | -@erase "$(INTDIR)\T42View.obj" | ||
202 | -@erase "$(OUTDIR)\T42.ex_" | ||
203 | -@erase "$(OUTDIR)\T42.exe" | ||
204 | |||
205 | "$(OUTDIR)" : | ||
206 | if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" | ||
207 | |||
208 | # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c | ||
209 | # ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c | ||
210 | CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\ | ||
211 | "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/T42.pch" /Yu"stdafx.h" /Fo"$(INTDIR)/" /c | ||
212 | CPP_OBJS=.\RELEASE/ | ||
213 | CPP_SBRS=.\. | ||
214 | # ADD BASE MTL /nologo /D "NDEBUG" /win32 | ||
215 | # ADD MTL /nologo /D "NDEBUG" /win32 | ||
216 | MTL_PROJ=/nologo /D "NDEBUG" /win32 | ||
217 | # ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" | ||
218 | # ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" | ||
219 | RSC_PROJ=/l 0x409 /fo"$(INTDIR)/T42.res" /d "NDEBUG" /d "_AFXDLL" | ||
220 | BSC32=bscmake.exe | ||
221 | # ADD BASE BSC32 /nologo | ||
222 | # ADD BSC32 /nologo | ||
223 | BSC32_FLAGS=/nologo /o"$(OUTDIR)/T42.bsc" | ||
224 | BSC32_SBRS= \ | ||
225 | |||
226 | LINK32=link.exe | ||
227 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 | ||
228 | # ADD LINK32 /nologo /subsystem:windows /machine:I386 | ||
229 | LINK32_FLAGS=/nologo /subsystem:windows /incremental:no\ | ||
230 | /pdb:"$(OUTDIR)/T42.pdb" /machine:I386 /out:"$(OUTDIR)/T42.exe" | ||
231 | LINK32_OBJS= \ | ||
232 | "$(INTDIR)\CalleeDlg.obj" \ | ||
233 | "$(INTDIR)\ColorButton.obj" \ | ||
234 | "$(INTDIR)\FontsPage.obj" \ | ||
235 | "$(INTDIR)\GeneralPage.obj" \ | ||
236 | "$(INTDIR)\RegEx.obj" \ | ||
237 | "$(INTDIR)\SecretaryPage.obj" \ | ||
238 | "$(INTDIR)\SoundsPage.obj" \ | ||
239 | "$(INTDIR)\StdAfx.obj" \ | ||
240 | "$(INTDIR)\T42.obj" \ | ||
241 | "$(INTDIR)\T42.res" \ | ||
242 | "$(INTDIR)\T42AnnounceDlg.obj" \ | ||
243 | "$(INTDIR)\T42Dlg.obj" \ | ||
244 | "$(INTDIR)\T42Document.obj" \ | ||
245 | "$(INTDIR)\T42Frame.obj" \ | ||
246 | "$(INTDIR)\T42Secretary.obj" \ | ||
247 | "$(INTDIR)\T42View.obj" | ||
248 | |||
249 | "$(OUTDIR)\T42.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) | ||
250 | $(LINK32) @<< | ||
251 | $(LINK32_FLAGS) $(LINK32_OBJS) | ||
252 | << | ||
253 | |||
254 | # Begin Custom Build | ||
255 | OutDir=.\RELEASE | ||
256 | TargetName=T42 | ||
257 | InputPath=.\RELEASE\T42.exe | ||
258 | SOURCE=$(InputPath) | ||
259 | |||
260 | "$(OutDir)\$(TargetName).ex_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
261 | compress $(OutDir)\$(TargetName).exe $(OutDir)\$(TargetName).ex_ | ||
262 | |||
263 | # End Custom Build | ||
264 | |||
265 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
266 | |||
267 | # PROP BASE Use_MFC 6 | ||
268 | # PROP BASE Use_Debug_Libraries 0 | ||
269 | # PROP BASE Output_Dir "T42___W0" | ||
270 | # PROP BASE Intermediate_Dir "T42___W0" | ||
271 | # PROP BASE Target_Dir "" | ||
272 | # PROP Use_MFC 5 | ||
273 | # PROP Use_Debug_Libraries 0 | ||
274 | # PROP Output_Dir "RELEAST" | ||
275 | # PROP Intermediate_Dir "RELEAST" | ||
276 | # PROP Target_Dir "" | ||
277 | OUTDIR=.\RELEAST | ||
278 | INTDIR=.\RELEAST | ||
279 | # Begin Custom Macros | ||
280 | OutDir=.\RELEAST | ||
281 | TargetName=T42 | ||
282 | # End Custom Macros | ||
283 | |||
284 | ALL : "$(OUTDIR)\T42.exe" "$(OUTDIR)\T42.ex_" "$(OUTDIR)\T42.hlp"\ | ||
285 | "$(OUTDIR)\T42.cnt" "$(OUTDIR)\T42.hl_" "$(OUTDIR)\T42.cn_" | ||
286 | |||
287 | CLEAN : | ||
288 | -@erase "$(INTDIR)\CalleeDlg.obj" | ||
289 | -@erase "$(INTDIR)\ColorButton.obj" | ||
290 | -@erase "$(INTDIR)\FontsPage.obj" | ||
291 | -@erase "$(INTDIR)\GeneralPage.obj" | ||
292 | -@erase "$(INTDIR)\RegEx.obj" | ||
293 | -@erase "$(INTDIR)\SecretaryPage.obj" | ||
294 | -@erase "$(INTDIR)\SoundsPage.obj" | ||
295 | -@erase "$(INTDIR)\StdAfx.obj" | ||
296 | -@erase "$(INTDIR)\T42.cn_" | ||
297 | -@erase "$(INTDIR)\T42.cnt" | ||
298 | -@erase "$(INTDIR)\T42.hl_" | ||
299 | -@erase "$(INTDIR)\T42.hlp" | ||
300 | -@erase "$(INTDIR)\T42.obj" | ||
301 | -@erase "$(INTDIR)\T42.pch" | ||
302 | -@erase "$(INTDIR)\T42.res" | ||
303 | -@erase "$(INTDIR)\T42AnnounceDlg.obj" | ||
304 | -@erase "$(INTDIR)\T42Dlg.obj" | ||
305 | -@erase "$(INTDIR)\T42Document.obj" | ||
306 | -@erase "$(INTDIR)\T42Frame.obj" | ||
307 | -@erase "$(INTDIR)\T42Secretary.obj" | ||
308 | -@erase "$(INTDIR)\T42View.obj" | ||
309 | -@erase "$(OUTDIR)\T42.ex_" | ||
310 | -@erase "$(OUTDIR)\T42.exe" | ||
311 | |||
312 | "$(OUTDIR)" : | ||
313 | if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" | ||
314 | |||
315 | # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c | ||
316 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /c | ||
317 | CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\ | ||
318 | "_MBCS" /Fp"$(INTDIR)/T42.pch" /Yu"stdafx.h" /Fo"$(INTDIR)/" /c | ||
319 | CPP_OBJS=.\RELEAST/ | ||
320 | CPP_SBRS=.\. | ||
321 | # ADD BASE MTL /nologo /D "NDEBUG" /win32 | ||
322 | # ADD MTL /nologo /D "NDEBUG" /win32 | ||
323 | MTL_PROJ=/nologo /D "NDEBUG" /win32 | ||
324 | # ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" | ||
325 | # ADD RSC /l 0x409 /d "NDEBUG" | ||
326 | RSC_PROJ=/l 0x409 /fo"$(INTDIR)/T42.res" /d "NDEBUG" | ||
327 | BSC32=bscmake.exe | ||
328 | # ADD BASE BSC32 /nologo | ||
329 | # ADD BSC32 /nologo | ||
330 | BSC32_FLAGS=/nologo /o"$(OUTDIR)/T42.bsc" | ||
331 | BSC32_SBRS= \ | ||
332 | |||
333 | LINK32=link.exe | ||
334 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 | ||
335 | # ADD LINK32 /nologo /subsystem:windows /machine:I386 | ||
336 | LINK32_FLAGS=/nologo /subsystem:windows /incremental:no\ | ||
337 | /pdb:"$(OUTDIR)/T42.pdb" /machine:I386 /out:"$(OUTDIR)/T42.exe" | ||
338 | LINK32_OBJS= \ | ||
339 | "$(INTDIR)\CalleeDlg.obj" \ | ||
340 | "$(INTDIR)\ColorButton.obj" \ | ||
341 | "$(INTDIR)\FontsPage.obj" \ | ||
342 | "$(INTDIR)\GeneralPage.obj" \ | ||
343 | "$(INTDIR)\RegEx.obj" \ | ||
344 | "$(INTDIR)\SecretaryPage.obj" \ | ||
345 | "$(INTDIR)\SoundsPage.obj" \ | ||
346 | "$(INTDIR)\StdAfx.obj" \ | ||
347 | "$(INTDIR)\T42.obj" \ | ||
348 | "$(INTDIR)\T42.res" \ | ||
349 | "$(INTDIR)\T42AnnounceDlg.obj" \ | ||
350 | "$(INTDIR)\T42Dlg.obj" \ | ||
351 | "$(INTDIR)\T42Document.obj" \ | ||
352 | "$(INTDIR)\T42Frame.obj" \ | ||
353 | "$(INTDIR)\T42Secretary.obj" \ | ||
354 | "$(INTDIR)\T42View.obj" | ||
355 | |||
356 | "$(OUTDIR)\T42.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) | ||
357 | $(LINK32) @<< | ||
358 | $(LINK32_FLAGS) $(LINK32_OBJS) | ||
359 | << | ||
360 | |||
361 | # Begin Custom Build | ||
362 | OutDir=.\RELEAST | ||
363 | TargetName=T42 | ||
364 | InputPath=.\RELEAST\T42.exe | ||
365 | SOURCE=$(InputPath) | ||
366 | |||
367 | "$(OutDir)\$(TargetName).ex_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
368 | compress $(OutDir)\$(TargetName).exe $(OutDir)\$(TargetName).ex_ | ||
369 | |||
370 | # End Custom Build | ||
371 | |||
372 | !ELSEIF "$(CFG)" == "Install - Win32 Debug" | ||
373 | |||
374 | # PROP BASE Use_MFC 2 | ||
375 | # PROP BASE Use_Debug_Libraries 1 | ||
376 | # PROP BASE Output_Dir "Install\Debug" | ||
377 | # PROP BASE Intermediate_Dir "Install\Debug" | ||
378 | # PROP BASE Target_Dir "Install" | ||
379 | # PROP Use_MFC 2 | ||
380 | # PROP Use_Debug_Libraries 1 | ||
381 | # PROP Output_Dir "Install\Debug" | ||
382 | # PROP Intermediate_Dir "Install\Debug" | ||
383 | # PROP Target_Dir "Install" | ||
384 | OUTDIR=.\Install\Debug | ||
385 | INTDIR=.\Install\Debug | ||
386 | |||
387 | ALL : "T42 - Win32 Debug" "$(OUTDIR)\Install.exe" | ||
388 | |||
389 | CLEAN : | ||
390 | -@erase "$(INTDIR)\install.obj" | ||
391 | -@erase "$(INTDIR)\Install.res" | ||
392 | -@erase "$(INTDIR)\vc40.idb" | ||
393 | -@erase "$(INTDIR)\vc40.pdb" | ||
394 | -@erase "$(OUTDIR)\Install.exe" | ||
395 | -@erase "$(OUTDIR)\Install.ilk" | ||
396 | -@erase "$(OUTDIR)\Install.pdb" | ||
397 | |||
398 | "$(OUTDIR)" : | ||
399 | if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" | ||
400 | |||
401 | # ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c | ||
402 | # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c | ||
403 | CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\ | ||
404 | /D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/Install.pch" /YX /Fo"$(INTDIR)/"\ | ||
405 | /Fd"$(INTDIR)/" /c | ||
406 | CPP_OBJS=.\Install\Debug/ | ||
407 | CPP_SBRS=.\. | ||
408 | # ADD BASE MTL /nologo /D "_DEBUG" /win32 | ||
409 | # ADD MTL /nologo /D "_DEBUG" /win32 | ||
410 | MTL_PROJ=/nologo /D "_DEBUG" /win32 | ||
411 | # ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL" | ||
412 | # ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL" | ||
413 | RSC_PROJ=/l 0x409 /fo"$(INTDIR)/Install.res" /d "_DEBUG" /d "_AFXDLL" | ||
414 | BSC32=bscmake.exe | ||
415 | # ADD BASE BSC32 /nologo | ||
416 | # ADD BSC32 /nologo | ||
417 | BSC32_FLAGS=/nologo /o"$(OUTDIR)/Install.bsc" | ||
418 | BSC32_SBRS= \ | ||
419 | |||
420 | LINK32=link.exe | ||
421 | # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 | ||
422 | # ADD LINK32 version.lib /nologo /subsystem:windows /debug /machine:I386 | ||
423 | LINK32_FLAGS=version.lib /nologo /subsystem:windows /incremental:yes\ | ||
424 | /pdb:"$(OUTDIR)/Install.pdb" /debug /machine:I386 /out:"$(OUTDIR)/Install.exe" | ||
425 | LINK32_OBJS= \ | ||
426 | "$(INTDIR)\install.obj" \ | ||
427 | "$(INTDIR)\Install.res" | ||
428 | |||
429 | "$(OUTDIR)\Install.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) | ||
430 | $(LINK32) @<< | ||
431 | $(LINK32_FLAGS) $(LINK32_OBJS) | ||
432 | << | ||
433 | |||
434 | !ELSEIF "$(CFG)" == "Install - Win32 Pure" | ||
435 | |||
436 | # PROP BASE Use_MFC 2 | ||
437 | # PROP BASE Use_Debug_Libraries 0 | ||
438 | # PROP BASE Output_Dir "Install\Pure" | ||
439 | # PROP BASE Intermediate_Dir "Install\Pure" | ||
440 | # PROP BASE Target_Dir "Install" | ||
441 | # PROP Use_MFC 0 | ||
442 | # PROP Use_Debug_Libraries 0 | ||
443 | # PROP Output_Dir "Install\Pure" | ||
444 | # PROP Intermediate_Dir "Install\Pure" | ||
445 | # PROP Target_Dir "Install" | ||
446 | OUTDIR=.\Install\Pure | ||
447 | INTDIR=.\Install\Pure | ||
448 | |||
449 | ALL : "T42 - Win32 Pure" "$(OUTDIR)\Install.exe" | ||
450 | |||
451 | CLEAN : | ||
452 | -@erase "$(INTDIR)\install.obj" | ||
453 | -@erase "$(INTDIR)\Install.res" | ||
454 | -@erase "$(OUTDIR)\Install.exe" | ||
455 | |||
456 | "$(OUTDIR)" : | ||
457 | if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" | ||
458 | |||
459 | # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c | ||
460 | # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /c | ||
461 | CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\ | ||
462 | "_MBCS" /Fp"$(INTDIR)/Install.pch" /YX /Fo"$(INTDIR)/" /c | ||
463 | CPP_OBJS=.\Install\Pure/ | ||
464 | CPP_SBRS=.\. | ||
465 | # ADD BASE MTL /nologo /D "NDEBUG" /win32 | ||
466 | # ADD MTL /nologo /D "NDEBUG" /win32 | ||
467 | MTL_PROJ=/nologo /D "NDEBUG" /win32 | ||
468 | # ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" | ||
469 | # ADD RSC /l 0x409 /d "NDEBUG" | ||
470 | RSC_PROJ=/l 0x409 /fo"$(INTDIR)/Install.res" /d "NDEBUG" | ||
471 | BSC32=bscmake.exe | ||
472 | # ADD BASE BSC32 /nologo | ||
473 | # ADD BSC32 /nologo | ||
474 | BSC32_FLAGS=/nologo /o"$(OUTDIR)/Install.bsc" | ||
475 | BSC32_SBRS= \ | ||
476 | |||
477 | LINK32=link.exe | ||
478 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 | ||
479 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib /nologo /subsystem:windows /machine:I386 | ||
480 | LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ | ||
481 | advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ | ||
482 | odbccp32.lib version.lib /nologo /subsystem:windows /incremental:no\ | ||
483 | /pdb:"$(OUTDIR)/Install.pdb" /machine:I386 /out:"$(OUTDIR)/Install.exe" | ||
484 | LINK32_OBJS= \ | ||
485 | "$(INTDIR)\install.obj" \ | ||
486 | "$(INTDIR)\Install.res" | ||
487 | |||
488 | "$(OUTDIR)\Install.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) | ||
489 | $(LINK32) @<< | ||
490 | $(LINK32_FLAGS) $(LINK32_OBJS) | ||
491 | << | ||
492 | |||
493 | !ELSEIF "$(CFG)" == "Install - Win32 Static" | ||
494 | |||
495 | # PROP BASE Use_MFC 2 | ||
496 | # PROP BASE Use_Debug_Libraries 0 | ||
497 | # PROP BASE Output_Dir "Install\Static" | ||
498 | # PROP BASE Intermediate_Dir "Install\Static" | ||
499 | # PROP BASE Target_Dir "Install" | ||
500 | # PROP Use_MFC 0 | ||
501 | # PROP Use_Debug_Libraries 0 | ||
502 | # PROP Output_Dir "Install\Static" | ||
503 | # PROP Intermediate_Dir "Install\Static" | ||
504 | # PROP Target_Dir "Install" | ||
505 | OUTDIR=.\Install\Static | ||
506 | INTDIR=.\Install\Static | ||
507 | |||
508 | ALL : "T42 - Win32 Static" "$(OUTDIR)\Install.exe" | ||
509 | |||
510 | CLEAN : | ||
511 | -@erase "$(INTDIR)\install.obj" | ||
512 | -@erase "$(INTDIR)\Install.res" | ||
513 | -@erase "$(OUTDIR)\Install.exe" | ||
514 | |||
515 | "$(OUTDIR)" : | ||
516 | if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" | ||
517 | |||
518 | # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c | ||
519 | # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "STATI_K" /YX /c | ||
520 | CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\ | ||
521 | "_MBCS" /D "STATI_K" /Fp"$(INTDIR)/Install.pch" /YX /Fo"$(INTDIR)/" /c | ||
522 | CPP_OBJS=.\Install\Static/ | ||
523 | CPP_SBRS=.\. | ||
524 | # ADD BASE MTL /nologo /D "NDEBUG" /win32 | ||
525 | # ADD MTL /nologo /D "NDEBUG" /win32 | ||
526 | MTL_PROJ=/nologo /D "NDEBUG" /win32 | ||
527 | # ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" | ||
528 | # ADD RSC /l 0x409 /d "NDEBUG" /d "STATI_K" | ||
529 | RSC_PROJ=/l 0x409 /fo"$(INTDIR)/Install.res" /d "NDEBUG" /d "STATI_K" | ||
530 | BSC32=bscmake.exe | ||
531 | # ADD BASE BSC32 /nologo | ||
532 | # ADD BSC32 /nologo | ||
533 | BSC32_FLAGS=/nologo /o"$(OUTDIR)/Install.bsc" | ||
534 | BSC32_SBRS= \ | ||
535 | |||
536 | LINK32=link.exe | ||
537 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 | ||
538 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib /nologo /subsystem:windows /machine:I386 | ||
539 | LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ | ||
540 | advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ | ||
541 | odbccp32.lib version.lib /nologo /subsystem:windows /incremental:no\ | ||
542 | /pdb:"$(OUTDIR)/Install.pdb" /machine:I386 /out:"$(OUTDIR)/Install.exe" | ||
543 | LINK32_OBJS= \ | ||
544 | "$(INTDIR)\install.obj" \ | ||
545 | "$(INTDIR)\Install.res" | ||
546 | |||
547 | "$(OUTDIR)\Install.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) | ||
548 | $(LINK32) @<< | ||
549 | $(LINK32_FLAGS) $(LINK32_OBJS) | ||
550 | << | ||
551 | |||
552 | !ELSEIF "$(CFG)" == "Install - Win32 Canned" | ||
553 | |||
554 | # PROP BASE Use_MFC 2 | ||
555 | # PROP BASE Use_Debug_Libraries 0 | ||
556 | # PROP BASE Output_Dir "Install\Canned" | ||
557 | # PROP BASE Intermediate_Dir "Install\Canned" | ||
558 | # PROP BASE Target_Dir "Install" | ||
559 | # PROP Use_MFC 0 | ||
560 | # PROP Use_Debug_Libraries 0 | ||
561 | # PROP Output_Dir "Install\Canned" | ||
562 | # PROP Intermediate_Dir "Install\Canned" | ||
563 | # PROP Target_Dir "Install" | ||
564 | OUTDIR=.\Install\Canned | ||
565 | INTDIR=.\Install\Canned | ||
566 | |||
567 | ALL : "$(OUTDIR)\Install.exe" | ||
568 | |||
569 | CLEAN : | ||
570 | -@erase "$(INTDIR)\install.obj" | ||
571 | -@erase "$(INTDIR)\Install.res" | ||
572 | -@erase "$(OUTDIR)\Install.exe" | ||
573 | |||
574 | "$(OUTDIR)" : | ||
575 | if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" | ||
576 | |||
577 | # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c | ||
578 | # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "K_ANNED" /YX /c | ||
579 | CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\ | ||
580 | "_MBCS" /D "K_ANNED" /Fp"$(INTDIR)/Install.pch" /YX /Fo"$(INTDIR)/" /c | ||
581 | CPP_OBJS=.\Install\Canned/ | ||
582 | CPP_SBRS=.\. | ||
583 | # ADD BASE MTL /nologo /D "NDEBUG" /win32 | ||
584 | # ADD MTL /nologo /D "NDEBUG" /win32 | ||
585 | MTL_PROJ=/nologo /D "NDEBUG" /win32 | ||
586 | # ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" | ||
587 | # ADD RSC /l 0x409 /d "NDEBUG" /d "K_ANNED" | ||
588 | RSC_PROJ=/l 0x409 /fo"$(INTDIR)/Install.res" /d "NDEBUG" /d "K_ANNED" | ||
589 | BSC32=bscmake.exe | ||
590 | # ADD BASE BSC32 /nologo | ||
591 | # ADD BSC32 /nologo | ||
592 | BSC32_FLAGS=/nologo /o"$(OUTDIR)/Install.bsc" | ||
593 | BSC32_SBRS= \ | ||
594 | |||
595 | LINK32=link.exe | ||
596 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 | ||
597 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib /nologo /subsystem:windows /machine:I386 | ||
598 | LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ | ||
599 | advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ | ||
600 | odbccp32.lib version.lib /nologo /subsystem:windows /incremental:no\ | ||
601 | /pdb:"$(OUTDIR)/Install.pdb" /machine:I386 /out:"$(OUTDIR)/Install.exe" | ||
602 | LINK32_OBJS= \ | ||
603 | "$(INTDIR)\install.obj" \ | ||
604 | "$(INTDIR)\Install.res" | ||
605 | |||
606 | "$(OUTDIR)\Install.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) | ||
607 | $(LINK32) @<< | ||
608 | $(LINK32_FLAGS) $(LINK32_OBJS) | ||
609 | << | ||
610 | |||
611 | !ENDIF | ||
612 | |||
613 | .c{$(CPP_OBJS)}.obj: | ||
614 | $(CPP) $(CPP_PROJ) $< | ||
615 | |||
616 | .cpp{$(CPP_OBJS)}.obj: | ||
617 | $(CPP) $(CPP_PROJ) $< | ||
618 | |||
619 | .cxx{$(CPP_OBJS)}.obj: | ||
620 | $(CPP) $(CPP_PROJ) $< | ||
621 | |||
622 | .c{$(CPP_SBRS)}.sbr: | ||
623 | $(CPP) $(CPP_PROJ) $< | ||
624 | |||
625 | .cpp{$(CPP_SBRS)}.sbr: | ||
626 | $(CPP) $(CPP_PROJ) $< | ||
627 | |||
628 | .cxx{$(CPP_SBRS)}.sbr: | ||
629 | $(CPP) $(CPP_PROJ) $< | ||
630 | |||
631 | ################################################################################ | ||
632 | # Begin Target | ||
633 | |||
634 | # Name "T42 - Win32 Debug" | ||
635 | # Name "T42 - Win32 Pure" | ||
636 | # Name "T42 - Win32 Static" | ||
637 | |||
638 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
639 | |||
640 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
641 | |||
642 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
643 | |||
644 | !ENDIF | ||
645 | |||
646 | ################################################################################ | ||
647 | # Begin Source File | ||
648 | |||
649 | SOURCE=.\T42.cpp | ||
650 | |||
651 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
652 | |||
653 | DEP_CPP_T42_C=\ | ||
654 | ".\ColorButton.h"\ | ||
655 | ".\FontsPage.h"\ | ||
656 | ".\GeneralPage.h"\ | ||
657 | ".\SecretaryPage.h"\ | ||
658 | ".\shared-code\BitSet.h"\ | ||
659 | ".\shared-code\BTreendex.h"\ | ||
660 | ".\shared-code\Dynamide.h"\ | ||
661 | ".\shared-code\FindIFace.h"\ | ||
662 | ".\shared-code\kHelpers.h"\ | ||
663 | ".\shared-code\LRUCache.h"\ | ||
664 | ".\shared-code\SNMPeer.h"\ | ||
665 | ".\shared-code\SNMPExtDll.h"\ | ||
666 | ".\shared-code\SNMPOIDs.h"\ | ||
667 | ".\SoundsPage.h"\ | ||
668 | ".\stdafx.h"\ | ||
669 | ".\T42.h"\ | ||
670 | ".\T42CallLog.h"\ | ||
671 | ".\T42Dlg.h"\ | ||
672 | ".\T42Document.h"\ | ||
673 | ".\T42Frame.h"\ | ||
674 | ".\T42View.h"\ | ||
675 | ".\talkd.h"\ | ||
676 | |||
677 | |||
678 | "$(INTDIR)\T42.obj" : $(SOURCE) $(DEP_CPP_T42_C) "$(INTDIR)"\ | ||
679 | "$(INTDIR)\T42.pch" | ||
680 | |||
681 | |||
682 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
683 | |||
684 | DEP_CPP_T42_C=\ | ||
685 | ".\ColorButton.h"\ | ||
686 | ".\FontsPage.h"\ | ||
687 | ".\GeneralPage.h"\ | ||
688 | ".\SecretaryPage.h"\ | ||
689 | ".\shared-code\BitSet.h"\ | ||
690 | ".\shared-code\BTreendex.h"\ | ||
691 | ".\shared-code\Dynamide.h"\ | ||
692 | ".\shared-code\FindIFace.h"\ | ||
693 | ".\shared-code\kHelpers.h"\ | ||
694 | ".\shared-code\LRUCache.h"\ | ||
695 | ".\shared-code\SNMPeer.h"\ | ||
696 | ".\shared-code\SNMPExtDll.h"\ | ||
697 | ".\shared-code\SNMPOIDs.h"\ | ||
698 | ".\SoundsPage.h"\ | ||
699 | ".\stdafx.h"\ | ||
700 | ".\T42.h"\ | ||
701 | ".\T42CallLog.h"\ | ||
702 | ".\T42Dlg.h"\ | ||
703 | ".\T42Document.h"\ | ||
704 | ".\T42Frame.h"\ | ||
705 | ".\T42View.h"\ | ||
706 | ".\talkd.h"\ | ||
707 | |||
708 | |||
709 | "$(INTDIR)\T42.obj" : $(SOURCE) $(DEP_CPP_T42_C) "$(INTDIR)"\ | ||
710 | "$(INTDIR)\T42.pch" | ||
711 | |||
712 | |||
713 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
714 | |||
715 | DEP_CPP_T42_C=\ | ||
716 | ".\ColorButton.h"\ | ||
717 | ".\FontsPage.h"\ | ||
718 | ".\GeneralPage.h"\ | ||
719 | ".\SecretaryPage.h"\ | ||
720 | ".\shared-code\BitSet.h"\ | ||
721 | ".\shared-code\BTreendex.h"\ | ||
722 | ".\shared-code\Dynamide.h"\ | ||
723 | ".\shared-code\FindIFace.h"\ | ||
724 | ".\shared-code\kHelpers.h"\ | ||
725 | ".\shared-code\LRUCache.h"\ | ||
726 | ".\shared-code\SNMPeer.h"\ | ||
727 | ".\shared-code\SNMPExtDll.h"\ | ||
728 | ".\shared-code\SNMPOIDs.h"\ | ||
729 | ".\SoundsPage.h"\ | ||
730 | ".\stdafx.h"\ | ||
731 | ".\T42.h"\ | ||
732 | ".\T42CallLog.h"\ | ||
733 | ".\T42Dlg.h"\ | ||
734 | ".\T42Document.h"\ | ||
735 | ".\T42Frame.h"\ | ||
736 | ".\T42View.h"\ | ||
737 | ".\talkd.h"\ | ||
738 | |||
739 | |||
740 | "$(INTDIR)\T42.obj" : $(SOURCE) $(DEP_CPP_T42_C) "$(INTDIR)"\ | ||
741 | "$(INTDIR)\T42.pch" | ||
742 | |||
743 | |||
744 | !ENDIF | ||
745 | |||
746 | # End Source File | ||
747 | ################################################################################ | ||
748 | # Begin Source File | ||
749 | |||
750 | SOURCE=.\T42Dlg.cpp | ||
751 | DEP_CPP_T42DL=\ | ||
752 | ".\shared-code\BitSet.h"\ | ||
753 | ".\shared-code\BTreendex.h"\ | ||
754 | ".\shared-code\Dynamide.h"\ | ||
755 | ".\shared-code\FindIFace.h"\ | ||
756 | ".\shared-code\kHelpers.h"\ | ||
757 | ".\shared-code\LRUCache.h"\ | ||
758 | ".\shared-code\SNMPeer.h"\ | ||
759 | ".\shared-code\SNMPExtDll.h"\ | ||
760 | ".\shared-code\SNMPOIDs.h"\ | ||
761 | ".\stdafx.h"\ | ||
762 | ".\T42.h"\ | ||
763 | ".\T42AnnounceDlg.h"\ | ||
764 | ".\T42CallLog.h"\ | ||
765 | ".\T42Dlg.h"\ | ||
766 | ".\T42Document.h"\ | ||
767 | ".\T42Frame.h"\ | ||
768 | ".\T42Secretary.h"\ | ||
769 | ".\talkd.h"\ | ||
770 | |||
771 | |||
772 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
773 | |||
774 | |||
775 | "$(INTDIR)\T42Dlg.obj" : $(SOURCE) $(DEP_CPP_T42DL) "$(INTDIR)"\ | ||
776 | "$(INTDIR)\T42.pch" | ||
777 | |||
778 | |||
779 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
780 | |||
781 | |||
782 | "$(INTDIR)\T42Dlg.obj" : $(SOURCE) $(DEP_CPP_T42DL) "$(INTDIR)"\ | ||
783 | "$(INTDIR)\T42.pch" | ||
784 | |||
785 | |||
786 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
787 | |||
788 | |||
789 | "$(INTDIR)\T42Dlg.obj" : $(SOURCE) $(DEP_CPP_T42DL) "$(INTDIR)"\ | ||
790 | "$(INTDIR)\T42.pch" | ||
791 | |||
792 | |||
793 | !ENDIF | ||
794 | |||
795 | # End Source File | ||
796 | ################################################################################ | ||
797 | # Begin Source File | ||
798 | |||
799 | SOURCE=.\StdAfx.cpp | ||
800 | DEP_CPP_STDAF=\ | ||
801 | ".\shared-code\BitSet.h"\ | ||
802 | ".\shared-code\BTreendex.h"\ | ||
803 | ".\shared-code\Dynamide.h"\ | ||
804 | ".\shared-code\FindIFace.h"\ | ||
805 | ".\shared-code\kHelpers.h"\ | ||
806 | ".\shared-code\LRUCache.h"\ | ||
807 | ".\shared-code\SNMPeer.h"\ | ||
808 | ".\shared-code\SNMPExtDll.h"\ | ||
809 | ".\shared-code\SNMPOIDs.h"\ | ||
810 | ".\stdafx.h"\ | ||
811 | ".\T42CallLog.h"\ | ||
812 | ".\talkd.h"\ | ||
813 | |||
814 | |||
815 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
816 | |||
817 | # ADD CPP /Yc"stdafx.h" | ||
818 | |||
819 | BuildCmds= \ | ||
820 | $(CPP) /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\ | ||
821 | /D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/T42.pch" /Yc"stdafx.h" /Fo"$(INTDIR)/"\ | ||
822 | /Fd"$(INTDIR)/" /c $(SOURCE) \ | ||
823 | |||
824 | |||
825 | "$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)" | ||
826 | $(BuildCmds) | ||
827 | |||
828 | "$(INTDIR)\T42.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)" | ||
829 | $(BuildCmds) | ||
830 | |||
831 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
832 | |||
833 | # ADD BASE CPP /Yc"stdafx.h" | ||
834 | # ADD CPP /Yc"stdafx.h" | ||
835 | |||
836 | BuildCmds= \ | ||
837 | $(CPP) /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\ | ||
838 | "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/T42.pch" /Yc"stdafx.h" /Fo"$(INTDIR)/" /c\ | ||
839 | $(SOURCE) \ | ||
840 | |||
841 | |||
842 | "$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)" | ||
843 | $(BuildCmds) | ||
844 | |||
845 | "$(INTDIR)\T42.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)" | ||
846 | $(BuildCmds) | ||
847 | |||
848 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
849 | |||
850 | # ADD BASE CPP /Yc"stdafx.h" | ||
851 | # ADD CPP /Yc"stdafx.h" | ||
852 | |||
853 | BuildCmds= \ | ||
854 | $(CPP) /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS"\ | ||
855 | /Fp"$(INTDIR)/T42.pch" /Yc"stdafx.h" /Fo"$(INTDIR)/" /c $(SOURCE) \ | ||
856 | |||
857 | |||
858 | "$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)" | ||
859 | $(BuildCmds) | ||
860 | |||
861 | "$(INTDIR)\T42.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)" | ||
862 | $(BuildCmds) | ||
863 | |||
864 | !ENDIF | ||
865 | |||
866 | # End Source File | ||
867 | ################################################################################ | ||
868 | # Begin Source File | ||
869 | |||
870 | SOURCE=.\T42.rc | ||
871 | DEP_RSC_T42_R=\ | ||
872 | ".\res\fullcup.ico"\ | ||
873 | ".\res\idr_flip.ico"\ | ||
874 | ".\res\idr_full.ico"\ | ||
875 | ".\res\idr_t42f.ico"\ | ||
876 | ".\res\T42-Beep.wav"\ | ||
877 | ".\res\T42-Boiling.wav"\ | ||
878 | ".\res\T42-Whistle.wav"\ | ||
879 | ".\res\T42.ico"\ | ||
880 | ".\res\T42.rc2"\ | ||
881 | ".\res\t42calln.ico"\ | ||
882 | ".\res\t42callp.ico"\ | ||
883 | ".\shared-data\browse-icon.ico"\ | ||
884 | ".\shared-data\klever-background.bmp"\ | ||
885 | ".\shared-data\play-icon.ico"\ | ||
886 | |||
887 | |||
888 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
889 | |||
890 | |||
891 | "$(INTDIR)\T42.res" : $(SOURCE) $(DEP_RSC_T42_R) "$(INTDIR)" | ||
892 | $(RSC) $(RSC_PROJ) $(SOURCE) | ||
893 | |||
894 | |||
895 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
896 | |||
897 | |||
898 | "$(INTDIR)\T42.res" : $(SOURCE) $(DEP_RSC_T42_R) "$(INTDIR)" | ||
899 | $(RSC) $(RSC_PROJ) $(SOURCE) | ||
900 | |||
901 | |||
902 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
903 | |||
904 | |||
905 | "$(INTDIR)\T42.res" : $(SOURCE) $(DEP_RSC_T42_R) "$(INTDIR)" | ||
906 | $(RSC) $(RSC_PROJ) $(SOURCE) | ||
907 | |||
908 | |||
909 | !ENDIF | ||
910 | |||
911 | # End Source File | ||
912 | ################################################################################ | ||
913 | # Begin Source File | ||
914 | |||
915 | SOURCE=.\help\T42.hpj | ||
916 | |||
917 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
918 | |||
919 | # Begin Custom Build - Making help file... | ||
920 | OutDir=.\Debug | ||
921 | ProjDir=. | ||
922 | TargetName=T42 | ||
923 | InputPath=.\help\T42.hpj | ||
924 | |||
925 | BuildCmds= \ | ||
926 | "$(ProjDir)\makehelp.bat" \ | ||
927 | compress $(OutDir)\$(TargetName).hlp $(OutDir)\$(TargetName).hl_ \ | ||
928 | compress $(OutDir)\$(TargetName).cnt $(OutDir)\$(TargetName).cn_ \ | ||
929 | |||
930 | |||
931 | "$(OutDir)\$(TargetName).hlp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
932 | $(BuildCmds) | ||
933 | |||
934 | "$(OutDir)\$(TargetName).cnt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
935 | $(BuildCmds) | ||
936 | |||
937 | "$(OutDir)\$(TargetName).hl_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
938 | $(BuildCmds) | ||
939 | |||
940 | "$(OutDir)\$(TargetName).cn_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
941 | $(BuildCmds) | ||
942 | # End Custom Build | ||
943 | |||
944 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
945 | |||
946 | # Begin Custom Build - Making help file... | ||
947 | OutDir=.\RELEASE | ||
948 | ProjDir=. | ||
949 | TargetName=T42 | ||
950 | InputPath=.\help\T42.hpj | ||
951 | |||
952 | BuildCmds= \ | ||
953 | "$(ProjDir)\makehelp.bat" \ | ||
954 | compress $(OutDir)\$(TargetName).hlp $(OutDir)\$(TargetName).hl_ \ | ||
955 | compress $(OutDir)\$(TargetName).cnt $(OutDir)\$(TargetName).cn_ \ | ||
956 | |||
957 | |||
958 | "$(OutDir)\$(TargetName).hlp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
959 | $(BuildCmds) | ||
960 | |||
961 | "$(OutDir)\$(TargetName).cnt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
962 | $(BuildCmds) | ||
963 | |||
964 | "$(OutDir)\$(TargetName).hl_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
965 | $(BuildCmds) | ||
966 | |||
967 | "$(OutDir)\$(TargetName).cn_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
968 | $(BuildCmds) | ||
969 | # End Custom Build | ||
970 | |||
971 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
972 | |||
973 | # Begin Custom Build - Making help file... | ||
974 | OutDir=.\RELEAST | ||
975 | ProjDir=. | ||
976 | TargetName=T42 | ||
977 | InputPath=.\help\T42.hpj | ||
978 | |||
979 | BuildCmds= \ | ||
980 | "$(ProjDir)\makehelp.bat" \ | ||
981 | compress $(OutDir)\$(TargetName).hlp $(OutDir)\$(TargetName).hl_ \ | ||
982 | compress $(OutDir)\$(TargetName).cnt $(OutDir)\$(TargetName).cn_ \ | ||
983 | |||
984 | |||
985 | "$(OutDir)\$(TargetName).hlp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
986 | $(BuildCmds) | ||
987 | |||
988 | "$(OutDir)\$(TargetName).cnt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
989 | $(BuildCmds) | ||
990 | |||
991 | "$(OutDir)\$(TargetName).hl_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
992 | $(BuildCmds) | ||
993 | |||
994 | "$(OutDir)\$(TargetName).cn_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
995 | $(BuildCmds) | ||
996 | # End Custom Build | ||
997 | |||
998 | !ENDIF | ||
999 | |||
1000 | # End Source File | ||
1001 | ################################################################################ | ||
1002 | # Begin Source File | ||
1003 | |||
1004 | SOURCE=.\T42Frame.cpp | ||
1005 | DEP_CPP_T42FR=\ | ||
1006 | ".\CalleeDlg.h"\ | ||
1007 | ".\shared-code\BitSet.h"\ | ||
1008 | ".\shared-code\BTreendex.h"\ | ||
1009 | ".\shared-code\Dynamide.h"\ | ||
1010 | ".\shared-code\FindIFace.h"\ | ||
1011 | ".\shared-code\kHelpers.h"\ | ||
1012 | ".\shared-code\LRUCache.h"\ | ||
1013 | ".\shared-code\RegEx.h"\ | ||
1014 | ".\shared-code\SNMPeer.h"\ | ||
1015 | ".\shared-code\SNMPExtDll.h"\ | ||
1016 | ".\shared-code\SNMPOIDs.h"\ | ||
1017 | ".\stdafx.h"\ | ||
1018 | ".\T42.h"\ | ||
1019 | ".\T42CallLog.h"\ | ||
1020 | ".\T42Document.h"\ | ||
1021 | ".\T42Frame.h"\ | ||
1022 | ".\T42View.h"\ | ||
1023 | ".\talkd.h"\ | ||
1024 | |||
1025 | |||
1026 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
1027 | |||
1028 | |||
1029 | "$(INTDIR)\T42Frame.obj" : $(SOURCE) $(DEP_CPP_T42FR) "$(INTDIR)"\ | ||
1030 | "$(INTDIR)\T42.pch" | ||
1031 | |||
1032 | |||
1033 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
1034 | |||
1035 | |||
1036 | "$(INTDIR)\T42Frame.obj" : $(SOURCE) $(DEP_CPP_T42FR) "$(INTDIR)"\ | ||
1037 | "$(INTDIR)\T42.pch" | ||
1038 | |||
1039 | |||
1040 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
1041 | |||
1042 | |||
1043 | "$(INTDIR)\T42Frame.obj" : $(SOURCE) $(DEP_CPP_T42FR) "$(INTDIR)"\ | ||
1044 | "$(INTDIR)\T42.pch" | ||
1045 | |||
1046 | |||
1047 | !ENDIF | ||
1048 | |||
1049 | # End Source File | ||
1050 | ################################################################################ | ||
1051 | # Begin Source File | ||
1052 | |||
1053 | SOURCE=.\T42View.cpp | ||
1054 | DEP_CPP_T42VI=\ | ||
1055 | ".\shared-code\BitSet.h"\ | ||
1056 | ".\shared-code\BTreendex.h"\ | ||
1057 | ".\shared-code\Dynamide.h"\ | ||
1058 | ".\shared-code\FindIFace.h"\ | ||
1059 | ".\shared-code\kHelpers.h"\ | ||
1060 | ".\shared-code\LRUCache.h"\ | ||
1061 | ".\shared-code\SNMPeer.h"\ | ||
1062 | ".\shared-code\SNMPExtDll.h"\ | ||
1063 | ".\shared-code\SNMPOIDs.h"\ | ||
1064 | ".\stdafx.h"\ | ||
1065 | ".\T42.h"\ | ||
1066 | ".\T42CallLog.h"\ | ||
1067 | ".\T42Frame.h"\ | ||
1068 | ".\T42View.h"\ | ||
1069 | ".\talkd.h"\ | ||
1070 | |||
1071 | |||
1072 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
1073 | |||
1074 | |||
1075 | "$(INTDIR)\T42View.obj" : $(SOURCE) $(DEP_CPP_T42VI) "$(INTDIR)"\ | ||
1076 | "$(INTDIR)\T42.pch" | ||
1077 | |||
1078 | |||
1079 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
1080 | |||
1081 | |||
1082 | "$(INTDIR)\T42View.obj" : $(SOURCE) $(DEP_CPP_T42VI) "$(INTDIR)"\ | ||
1083 | "$(INTDIR)\T42.pch" | ||
1084 | |||
1085 | |||
1086 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
1087 | |||
1088 | |||
1089 | "$(INTDIR)\T42View.obj" : $(SOURCE) $(DEP_CPP_T42VI) "$(INTDIR)"\ | ||
1090 | "$(INTDIR)\T42.pch" | ||
1091 | |||
1092 | |||
1093 | !ENDIF | ||
1094 | |||
1095 | # End Source File | ||
1096 | ################################################################################ | ||
1097 | # Begin Source File | ||
1098 | |||
1099 | SOURCE=.\CalleeDlg.cpp | ||
1100 | DEP_CPP_CALLE=\ | ||
1101 | ".\CalleeDlg.h"\ | ||
1102 | ".\shared-code\BitSet.h"\ | ||
1103 | ".\shared-code\BTreendex.h"\ | ||
1104 | ".\shared-code\Dynamide.h"\ | ||
1105 | ".\shared-code\FindIFace.h"\ | ||
1106 | ".\shared-code\kHelpers.h"\ | ||
1107 | ".\shared-code\LRUCache.h"\ | ||
1108 | ".\shared-code\SNMPeer.h"\ | ||
1109 | ".\shared-code\SNMPExtDll.h"\ | ||
1110 | ".\shared-code\SNMPOIDs.h"\ | ||
1111 | ".\stdafx.h"\ | ||
1112 | ".\T42.h"\ | ||
1113 | ".\T42CallLog.h"\ | ||
1114 | ".\talkd.h"\ | ||
1115 | |||
1116 | |||
1117 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
1118 | |||
1119 | |||
1120 | "$(INTDIR)\CalleeDlg.obj" : $(SOURCE) $(DEP_CPP_CALLE) "$(INTDIR)"\ | ||
1121 | "$(INTDIR)\T42.pch" | ||
1122 | |||
1123 | |||
1124 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
1125 | |||
1126 | |||
1127 | "$(INTDIR)\CalleeDlg.obj" : $(SOURCE) $(DEP_CPP_CALLE) "$(INTDIR)"\ | ||
1128 | "$(INTDIR)\T42.pch" | ||
1129 | |||
1130 | |||
1131 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
1132 | |||
1133 | |||
1134 | "$(INTDIR)\CalleeDlg.obj" : $(SOURCE) $(DEP_CPP_CALLE) "$(INTDIR)"\ | ||
1135 | "$(INTDIR)\T42.pch" | ||
1136 | |||
1137 | |||
1138 | !ENDIF | ||
1139 | |||
1140 | # End Source File | ||
1141 | ################################################################################ | ||
1142 | # Begin Source File | ||
1143 | |||
1144 | SOURCE=.\T42Document.cpp | ||
1145 | DEP_CPP_T42DO=\ | ||
1146 | ".\shared-code\BitSet.h"\ | ||
1147 | ".\shared-code\BTreendex.h"\ | ||
1148 | ".\shared-code\Dynamide.h"\ | ||
1149 | ".\shared-code\FindIFace.h"\ | ||
1150 | ".\shared-code\kHelpers.h"\ | ||
1151 | ".\shared-code\LRUCache.h"\ | ||
1152 | ".\shared-code\SNMPeer.h"\ | ||
1153 | ".\shared-code\SNMPExtDll.h"\ | ||
1154 | ".\shared-code\SNMPOIDs.h"\ | ||
1155 | ".\stdafx.h"\ | ||
1156 | ".\T42.h"\ | ||
1157 | ".\T42CallLog.h"\ | ||
1158 | ".\T42Document.h"\ | ||
1159 | ".\T42Frame.h"\ | ||
1160 | ".\T42View.h"\ | ||
1161 | ".\talkd.h"\ | ||
1162 | |||
1163 | |||
1164 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
1165 | |||
1166 | |||
1167 | "$(INTDIR)\T42Document.obj" : $(SOURCE) $(DEP_CPP_T42DO) "$(INTDIR)"\ | ||
1168 | "$(INTDIR)\T42.pch" | ||
1169 | |||
1170 | |||
1171 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
1172 | |||
1173 | |||
1174 | "$(INTDIR)\T42Document.obj" : $(SOURCE) $(DEP_CPP_T42DO) "$(INTDIR)"\ | ||
1175 | "$(INTDIR)\T42.pch" | ||
1176 | |||
1177 | |||
1178 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
1179 | |||
1180 | |||
1181 | "$(INTDIR)\T42Document.obj" : $(SOURCE) $(DEP_CPP_T42DO) "$(INTDIR)"\ | ||
1182 | "$(INTDIR)\T42.pch" | ||
1183 | |||
1184 | |||
1185 | !ENDIF | ||
1186 | |||
1187 | # End Source File | ||
1188 | ################################################################################ | ||
1189 | # Begin Source File | ||
1190 | |||
1191 | SOURCE=.\T42AnnounceDlg.cpp | ||
1192 | DEP_CPP_T42AN=\ | ||
1193 | ".\shared-code\BitSet.h"\ | ||
1194 | ".\shared-code\BTreendex.h"\ | ||
1195 | ".\shared-code\Dynamide.h"\ | ||
1196 | ".\shared-code\FindIFace.h"\ | ||
1197 | ".\shared-code\kHelpers.h"\ | ||
1198 | ".\shared-code\LRUCache.h"\ | ||
1199 | ".\shared-code\SNMPeer.h"\ | ||
1200 | ".\shared-code\SNMPExtDll.h"\ | ||
1201 | ".\shared-code\SNMPOIDs.h"\ | ||
1202 | ".\stdafx.h"\ | ||
1203 | ".\T42.h"\ | ||
1204 | ".\T42AnnounceDlg.h"\ | ||
1205 | ".\T42CallLog.h"\ | ||
1206 | ".\talkd.h"\ | ||
1207 | |||
1208 | |||
1209 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
1210 | |||
1211 | |||
1212 | "$(INTDIR)\T42AnnounceDlg.obj" : $(SOURCE) $(DEP_CPP_T42AN) "$(INTDIR)"\ | ||
1213 | "$(INTDIR)\T42.pch" | ||
1214 | |||
1215 | |||
1216 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
1217 | |||
1218 | |||
1219 | "$(INTDIR)\T42AnnounceDlg.obj" : $(SOURCE) $(DEP_CPP_T42AN) "$(INTDIR)"\ | ||
1220 | "$(INTDIR)\T42.pch" | ||
1221 | |||
1222 | |||
1223 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
1224 | |||
1225 | |||
1226 | "$(INTDIR)\T42AnnounceDlg.obj" : $(SOURCE) $(DEP_CPP_T42AN) "$(INTDIR)"\ | ||
1227 | "$(INTDIR)\T42.pch" | ||
1228 | |||
1229 | |||
1230 | !ENDIF | ||
1231 | |||
1232 | # End Source File | ||
1233 | ################################################################################ | ||
1234 | # Begin Source File | ||
1235 | |||
1236 | SOURCE=.\SoundsPage.cpp | ||
1237 | DEP_CPP_SOUND=\ | ||
1238 | ".\shared-code\BitSet.h"\ | ||
1239 | ".\shared-code\BTreendex.h"\ | ||
1240 | ".\shared-code\Dynamide.h"\ | ||
1241 | ".\shared-code\FindIFace.h"\ | ||
1242 | ".\shared-code\kHelpers.h"\ | ||
1243 | ".\shared-code\LRUCache.h"\ | ||
1244 | ".\shared-code\SNMPeer.h"\ | ||
1245 | ".\shared-code\SNMPExtDll.h"\ | ||
1246 | ".\shared-code\SNMPOIDs.h"\ | ||
1247 | ".\SoundsPage.h"\ | ||
1248 | ".\stdafx.h"\ | ||
1249 | ".\T42.h"\ | ||
1250 | ".\T42CallLog.h"\ | ||
1251 | ".\talkd.h"\ | ||
1252 | |||
1253 | |||
1254 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
1255 | |||
1256 | |||
1257 | "$(INTDIR)\SoundsPage.obj" : $(SOURCE) $(DEP_CPP_SOUND) "$(INTDIR)"\ | ||
1258 | "$(INTDIR)\T42.pch" | ||
1259 | |||
1260 | |||
1261 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
1262 | |||
1263 | |||
1264 | "$(INTDIR)\SoundsPage.obj" : $(SOURCE) $(DEP_CPP_SOUND) "$(INTDIR)"\ | ||
1265 | "$(INTDIR)\T42.pch" | ||
1266 | |||
1267 | |||
1268 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
1269 | |||
1270 | |||
1271 | "$(INTDIR)\SoundsPage.obj" : $(SOURCE) $(DEP_CPP_SOUND) "$(INTDIR)"\ | ||
1272 | "$(INTDIR)\T42.pch" | ||
1273 | |||
1274 | |||
1275 | !ENDIF | ||
1276 | |||
1277 | # End Source File | ||
1278 | ################################################################################ | ||
1279 | # Begin Source File | ||
1280 | |||
1281 | SOURCE=.\FontsPage.cpp | ||
1282 | DEP_CPP_FONTS=\ | ||
1283 | ".\ColorButton.h"\ | ||
1284 | ".\FontsPage.h"\ | ||
1285 | ".\shared-code\BitSet.h"\ | ||
1286 | ".\shared-code\BTreendex.h"\ | ||
1287 | ".\shared-code\Dynamide.h"\ | ||
1288 | ".\shared-code\FindIFace.h"\ | ||
1289 | ".\shared-code\kHelpers.h"\ | ||
1290 | ".\shared-code\LRUCache.h"\ | ||
1291 | ".\shared-code\SNMPeer.h"\ | ||
1292 | ".\shared-code\SNMPExtDll.h"\ | ||
1293 | ".\shared-code\SNMPOIDs.h"\ | ||
1294 | ".\stdafx.h"\ | ||
1295 | ".\T42.h"\ | ||
1296 | ".\T42CallLog.h"\ | ||
1297 | ".\talkd.h"\ | ||
1298 | |||
1299 | |||
1300 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
1301 | |||
1302 | |||
1303 | "$(INTDIR)\FontsPage.obj" : $(SOURCE) $(DEP_CPP_FONTS) "$(INTDIR)"\ | ||
1304 | "$(INTDIR)\T42.pch" | ||
1305 | |||
1306 | |||
1307 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
1308 | |||
1309 | |||
1310 | "$(INTDIR)\FontsPage.obj" : $(SOURCE) $(DEP_CPP_FONTS) "$(INTDIR)"\ | ||
1311 | "$(INTDIR)\T42.pch" | ||
1312 | |||
1313 | |||
1314 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
1315 | |||
1316 | |||
1317 | "$(INTDIR)\FontsPage.obj" : $(SOURCE) $(DEP_CPP_FONTS) "$(INTDIR)"\ | ||
1318 | "$(INTDIR)\T42.pch" | ||
1319 | |||
1320 | |||
1321 | !ENDIF | ||
1322 | |||
1323 | # End Source File | ||
1324 | ################################################################################ | ||
1325 | # Begin Source File | ||
1326 | |||
1327 | SOURCE=.\ColorButton.cpp | ||
1328 | DEP_CPP_COLOR=\ | ||
1329 | ".\ColorButton.h"\ | ||
1330 | ".\shared-code\BitSet.h"\ | ||
1331 | ".\shared-code\BTreendex.h"\ | ||
1332 | ".\shared-code\Dynamide.h"\ | ||
1333 | ".\shared-code\FindIFace.h"\ | ||
1334 | ".\shared-code\kHelpers.h"\ | ||
1335 | ".\shared-code\LRUCache.h"\ | ||
1336 | ".\shared-code\SNMPeer.h"\ | ||
1337 | ".\shared-code\SNMPExtDll.h"\ | ||
1338 | ".\shared-code\SNMPOIDs.h"\ | ||
1339 | ".\stdafx.h"\ | ||
1340 | ".\T42.h"\ | ||
1341 | ".\T42CallLog.h"\ | ||
1342 | ".\talkd.h"\ | ||
1343 | |||
1344 | |||
1345 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
1346 | |||
1347 | |||
1348 | "$(INTDIR)\ColorButton.obj" : $(SOURCE) $(DEP_CPP_COLOR) "$(INTDIR)"\ | ||
1349 | "$(INTDIR)\T42.pch" | ||
1350 | |||
1351 | |||
1352 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
1353 | |||
1354 | |||
1355 | "$(INTDIR)\ColorButton.obj" : $(SOURCE) $(DEP_CPP_COLOR) "$(INTDIR)"\ | ||
1356 | "$(INTDIR)\T42.pch" | ||
1357 | |||
1358 | |||
1359 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
1360 | |||
1361 | |||
1362 | "$(INTDIR)\ColorButton.obj" : $(SOURCE) $(DEP_CPP_COLOR) "$(INTDIR)"\ | ||
1363 | "$(INTDIR)\T42.pch" | ||
1364 | |||
1365 | |||
1366 | !ENDIF | ||
1367 | |||
1368 | # End Source File | ||
1369 | ################################################################################ | ||
1370 | # Begin Source File | ||
1371 | |||
1372 | SOURCE=.\SecretaryPage.cpp | ||
1373 | DEP_CPP_SECRE=\ | ||
1374 | ".\SecretaryPage.h"\ | ||
1375 | ".\shared-code\BitSet.h"\ | ||
1376 | ".\shared-code\BTreendex.h"\ | ||
1377 | ".\shared-code\Dynamide.h"\ | ||
1378 | ".\shared-code\FindIFace.h"\ | ||
1379 | ".\shared-code\kHelpers.h"\ | ||
1380 | ".\shared-code\LRUCache.h"\ | ||
1381 | ".\shared-code\SNMPeer.h"\ | ||
1382 | ".\shared-code\SNMPExtDll.h"\ | ||
1383 | ".\shared-code\SNMPOIDs.h"\ | ||
1384 | ".\stdafx.h"\ | ||
1385 | ".\T42.h"\ | ||
1386 | ".\T42CallLog.h"\ | ||
1387 | ".\talkd.h"\ | ||
1388 | |||
1389 | |||
1390 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
1391 | |||
1392 | |||
1393 | "$(INTDIR)\SecretaryPage.obj" : $(SOURCE) $(DEP_CPP_SECRE) "$(INTDIR)"\ | ||
1394 | "$(INTDIR)\T42.pch" | ||
1395 | |||
1396 | |||
1397 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
1398 | |||
1399 | |||
1400 | "$(INTDIR)\SecretaryPage.obj" : $(SOURCE) $(DEP_CPP_SECRE) "$(INTDIR)"\ | ||
1401 | "$(INTDIR)\T42.pch" | ||
1402 | |||
1403 | |||
1404 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
1405 | |||
1406 | |||
1407 | "$(INTDIR)\SecretaryPage.obj" : $(SOURCE) $(DEP_CPP_SECRE) "$(INTDIR)"\ | ||
1408 | "$(INTDIR)\T42.pch" | ||
1409 | |||
1410 | |||
1411 | !ENDIF | ||
1412 | |||
1413 | # End Source File | ||
1414 | ################################################################################ | ||
1415 | # Begin Source File | ||
1416 | |||
1417 | SOURCE=.\T42Secretary.cpp | ||
1418 | DEP_CPP_T42SE=\ | ||
1419 | ".\shared-code\BitSet.h"\ | ||
1420 | ".\shared-code\BTreendex.h"\ | ||
1421 | ".\shared-code\Dynamide.h"\ | ||
1422 | ".\shared-code\FindIFace.h"\ | ||
1423 | ".\shared-code\kHelpers.h"\ | ||
1424 | ".\shared-code\LRUCache.h"\ | ||
1425 | ".\shared-code\SNMPeer.h"\ | ||
1426 | ".\shared-code\SNMPExtDll.h"\ | ||
1427 | ".\shared-code\SNMPOIDs.h"\ | ||
1428 | ".\stdafx.h"\ | ||
1429 | ".\T42.h"\ | ||
1430 | ".\T42CallLog.h"\ | ||
1431 | ".\T42Document.h"\ | ||
1432 | ".\T42Frame.h"\ | ||
1433 | ".\T42Secretary.h"\ | ||
1434 | ".\T42View.h"\ | ||
1435 | ".\talkd.h"\ | ||
1436 | |||
1437 | |||
1438 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
1439 | |||
1440 | |||
1441 | "$(INTDIR)\T42Secretary.obj" : $(SOURCE) $(DEP_CPP_T42SE) "$(INTDIR)"\ | ||
1442 | "$(INTDIR)\T42.pch" | ||
1443 | |||
1444 | |||
1445 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
1446 | |||
1447 | |||
1448 | "$(INTDIR)\T42Secretary.obj" : $(SOURCE) $(DEP_CPP_T42SE) "$(INTDIR)"\ | ||
1449 | "$(INTDIR)\T42.pch" | ||
1450 | |||
1451 | |||
1452 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
1453 | |||
1454 | |||
1455 | "$(INTDIR)\T42Secretary.obj" : $(SOURCE) $(DEP_CPP_T42SE) "$(INTDIR)"\ | ||
1456 | "$(INTDIR)\T42.pch" | ||
1457 | |||
1458 | |||
1459 | !ENDIF | ||
1460 | |||
1461 | # End Source File | ||
1462 | ################################################################################ | ||
1463 | # Begin Source File | ||
1464 | |||
1465 | SOURCE=.\GeneralPage.cpp | ||
1466 | DEP_CPP_GENER=\ | ||
1467 | ".\GeneralPage.h"\ | ||
1468 | ".\shared-code\BitSet.h"\ | ||
1469 | ".\shared-code\BTreendex.h"\ | ||
1470 | ".\shared-code\Dynamide.h"\ | ||
1471 | ".\shared-code\FindIFace.h"\ | ||
1472 | ".\shared-code\kHelpers.h"\ | ||
1473 | ".\shared-code\LRUCache.h"\ | ||
1474 | ".\shared-code\SNMPeer.h"\ | ||
1475 | ".\shared-code\SNMPExtDll.h"\ | ||
1476 | ".\shared-code\SNMPOIDs.h"\ | ||
1477 | ".\stdafx.h"\ | ||
1478 | ".\T42.h"\ | ||
1479 | ".\T42CallLog.h"\ | ||
1480 | ".\talkd.h"\ | ||
1481 | |||
1482 | |||
1483 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
1484 | |||
1485 | |||
1486 | "$(INTDIR)\GeneralPage.obj" : $(SOURCE) $(DEP_CPP_GENER) "$(INTDIR)"\ | ||
1487 | "$(INTDIR)\T42.pch" | ||
1488 | |||
1489 | |||
1490 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
1491 | |||
1492 | |||
1493 | "$(INTDIR)\GeneralPage.obj" : $(SOURCE) $(DEP_CPP_GENER) "$(INTDIR)"\ | ||
1494 | "$(INTDIR)\T42.pch" | ||
1495 | |||
1496 | |||
1497 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
1498 | |||
1499 | |||
1500 | "$(INTDIR)\GeneralPage.obj" : $(SOURCE) $(DEP_CPP_GENER) "$(INTDIR)"\ | ||
1501 | "$(INTDIR)\T42.pch" | ||
1502 | |||
1503 | |||
1504 | !ENDIF | ||
1505 | |||
1506 | # End Source File | ||
1507 | ################################################################################ | ||
1508 | # Begin Source File | ||
1509 | |||
1510 | SOURCE=".\shared-code\RegEx.cpp" | ||
1511 | DEP_CPP_REGEX=\ | ||
1512 | ".\shared-code\BitSet.h"\ | ||
1513 | ".\shared-code\BTreendex.h"\ | ||
1514 | ".\shared-code\Dynamide.h"\ | ||
1515 | ".\shared-code\FindIFace.h"\ | ||
1516 | ".\shared-code\kHelpers.h"\ | ||
1517 | ".\shared-code\LRUCache.h"\ | ||
1518 | ".\shared-code\RegEx.h"\ | ||
1519 | ".\shared-code\SNMPeer.h"\ | ||
1520 | ".\shared-code\SNMPExtDll.h"\ | ||
1521 | ".\shared-code\SNMPOIDs.h"\ | ||
1522 | ".\stdafx.h"\ | ||
1523 | ".\T42CallLog.h"\ | ||
1524 | ".\talkd.h"\ | ||
1525 | |||
1526 | |||
1527 | !IF "$(CFG)" == "T42 - Win32 Debug" | ||
1528 | |||
1529 | # ADD CPP /Yu"../stdafx.h" | ||
1530 | |||
1531 | "$(INTDIR)\RegEx.obj" : $(SOURCE) $(DEP_CPP_REGEX) "$(INTDIR)"\ | ||
1532 | "$(INTDIR)\T42.pch" | ||
1533 | $(CPP) /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\ | ||
1534 | /D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/T42.pch" /Yu"../stdafx.h" /Fo"$(INTDIR)/"\ | ||
1535 | /Fd"$(INTDIR)/" /c $(SOURCE) | ||
1536 | |||
1537 | |||
1538 | !ELSEIF "$(CFG)" == "T42 - Win32 Pure" | ||
1539 | |||
1540 | # ADD CPP /Yu"../stdafx.h" | ||
1541 | |||
1542 | "$(INTDIR)\RegEx.obj" : $(SOURCE) $(DEP_CPP_REGEX) "$(INTDIR)"\ | ||
1543 | "$(INTDIR)\T42.pch" | ||
1544 | $(CPP) /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\ | ||
1545 | "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/T42.pch" /Yu"../stdafx.h" /Fo"$(INTDIR)/" /c\ | ||
1546 | $(SOURCE) | ||
1547 | |||
1548 | |||
1549 | !ELSEIF "$(CFG)" == "T42 - Win32 Static" | ||
1550 | |||
1551 | # ADD CPP /Yu"../stdafx.h" | ||
1552 | |||
1553 | "$(INTDIR)\RegEx.obj" : $(SOURCE) $(DEP_CPP_REGEX) "$(INTDIR)"\ | ||
1554 | "$(INTDIR)\T42.pch" | ||
1555 | $(CPP) /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\ | ||
1556 | "_MBCS" /Fp"$(INTDIR)/T42.pch" /Yu"../stdafx.h" /Fo"$(INTDIR)/" /c $(SOURCE) | ||
1557 | |||
1558 | |||
1559 | !ENDIF | ||
1560 | |||
1561 | # End Source File | ||
1562 | # End Target | ||
1563 | ################################################################################ | ||
1564 | # Begin Target | ||
1565 | |||
1566 | # Name "Install - Win32 Debug" | ||
1567 | # Name "Install - Win32 Pure" | ||
1568 | # Name "Install - Win32 Static" | ||
1569 | # Name "Install - Win32 Canned" | ||
1570 | |||
1571 | !IF "$(CFG)" == "Install - Win32 Debug" | ||
1572 | |||
1573 | !ELSEIF "$(CFG)" == "Install - Win32 Pure" | ||
1574 | |||
1575 | !ELSEIF "$(CFG)" == "Install - Win32 Static" | ||
1576 | |||
1577 | !ELSEIF "$(CFG)" == "Install - Win32 Canned" | ||
1578 | |||
1579 | !ENDIF | ||
1580 | |||
1581 | ################################################################################ | ||
1582 | # Begin Source File | ||
1583 | |||
1584 | SOURCE=.\Install\Install.rc | ||
1585 | DEP_RSC_INSTA=\ | ||
1586 | ".\Install\Custom.rch"\ | ||
1587 | ".\shared-data\install-icon.ico"\ | ||
1588 | |||
1589 | |||
1590 | !IF "$(CFG)" == "Install - Win32 Debug" | ||
1591 | |||
1592 | |||
1593 | "$(INTDIR)\Install.res" : $(SOURCE) $(DEP_RSC_INSTA) "$(INTDIR)" | ||
1594 | $(RSC) /l 0x409 /fo"$(INTDIR)/Install.res" /i "Install" /d "_DEBUG" /d\ | ||
1595 | "_AFXDLL" $(SOURCE) | ||
1596 | |||
1597 | |||
1598 | !ELSEIF "$(CFG)" == "Install - Win32 Pure" | ||
1599 | |||
1600 | |||
1601 | "$(INTDIR)\Install.res" : $(SOURCE) $(DEP_RSC_INSTA) "$(INTDIR)" | ||
1602 | $(RSC) /l 0x409 /fo"$(INTDIR)/Install.res" /i "Install" /d "NDEBUG"\ | ||
1603 | $(SOURCE) | ||
1604 | |||
1605 | |||
1606 | !ELSEIF "$(CFG)" == "Install - Win32 Static" | ||
1607 | |||
1608 | |||
1609 | "$(INTDIR)\Install.res" : $(SOURCE) $(DEP_RSC_INSTA) "$(INTDIR)" | ||
1610 | $(RSC) /l 0x409 /fo"$(INTDIR)/Install.res" /i "Install" /d "NDEBUG" /d\ | ||
1611 | "STATI_K" $(SOURCE) | ||
1612 | |||
1613 | |||
1614 | !ELSEIF "$(CFG)" == "Install - Win32 Canned" | ||
1615 | |||
1616 | |||
1617 | "$(INTDIR)\Install.res" : $(SOURCE) $(DEP_RSC_INSTA) "$(INTDIR)" | ||
1618 | $(RSC) /l 0x409 /fo"$(INTDIR)/Install.res" /i "Install" /d "NDEBUG" /d\ | ||
1619 | "K_ANNED" $(SOURCE) | ||
1620 | |||
1621 | |||
1622 | !ENDIF | ||
1623 | |||
1624 | # End Source File | ||
1625 | ################################################################################ | ||
1626 | # Begin Source File | ||
1627 | |||
1628 | SOURCE=.\Install\install.cpp | ||
1629 | DEP_CPP_INSTAL=\ | ||
1630 | ".\shared-code\install.h"\ | ||
1631 | |||
1632 | |||
1633 | !IF "$(CFG)" == "Install - Win32 Debug" | ||
1634 | |||
1635 | |||
1636 | "$(INTDIR)\install.obj" : $(SOURCE) $(DEP_CPP_INSTAL) "$(INTDIR)" | ||
1637 | $(CPP) $(CPP_PROJ) $(SOURCE) | ||
1638 | |||
1639 | |||
1640 | !ELSEIF "$(CFG)" == "Install - Win32 Pure" | ||
1641 | |||
1642 | |||
1643 | "$(INTDIR)\install.obj" : $(SOURCE) $(DEP_CPP_INSTAL) "$(INTDIR)" | ||
1644 | $(CPP) $(CPP_PROJ) $(SOURCE) | ||
1645 | |||
1646 | |||
1647 | !ELSEIF "$(CFG)" == "Install - Win32 Static" | ||
1648 | |||
1649 | |||
1650 | "$(INTDIR)\install.obj" : $(SOURCE) $(DEP_CPP_INSTAL) "$(INTDIR)" | ||
1651 | $(CPP) $(CPP_PROJ) $(SOURCE) | ||
1652 | |||
1653 | |||
1654 | !ELSEIF "$(CFG)" == "Install - Win32 Canned" | ||
1655 | |||
1656 | |||
1657 | "$(INTDIR)\install.obj" : $(SOURCE) $(DEP_CPP_INSTAL) "$(INTDIR)" | ||
1658 | $(CPP) $(CPP_PROJ) $(SOURCE) | ||
1659 | |||
1660 | |||
1661 | !ENDIF | ||
1662 | |||
1663 | # End Source File | ||
1664 | ################################################################################ | ||
1665 | # Begin Project Dependency | ||
1666 | |||
1667 | # Project_Dep_Name "T42" | ||
1668 | |||
1669 | !IF "$(CFG)" == "Install - Win32 Debug" | ||
1670 | |||
1671 | "T42 - Win32 Debug" : | ||
1672 | $(MAKE) /$(MAKEFLAGS) /F ".\T42.mak" CFG="T42 - Win32 Debug" | ||
1673 | |||
1674 | !ELSEIF "$(CFG)" == "Install - Win32 Pure" | ||
1675 | |||
1676 | "T42 - Win32 Pure" : | ||
1677 | $(MAKE) /$(MAKEFLAGS) /F ".\T42.mak" CFG="T42 - Win32 Pure" | ||
1678 | |||
1679 | !ELSEIF "$(CFG)" == "Install - Win32 Static" | ||
1680 | |||
1681 | "T42 - Win32 Static" : | ||
1682 | $(MAKE) /$(MAKEFLAGS) /F ".\T42.mak" CFG="T42 - Win32 Static" | ||
1683 | |||
1684 | !ELSEIF "$(CFG)" == "Install - Win32 Canned" | ||
1685 | |||
1686 | !ENDIF | ||
1687 | |||
1688 | # End Project Dependency | ||
1689 | # End Target | ||
1690 | # End Project | ||
1691 | ################################################################################ | ||
@@ -0,0 +1,837 @@ | |||
1 | //Microsoft Developer Studio generated resource script. | ||
2 | // | ||
3 | #include "resource.h" | ||
4 | |||
5 | #define APSTUDIO_READONLY_SYMBOLS | ||
6 | ///////////////////////////////////////////////////////////////////////////// | ||
7 | // | ||
8 | // Generated from the TEXTINCLUDE 2 resource. | ||
9 | // | ||
10 | #include "afxres.h" | ||
11 | |||
12 | ///////////////////////////////////////////////////////////////////////////// | ||
13 | #undef APSTUDIO_READONLY_SYMBOLS | ||
14 | |||
15 | ///////////////////////////////////////////////////////////////////////////// | ||
16 | // English (U.S.) resources | ||
17 | |||
18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) | ||
19 | #ifdef _WIN32 | ||
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US | ||
21 | #pragma code_page(1252) | ||
22 | #endif //_WIN32 | ||
23 | |||
24 | #ifdef APSTUDIO_INVOKED | ||
25 | ///////////////////////////////////////////////////////////////////////////// | ||
26 | // | ||
27 | // TEXTINCLUDE | ||
28 | // | ||
29 | |||
30 | 1 TEXTINCLUDE DISCARDABLE | ||
31 | BEGIN | ||
32 | "resource.h\0" | ||
33 | END | ||
34 | |||
35 | 2 TEXTINCLUDE DISCARDABLE | ||
36 | BEGIN | ||
37 | "#include ""afxres.h""\r\n" | ||
38 | "\0" | ||
39 | END | ||
40 | |||
41 | 3 TEXTINCLUDE DISCARDABLE | ||
42 | BEGIN | ||
43 | "#define _AFX_NO_SPLITTER_RESOURCES\r\n" | ||
44 | "#define _AFX_NO_OLE_RESOURCES\r\n" | ||
45 | "#define _AFX_NO_TRACKER_RESOURCES\r\n" | ||
46 | "#define _AFX_NO_PROPERTY_RESOURCES\r\n" | ||
47 | "\r\n" | ||
48 | "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" | ||
49 | "#ifdef _WIN32\r\n" | ||
50 | "LANGUAGE 9, 1\r\n" | ||
51 | "#pragma code_page(1252)\r\n" | ||
52 | "#endif\r\n" | ||
53 | "#include ""res\\T42.rc2"" // non-Microsoft Visual C++ edited resources\r\n" | ||
54 | "#include ""afxres.rc"" // Standard components\r\n" | ||
55 | "#endif\0" | ||
56 | END | ||
57 | |||
58 | #endif // APSTUDIO_INVOKED | ||
59 | |||
60 | |||
61 | ///////////////////////////////////////////////////////////////////////////// | ||
62 | // | ||
63 | // Icon | ||
64 | // | ||
65 | |||
66 | // Icon with lowest ID value placed first to ensure application icon | ||
67 | // remains consistent on all systems. | ||
68 | IDR_MAINFRAME ICON DISCARDABLE "res\\T42.ico" | ||
69 | IDR_T42FRAME ICON DISCARDABLE "res\\IDR_T42F.ico" | ||
70 | IDI_FULLCUP ICON DISCARDABLE "res\\fullcup.ico" | ||
71 | IDR_FULLT42 ICON DISCARDABLE "res\\IDR_FULL.ico" | ||
72 | IDI_BROWSE ICON DISCARDABLE "shared-data/browse-icon.ico" | ||
73 | IDI_T42CALLNEW ICON DISCARDABLE "res\\T42calln.ico" | ||
74 | IDI_T42CALLPROCESSED ICON DISCARDABLE "res\\T42callp.ico" | ||
75 | IDR_FLIPPEDCUP ICON DISCARDABLE "res\\IDR_FLIP.ico" | ||
76 | IDI_PREPLAY ICON DISCARDABLE "shared-data/play-icon.ico" | ||
77 | |||
78 | ///////////////////////////////////////////////////////////////////////////// | ||
79 | // | ||
80 | // Dialog | ||
81 | // | ||
82 | |||
83 | IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 194, 78 | ||
84 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||
85 | CAPTION "About T42" | ||
86 | FONT 8, "MS Sans Serif" | ||
87 | BEGIN | ||
88 | LTEXT "T42, Version 1.5",IDC_STATIC,37,10,119,8,SS_NOPREFIX | ||
89 | LTEXT "Copyright © 1998,2002 Klever Group",IDC_STATIC,37,25,119,8 | ||
90 | ICON IDR_MAINFRAME,IDC_STATIC,7,34,18,20 | ||
91 | ICON IDR_FLIPPEDCUP,IDC_STATIC,166,34,18,20 | ||
92 | DEFPUSHBUTTON "OK",IDOK,81,40,32,14,WS_GROUP | ||
93 | PUSHBUTTON "http://www.klever.net/",IDC_KLEVERNET,107,59,80,12 | ||
94 | END | ||
95 | |||
96 | IDD_T42_DIALOG DIALOGEX 0, 0, 221, 200 | ||
97 | STYLE DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | ||
98 | EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE | WS_EX_CONTEXTHELP | | ||
99 | WS_EX_APPWINDOW | ||
100 | CAPTION " Tea For Two " | ||
101 | FONT 8, "MS Sans Serif", 0, 0, 0x1 | ||
102 | BEGIN | ||
103 | CTEXT "On &Call:",IDC_STATIC,7,7,93,56,0,WS_EX_DLGMODALFRAME | | ||
104 | WS_EX_CLIENTEDGE | ||
105 | COMBOBOX IDC_ONCALL,13,19,81,76,CBS_DROPDOWNLIST | WS_VSCROLL | | ||
106 | WS_TABSTOP | ||
107 | CTEXT "When &Away:",IDC_STATIC,13,33,81,8 | ||
108 | COMBOBOX IDC_ONCALLAWAY,13,43,81,76,CBS_DROPDOWNLIST | WS_VSCROLL | | ||
109 | WS_TABSTOP | ||
110 | CONTROL "Calls",IDC_CALLS,"SysListView32",LVS_REPORT | WS_BORDER | | ||
111 | WS_TABSTOP,7,66,207,67 | ||
112 | CONTROL "Recorded Message..",IDC_PREVIEW,"RICHEDIT",WS_VSCROLL | | ||
113 | WS_TABSTOP | 0xc184,7,134,207,59 | ||
114 | PUSHBUTTON "&Tea",IDC_TALK,173,7,41,13 | ||
115 | PUSHBUTTON "&Options",IDC_OPTIONS,173,21,41,13 | ||
116 | PUSHBUTTON "E&xit",IDOK,173,35,41,13 | ||
117 | PUSHBUTTON "&Help",ID_HELP,173,49,41,13 | ||
118 | DEFPUSHBUTTON "",IDCANCEL,0,0,6,6,NOT WS_VISIBLE | ||
119 | CONTROL "A&way",IDC_AWAY,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | | ||
120 | BS_MULTILINE | WS_TABSTOP,101,7,41,56, | ||
121 | WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | | ||
122 | WS_EX_STATICEDGE | ||
123 | END | ||
124 | |||
125 | IDD_REMOTE DIALOGEX 0, 0, 153, 111 | ||
126 | STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION | ||
127 | EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE | ||
128 | CAPTION " It's party time!" | ||
129 | FONT 8, "MS Sans Serif", 0, 0, 0x1 | ||
130 | BEGIN | ||
131 | LTEXT "&Dear ",IDC_STATIC,7,9,18,8 | ||
132 | COMBOBOX IDC_CALLEE,29,7,117,56,CBS_DROPDOWN | CBS_AUTOHSCROLL | | ||
133 | WS_VSCROLL | WS_TABSTOP | ||
134 | LTEXT "yes, you on &tty ",IDC_STATIC,41,23,48,8 | ||
135 | COMBOBOX IDC_TTY,98,21,48,79,CBS_DROPDOWN | CBS_AUTOHSCROLL | | ||
136 | WS_VSCROLL | WS_TABSTOP | ||
137 | LTEXT "I'd love to have a cup of tea with you. How about right now?", | ||
138 | IDC_STATIC,19,36,112,28 | ||
139 | LTEXT "Yours,",IDC_STATIC,7,67,22,8 | ||
140 | COMBOBOX IDC_CALLER,46,73,100,30,CBS_DROPDOWN | CBS_AUTOHSCROLL | | ||
141 | WS_VSCROLL | WS_TABSTOP | ||
142 | DEFPUSHBUTTON "OK",IDOK,18,90,50,14 | ||
143 | PUSHBUTTON "Cancel",IDCANCEL,84,90,50,14 | ||
144 | END | ||
145 | |||
146 | IDD_T42VIEW DIALOG DISCARDABLE 0, 0, 185, 93 | ||
147 | STYLE DS_3DLOOK | WS_CHILD | ||
148 | FONT 8, "MS Sans Serif" | ||
149 | BEGIN | ||
150 | CONTROL "",IDC_SPLIT,"Static",SS_SIMPLE | SS_NOTIFY,93,1,8,91 | ||
151 | END | ||
152 | |||
153 | IDD_ANNOUNCE DIALOGEX 0, 0, 141, 139 | ||
154 | STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_POPUP | | ||
155 | WS_CAPTION | ||
156 | EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE | ||
157 | CAPTION " It's a party and you're invited!" | ||
158 | FONT 8, "MS Sans Serif", 0, 0, 0x1 | ||
159 | BEGIN | ||
160 | DEFPUSHBUTTON "&Yes, I'd appreciate some milk",IDOK,7,81,127,14 | ||
161 | PUSHBUTTON "Not now, have a cup of tea with my &secretary", | ||
162 | IDC_SECRETARY,7,96,127,21,BS_MULTILINE | ||
163 | PUSHBUTTON "&No, thanks, I'm out to cofee house.",IDCANCEL,7,118, | ||
164 | 127,14 | ||
165 | LTEXT "Dear ",IDC_STATIC,7,7,18,8 | ||
166 | LTEXT "..",IDC_CALLEE,27,7,107,8,SS_NOPREFIX | ||
167 | RTEXT "..",IDC_TTY,7,16,127,10 | ||
168 | LTEXT "I'd love to have a cup of tea with you. How about right now?", | ||
169 | IDC_STATIC,15,28,112,19 | ||
170 | LTEXT "Yours,",IDC_STATIC,15,50,21,8 | ||
171 | RTEXT "..",IDC_CALLER,7,59,127,20,SS_NOPREFIX | ||
172 | PUSHBUTTON "",IDC_NOTHERE,0,132,6,6,NOT WS_VISIBLE | NOT WS_TABSTOP | ||
173 | PUSHBUTTON "",IDC_REFUSE,7,132,6,6,NOT WS_VISIBLE | NOT WS_TABSTOP | ||
174 | END | ||
175 | |||
176 | IDD_OPTIONS_SOUNDS DIALOG DISCARDABLE 0, 0, 210, 154 | ||
177 | STYLE WS_CHILD | WS_DISABLED | WS_CAPTION | ||
178 | CAPTION "Sounds" | ||
179 | FONT 8, "MS Sans Serif" | ||
180 | BEGIN | ||
181 | LTEXT "&Bell in T42 conversation window:",IDC_STATIC,7,5,83,16 | ||
182 | COMBOBOX IDC_T42BELL,90,5,83,65,CBS_DROPDOWN | CBS_AUTOHSCROLL | | ||
183 | CBS_SORT | WS_VSCROLL | WS_TABSTOP | ||
184 | PUSHBUTTON "Bell Browse",IDC_T42BELL_BROWSE,175,5,13,13,BS_ICON | | ||
185 | BS_CENTER | BS_VCENTER | ||
186 | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,25,196,1 | ||
187 | LTEXT "&Prompt sound alert:",IDC_STATIC,7,30,83,8 | ||
188 | COMBOBOX IDC_T42PROMPT,90,30,83,65,CBS_DROPDOWN | CBS_AUTOHSCROLL | | ||
189 | CBS_SORT | WS_VSCROLL | WS_TABSTOP | ||
190 | PUSHBUTTON "Prompt Browse",IDC_T42PROMPT_BROWSE,175,30,13,13, | ||
191 | BS_ICON | BS_CENTER | BS_VCENTER | ||
192 | CONTROL "&Loop sound",IDC_T42PROMPT_LOOP,"Button", | ||
193 | BS_AUTOCHECKBOX | WS_TABSTOP,36,40,53,8 | ||
194 | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,50,196,1 | ||
195 | LTEXT "&Wake-up sound alert:",IDC_STATIC,7,55,83,16 | ||
196 | COMBOBOX IDC_T42WAKE,90,55,83,65,CBS_DROPDOWN | CBS_AUTOHSCROLL | | ||
197 | CBS_SORT | WS_VSCROLL | WS_TABSTOP | ||
198 | PUSHBUTTON "Wake Browse",IDC_T42WAKE_BROWSE,175,55,13,13,BS_ICON | | ||
199 | BS_CENTER | BS_VCENTER | ||
200 | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,75,196,1 | ||
201 | PUSHBUTTON "Bell Play",IDC_T42BELL_PLAY,190,5,13,13,BS_ICON | | ||
202 | BS_CENTER | BS_VCENTER | ||
203 | PUSHBUTTON "Prompt Play",IDC_T42PROMPT_PLAY,190,30,13,13,BS_ICON | | ||
204 | BS_CENTER | BS_VCENTER | ||
205 | PUSHBUTTON "Wake Play",IDC_T42WAKE_PLAY,190,55,13,13,BS_ICON | | ||
206 | BS_CENTER | BS_VCENTER | ||
207 | END | ||
208 | |||
209 | IDD_OPTIONS_FONTS DIALOG DISCARDABLE 0, 0, 210, 154 | ||
210 | STYLE WS_CHILD | WS_DISABLED | WS_CAPTION | ||
211 | CAPTION "Format" | ||
212 | FONT 8, "MS Sans Serif" | ||
213 | BEGIN | ||
214 | LTEXT "F&ormat:",IDC_STATIC,7,5,24,8 | ||
215 | LISTBOX IDC_FORMATNAME,7,15,60,85,LBS_NOINTEGRALHEIGHT | | ||
216 | WS_VSCROLL | WS_TABSTOP | ||
217 | LTEXT "Font &face:",IDC_STATIC,70,5,33,8 | ||
218 | COMBOBOX IDC_FACES,70,15,90,72,CBS_DROPDOWNLIST | CBS_SORT | | ||
219 | WS_VSCROLL | WS_TABSTOP | ||
220 | LTEXT "Font &size:",IDC_STATIC,163,5,31,8 | ||
221 | COMBOBOX IDC_FONTSIZE,163,15,40,72,CBS_DROPDOWN | CBS_AUTOHSCROLL | | ||
222 | WS_VSCROLL | WS_TABSTOP | ||
223 | CONTROL "&Bold",IDC_BOLD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, | ||
224 | 70,30,39,10 | ||
225 | CONTROL "&Italic",IDC_ITALIC,"Button",BS_AUTOCHECKBOX | | ||
226 | WS_TABSTOP,115,30,31,10 | ||
227 | CONTROL "&Underline",IDC_UNDERLINE,"Button",BS_AUTOCHECKBOX | | ||
228 | WS_TABSTOP,157,30,46,10 | ||
229 | CONTROL "Strike&out",IDC_STRIKEOUT,"Button",BS_AUTOCHECKBOX | | ||
230 | WS_TABSTOP,70,43,44,10 | ||
231 | COMBOBOX IDC_CHARSET,115,41,88,59,CBS_DROPDOWNLIST | CBS_SORT | | ||
232 | WS_VSCROLL | WS_TABSTOP | ||
233 | CONTROL "&Foreground color",IDC_FORECOLOR,"Button",BS_OWNERDRAW | | ||
234 | WS_TABSTOP,70,56,64,14 | ||
235 | CONTROL "&Background color",IDC_BACKCOLOR,"Button",BS_OWNERDRAW | | ||
236 | WS_TABSTOP,139,56,64,14 | ||
237 | CONTROL "Sample",IDC_SAMPLE,"RICHEDIT",WS_DISABLED | WS_TABSTOP | | ||
238 | 0xc184,70,72,133,28 | ||
239 | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,105,196,1 | ||
240 | LTEXT "..",IDC_TIP,7,110,196,39 | ||
241 | END | ||
242 | |||
243 | IDD_OPTIONS_SECRETARY DIALOG DISCARDABLE 0, 0, 210, 154 | ||
244 | STYLE WS_CHILD | WS_DISABLED | WS_CAPTION | ||
245 | CAPTION "Secretary" | ||
246 | FONT 8, "MS Sans Serif" | ||
247 | BEGIN | ||
248 | LTEXT "&Greeting message:",IDC_STATIC,7,7,60,8 | ||
249 | EDITTEXT IDC_GREETING,7,16,196,61,ES_MULTILINE | ES_AUTOVSCROLL | | ||
250 | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | ||
251 | LTEXT "After greeting, stop recording when",IDC_STATIC,7,77, | ||
252 | 111,8 | ||
253 | CONTROL "&more than",IDC_DOBYTELIMIT,"Button",BS_AUTOCHECKBOX | | ||
254 | WS_TABSTOP,7,85,47,12 | ||
255 | LTEXT "&characters entered, or",IDC_STATIC,96,87,70,8 | ||
256 | EDITTEXT IDC_BYTELIMIT,55,85,40,12,ES_AUTOHSCROLL | ES_NUMBER | ||
257 | CONTROL "Spin1",IDC_CHARSPIN,"msctls_updown32",UDS_WRAP | | ||
258 | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | | ||
259 | UDS_ARROWKEYS | UDS_NOTHOUSANDS,84,85,11,12 | ||
260 | CONTROL "&time limit of",IDC_DOTIMELIMIT,"Button", | ||
261 | BS_AUTOCHECKBOX | WS_TABSTOP,7,98,47,12 | ||
262 | LTEXT "min&utes exceeded.",IDC_STATIC,96,100,63,8 | ||
263 | EDITTEXT IDC_TIMELIMIT,55,98,40,12,ES_AUTOHSCROLL | ES_NUMBER | ||
264 | CONTROL "Spin1",IDC_TIMESPIN,"msctls_updown32",UDS_WRAP | | ||
265 | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | | ||
266 | UDS_ARROWKEYS | UDS_NOTHOUSANDS,85,98,10,12 | ||
267 | CONTROL "Stop automatically &accepting calls when", | ||
268 | IDC_DOWINLIMIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, | ||
269 | 115,140,12 | ||
270 | LTEXT "calls in &progress",IDC_STATIC,97,129,54,8 | ||
271 | EDITTEXT IDC_WINLIMIT,55,127,40,12,ES_AUTOHSCROLL | ES_NUMBER | ||
272 | CONTROL "Spin1",IDC_WINSPIN,"msctls_updown32",UDS_WRAP | | ||
273 | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | | ||
274 | UDS_ARROWKEYS | UDS_NOTHOUSANDS,85,127,10,12 | ||
275 | CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,113,196,1 | ||
276 | END | ||
277 | |||
278 | IDD_OPTIONS_GENERAL DIALOG DISCARDABLE 0, 0, 210, 154 | ||
279 | STYLE WS_CHILD | WS_DISABLED | WS_CAPTION | ||
280 | CAPTION "General" | ||
281 | FONT 8, "MS Sans Serif" | ||
282 | BEGIN | ||
283 | LTEXT "T42 '&ntalk' daemon listening on port ",IDC_STATIC,7,7, | ||
284 | 114,8 | ||
285 | EDITTEXT IDC_NTALKPORT,123,5,80,12,ES_LOWERCASE | ES_AUTOHSCROLL | ||
286 | CONTROL "Spin1",IDC_NTALKPORTSPIN,"msctls_updown32", | ||
287 | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,193,5,10, | ||
288 | 12 | ||
289 | LTEXT "Note: you will need to restart T42 if you change ntalk demon port number.", | ||
290 | IDC_STATIC,40,20,163,20 | ||
291 | END | ||
292 | |||
293 | |||
294 | #ifndef _MAC | ||
295 | ///////////////////////////////////////////////////////////////////////////// | ||
296 | // | ||
297 | // Version | ||
298 | // | ||
299 | |||
300 | VS_VERSION_INFO VERSIONINFO | ||
301 | FILEVERSION 1,5,0,0 | ||
302 | PRODUCTVERSION 1,5,0,0 | ||
303 | FILEFLAGSMASK 0x3fL | ||
304 | #ifdef _DEBUG | ||
305 | FILEFLAGS 0x1L | ||
306 | #else | ||
307 | FILEFLAGS 0x0L | ||
308 | #endif | ||
309 | FILEOS 0x4L | ||
310 | FILETYPE 0x1L | ||
311 | FILESUBTYPE 0x0L | ||
312 | BEGIN | ||
313 | BLOCK "StringFileInfo" | ||
314 | BEGIN | ||
315 | BLOCK "040904b0" | ||
316 | BEGIN | ||
317 | VALUE "CompanyName", "Klever Group (http://www.klever.net/)\0" | ||
318 | VALUE "FileDescription", "T42, unix talk/ntalk implementation\0" | ||
319 | VALUE "FileVersion", "1, 5, 0, 0\0" | ||
320 | VALUE "InternalName", "T42\0" | ||
321 | VALUE "LegalCopyright", "Copyright © 1998, 2002 Klever Group (http://www.klever.net/)\0" | ||
322 | VALUE "LegalTrademarks", "Klever Group (http://www.klever.net/)\0" | ||
323 | VALUE "OriginalFilename", "T42.EXE\0" | ||
324 | VALUE "ProductName", "T42\0" | ||
325 | VALUE "ProductVersion", "1, 5, 0, 0\0" | ||
326 | END | ||
327 | END | ||
328 | BLOCK "VarFileInfo" | ||
329 | BEGIN | ||
330 | VALUE "Translation", 0x409, 1200 | ||
331 | END | ||
332 | END | ||
333 | |||
334 | #endif // !_MAC | ||
335 | |||
336 | |||
337 | ///////////////////////////////////////////////////////////////////////////// | ||
338 | // | ||
339 | // DESIGNINFO | ||
340 | // | ||
341 | |||
342 | #ifdef APSTUDIO_INVOKED | ||
343 | GUIDELINES DESIGNINFO DISCARDABLE | ||
344 | BEGIN | ||
345 | IDD_ABOUTBOX, DIALOG | ||
346 | BEGIN | ||
347 | LEFTMARGIN, 7 | ||
348 | RIGHTMARGIN, 187 | ||
349 | TOPMARGIN, 7 | ||
350 | BOTTOMMARGIN, 71 | ||
351 | END | ||
352 | |||
353 | IDD_T42_DIALOG, DIALOG | ||
354 | BEGIN | ||
355 | LEFTMARGIN, 7 | ||
356 | RIGHTMARGIN, 214 | ||
357 | TOPMARGIN, 7 | ||
358 | BOTTOMMARGIN, 193 | ||
359 | END | ||
360 | |||
361 | IDD_REMOTE, DIALOG | ||
362 | BEGIN | ||
363 | LEFTMARGIN, 7 | ||
364 | RIGHTMARGIN, 146 | ||
365 | TOPMARGIN, 7 | ||
366 | BOTTOMMARGIN, 104 | ||
367 | END | ||
368 | |||
369 | IDD_ANNOUNCE, DIALOG | ||
370 | BEGIN | ||
371 | LEFTMARGIN, 7 | ||
372 | RIGHTMARGIN, 134 | ||
373 | TOPMARGIN, 7 | ||
374 | BOTTOMMARGIN, 132 | ||
375 | END | ||
376 | |||
377 | IDD_OPTIONS_SOUNDS, DIALOG | ||
378 | BEGIN | ||
379 | LEFTMARGIN, 7 | ||
380 | RIGHTMARGIN, 203 | ||
381 | VERTGUIDE, 90 | ||
382 | VERTGUIDE, 175 | ||
383 | TOPMARGIN, 5 | ||
384 | BOTTOMMARGIN, 149 | ||
385 | END | ||
386 | |||
387 | IDD_OPTIONS_FONTS, DIALOG | ||
388 | BEGIN | ||
389 | LEFTMARGIN, 7 | ||
390 | RIGHTMARGIN, 203 | ||
391 | VERTGUIDE, 67 | ||
392 | VERTGUIDE, 70 | ||
393 | TOPMARGIN, 5 | ||
394 | BOTTOMMARGIN, 149 | ||
395 | HORZGUIDE, 100 | ||
396 | END | ||
397 | |||
398 | IDD_OPTIONS_SECRETARY, DIALOG | ||
399 | BEGIN | ||
400 | LEFTMARGIN, 7 | ||
401 | RIGHTMARGIN, 203 | ||
402 | TOPMARGIN, 7 | ||
403 | BOTTOMMARGIN, 147 | ||
404 | HORZGUIDE, 77 | ||
405 | END | ||
406 | |||
407 | IDD_OPTIONS_GENERAL, DIALOG | ||
408 | BEGIN | ||
409 | LEFTMARGIN, 7 | ||
410 | RIGHTMARGIN, 203 | ||
411 | TOPMARGIN, 5 | ||
412 | BOTTOMMARGIN, 149 | ||
413 | END | ||
414 | END | ||
415 | #endif // APSTUDIO_INVOKED | ||
416 | |||
417 | |||
418 | ///////////////////////////////////////////////////////////////////////////// | ||
419 | // | ||
420 | // Menu | ||
421 | // | ||
422 | |||
423 | IDR_T42FRAME MENU DISCARDABLE | ||
424 | BEGIN | ||
425 | POPUP "&Tea" | ||
426 | BEGIN | ||
427 | MENUITEM "Remote &user", ID_TALK_REMOTEUSER | ||
428 | MENUITEM "&Close connection", ID_TALK_ABORT | ||
429 | MENUITEM "&Re-connect", ID_TALK_RECONNECT | ||
430 | MENUITEM SEPARATOR | ||
431 | MENUITEM "&Save", ID_TEA_SAVE | ||
432 | MENUITEM SEPARATOR | ||
433 | MENUITEM "E&xit", ID_TALK_CLOSE | ||
434 | END | ||
435 | POPUP "&Edit" | ||
436 | BEGIN | ||
437 | MENUITEM "&Copy\tCtrl-INS", ID_EDIT_COPY | ||
438 | MENUITEM "&Paste\tShift-INS", ID_EDIT_PASTE | ||
439 | END | ||
440 | POPUP "&Sleep" | ||
441 | BEGIN | ||
442 | MENUITEM "&Sleep\tCtrl-S", ID_SLEEP_SLEEP | ||
443 | MENUITEM SEPARATOR | ||
444 | MENUITEM "Sleep on &minimize", ID_SLEEP_SLEEPONMINIMIZE | ||
445 | MENUITEM "Minimi&ze on sleep", ID_SLEEP_MINIMIZEONSLEEP | ||
446 | POPUP "&Wake-up action" | ||
447 | BEGIN | ||
448 | MENUITEM "Make &sound", ID_SLEEP_WAKEUPACTION_MAKESOUND | ||
449 | |||
450 | MENUITEM "&Pop-up", ID_SLEEP_WAKEUPACTION_POPUP | ||
451 | |||
452 | END | ||
453 | END | ||
454 | POPUP "&Window" | ||
455 | BEGIN | ||
456 | MENUITEM "Split e&qually", ID_WINDOW_SPLITEQUALLY | ||
457 | MENUITEM "&Save layout", ID_WINDOW_SAVELAYOUT | ||
458 | MENUITEM "&Autosave layout", ID_WINDOW_AUTOSAVELAYOUT | ||
459 | MENUITEM SEPARATOR | ||
460 | MENUITEM "&Horizontal split", ID_WINDOW_HORIZONTALSPLIT | ||
461 | MENUITEM "&Vertical split", ID_WINDOW_VERTICALSPLIT | ||
462 | MENUITEM SEPARATOR | ||
463 | MENUITEM "&Hide on minimize", ID_WINDOW_HIDEINTRAYONMINIMIZE | ||
464 | |||
465 | END | ||
466 | END | ||
467 | |||
468 | IDM_POPUPS MENU DISCARDABLE | ||
469 | BEGIN | ||
470 | POPUP "Tray" | ||
471 | BEGIN | ||
472 | MENUITEM "Order some &tea", ID_TRAY_T42 | ||
473 | MENUITEM "&Away", ID_TRAY_AWAY | ||
474 | MENUITEM "Show main &window", ID_TRAY_SHOWMAINWINDOW | ||
475 | MENUITEM "&Options", ID_TRAY_OPTIONS | ||
476 | MENUITEM "E&xit", ID_TRAY_EXIT | ||
477 | END | ||
478 | POPUP "Call Log" | ||
479 | BEGIN | ||
480 | MENUITEM "&Call back", ID_CALLLOG_CALLBACK | ||
481 | MENUITEM "&Delete", ID_CALLLOG_DELETE | ||
482 | MENUITEM "&Save to file..", ID_CALLLOG_SAVETOFILE | ||
483 | MENUITEM SEPARATOR | ||
484 | MENUITEM "Mark as &new", ID_CALLLOG_MARKASNEW | ||
485 | MENUITEM "Mark as &processed", ID_CALLLOG_MARKASPROCESSED | ||
486 | MENUITEM SEPARATOR | ||
487 | MENUITEM "&Empty Log", ID_CALLLOG_EMPTYLOG | ||
488 | END | ||
489 | END | ||
490 | |||
491 | |||
492 | ///////////////////////////////////////////////////////////////////////////// | ||
493 | // | ||
494 | // Accelerator | ||
495 | // | ||
496 | |||
497 | IDR_T42FRAME ACCELERATORS DISCARDABLE | ||
498 | BEGIN | ||
499 | "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT | ||
500 | "S", ID_SLEEP_SLEEP, VIRTKEY, CONTROL, NOINVERT | ||
501 | "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT | ||
502 | VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT | ||
503 | VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT | ||
504 | END | ||
505 | |||
506 | |||
507 | ///////////////////////////////////////////////////////////////////////////// | ||
508 | // | ||
509 | // Dialog Info | ||
510 | // | ||
511 | |||
512 | IDD_REMOTE DLGINIT | ||
513 | BEGIN | ||
514 | IDC_TTY, 0x403, 5, 0 | ||
515 | 0x7474, 0x3079, "\000" | ||
516 | IDC_TTY, 0x403, 6, 0 | ||
517 | 0x7474, 0x7079, 0x0030, | ||
518 | IDC_TTY, 0x403, 6, 0 | ||
519 | 0x7474, 0x7679, 0x0030, | ||
520 | IDC_TTY, 0x403, 6, 0 | ||
521 | 0x7474, 0x6179, 0x0030, | ||
522 | IDC_TTY, 0x403, 5, 0 | ||
523 | 0x7474, 0x3179, "\000" | ||
524 | IDC_TTY, 0x403, 6, 0 | ||
525 | 0x7474, 0x7079, 0x0031, | ||
526 | IDC_TTY, 0x403, 6, 0 | ||
527 | 0x7474, 0x7679, 0x0031, | ||
528 | IDC_TTY, 0x403, 6, 0 | ||
529 | 0x7474, 0x6179, 0x0031, | ||
530 | IDC_TTY, 0x403, 5, 0 | ||
531 | 0x7474, 0x3279, "\000" | ||
532 | IDC_TTY, 0x403, 6, 0 | ||
533 | 0x7474, 0x7079, 0x0032, | ||
534 | IDC_TTY, 0x403, 6, 0 | ||
535 | 0x7474, 0x7679, 0x0032, | ||
536 | IDC_TTY, 0x403, 6, 0 | ||
537 | 0x7474, 0x6179, 0x0032, | ||
538 | IDC_TTY, 0x403, 5, 0 | ||
539 | 0x7474, 0x3379, "\000" | ||
540 | IDC_TTY, 0x403, 6, 0 | ||
541 | 0x7474, 0x7079, 0x0033, | ||
542 | IDC_TTY, 0x403, 6, 0 | ||
543 | 0x7474, 0x7679, 0x0033, | ||
544 | IDC_TTY, 0x403, 6, 0 | ||
545 | 0x7474, 0x6179, 0x0033, | ||
546 | IDC_TTY, 0x403, 5, 0 | ||
547 | 0x7474, 0x3479, "\000" | ||
548 | IDC_TTY, 0x403, 6, 0 | ||
549 | 0x7474, 0x7079, 0x0034, | ||
550 | IDC_TTY, 0x403, 6, 0 | ||
551 | 0x7474, 0x7679, 0x0034, | ||
552 | IDC_TTY, 0x403, 6, 0 | ||
553 | 0x7474, 0x6179, 0x0034, | ||
554 | 0 | ||
555 | END | ||
556 | |||
557 | IDD_T42_DIALOG DLGINIT | ||
558 | BEGIN | ||
559 | IDC_ONCALL, 0x403, 7, 0 | ||
560 | 0x7250, 0x6d6f, 0x7470, "\000" | ||
561 | IDC_ONCALL, 0x403, 10, 0 | ||
562 | 0x6553, 0x7263, 0x7465, 0x7261, 0x0079, | ||
563 | IDC_ONCALL, 0x403, 9, 0 | ||
564 | 0x6f4e, 0x2074, 0x6568, 0x6572, "\000" | ||
565 | IDC_ONCALL, 0x403, 7, 0 | ||
566 | 0x6552, 0x7566, 0x6573, "\000" | ||
567 | IDC_ONCALL, 0x403, 7, 0 | ||
568 | 0x6749, 0x6f6e, 0x6572, "\000" | ||
569 | IDC_ONCALLAWAY, 0x403, 7, 0 | ||
570 | 0x7250, 0x6d6f, 0x7470, "\000" | ||
571 | IDC_ONCALLAWAY, 0x403, 10, 0 | ||
572 | 0x6553, 0x7263, 0x7465, 0x7261, 0x0079, | ||
573 | IDC_ONCALLAWAY, 0x403, 9, 0 | ||
574 | 0x6f4e, 0x2074, 0x6568, 0x6572, "\000" | ||
575 | IDC_ONCALLAWAY, 0x403, 7, 0 | ||
576 | 0x6552, 0x7566, 0x6573, "\000" | ||
577 | IDC_ONCALLAWAY, 0x403, 7, 0 | ||
578 | 0x6749, 0x6f6e, 0x6572, "\000" | ||
579 | 0 | ||
580 | END | ||
581 | |||
582 | IDD_OPTIONS_SOUNDS DLGINIT | ||
583 | BEGIN | ||
584 | IDC_T42BELL, 0x403, 11, 0 | ||
585 | 0x7428, 0x6165, 0x642d, 0x6f72, 0x2970, "\000" | ||
586 | IDC_T42PROMPT, 0x403, 17, 0 | ||
587 | 0x6228, 0x696f, 0x696c, 0x676e, 0x742d, 0x6165, 0x6f70, 0x2974, "\000" | ||
588 | IDC_T42WAKE, 0x403, 17, 0 | ||
589 | 0x7428, 0x6165, 0x6f70, 0x2d74, 0x6877, 0x7369, 0x6c74, 0x2965, "\000" | ||
590 | 0 | ||
591 | END | ||
592 | |||
593 | IDD_OPTIONS_FONTS DLGINIT | ||
594 | BEGIN | ||
595 | IDC_FONTSIZE, 0x403, 2, 0 | ||
596 | 0x0036, | ||
597 | IDC_FONTSIZE, 0x403, 2, 0 | ||
598 | 0x0038, | ||
599 | IDC_FONTSIZE, 0x403, 2, 0 | ||
600 | 0x0039, | ||
601 | IDC_FONTSIZE, 0x403, 3, 0 | ||
602 | 0x3031, "\000" | ||
603 | IDC_FONTSIZE, 0x403, 3, 0 | ||
604 | 0x3131, "\000" | ||
605 | IDC_FONTSIZE, 0x403, 3, 0 | ||
606 | 0x3231, "\000" | ||
607 | IDC_FONTSIZE, 0x403, 3, 0 | ||
608 | 0x3431, "\000" | ||
609 | IDC_FONTSIZE, 0x403, 3, 0 | ||
610 | 0x3631, "\000" | ||
611 | IDC_FONTSIZE, 0x403, 3, 0 | ||
612 | 0x3831, "\000" | ||
613 | IDC_FONTSIZE, 0x403, 3, 0 | ||
614 | 0x3232, "\000" | ||
615 | IDC_FONTSIZE, 0x403, 3, 0 | ||
616 | 0x3432, "\000" | ||
617 | IDC_FONTSIZE, 0x403, 3, 0 | ||
618 | 0x3632, "\000" | ||
619 | IDC_FONTSIZE, 0x403, 3, 0 | ||
620 | 0x3233, "\000" | ||
621 | IDC_FONTSIZE, 0x403, 3, 0 | ||
622 | 0x3633, "\000" | ||
623 | IDC_FONTSIZE, 0x403, 3, 0 | ||
624 | 0x3834, "\000" | ||
625 | IDC_FONTSIZE, 0x403, 3, 0 | ||
626 | 0x3237, "\000" | ||
627 | 0 | ||
628 | END | ||
629 | |||
630 | |||
631 | ///////////////////////////////////////////////////////////////////////////// | ||
632 | // | ||
633 | // Bitmap | ||
634 | // | ||
635 | |||
636 | IDB_BACK BITMAP DISCARDABLE "shared-data/klever-background.bmp" | ||
637 | |||
638 | ///////////////////////////////////////////////////////////////////////////// | ||
639 | // | ||
640 | // WAVE | ||
641 | // | ||
642 | |||
643 | IDW_BEEP_DROP WAVE DISCARDABLE "res\\T42-beep.wav" | ||
644 | IDW_ANNOUNCE_BOILING WAVE DISCARDABLE "res\\T42-boiling.wav" | ||
645 | IDW_WAKE_WHISTLE WAVE DISCARDABLE "res\\T42-whistle.wav" | ||
646 | |||
647 | ///////////////////////////////////////////////////////////////////////////// | ||
648 | // | ||
649 | // String Table | ||
650 | // | ||
651 | |||
652 | STRINGTABLE DISCARDABLE | ||
653 | BEGIN | ||
654 | IDS_ABOUTBOX "&About T42..." | ||
655 | IDS_ERR_MALFORMEDREMOTE "Malformed remote name." | ||
656 | IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed." | ||
657 | ID_INDICATOR_DATE "Date" | ||
658 | IDS_STATUS_RESOLVING "Looking up remote host address.." | ||
659 | IDS_ERR_REMOTERESOLVEFAILED "Remote lookup failed: %s" | ||
660 | IDS_ERR_CTLCREATEFAILED "Failed to create control socket: %s" | ||
661 | IDS_ERR_CTLBINDFAILED "Failed to bind control socket: %s" | ||
662 | IDS_ERR_CTLGETFAILED "Failed to get control socket name: %s" | ||
663 | IDS_ERR_TCPCREATEFAILED "Failed to create conversation socket: %s" | ||
664 | IDS_ERR_TCPBINDFAILED "Failed to bind conversation socket: %s" | ||
665 | END | ||
666 | |||
667 | STRINGTABLE DISCARDABLE | ||
668 | BEGIN | ||
669 | IDS_CTL_BADCTL "Remote didn't like out ctl address. This means you can not see this message." | ||
670 | IDR_T42FRAME "Tea For Two" | ||
671 | IDS_CTL_UNKNOWNERROR "Remote talk daemon seems to be talking different language.." | ||
672 | IDS_ERR_ANNOUNCEFAILED "Failed to page remote user." | ||
673 | IDS_ERR_LEAVINVITEFAILED | ||
674 | "Failed to leave an invitation on local talk daemon." | ||
675 | IDS_ERR_TCPACCEPTFAILED "Failed to accept remote connection: %s" | ||
676 | IDS_STATUS_ANNOUNCING "Ringing your party.." | ||
677 | IDS_ERR_CTLLDELETEFAILED | ||
678 | "Failed to clean up invitation on local machine." | ||
679 | IDS_ERR_CTLRDELETEFAILED | ||
680 | "Failed to clean up invitation on remote machine." | ||
681 | IDS_ERR_TCPERROR "Error on conversation socket: %s" | ||
682 | IDS_STATUS_ESTABLISHED "Connection established." | ||
683 | IDS_STATUS_CONNECTIONCLOSED "Connection closed." | ||
684 | IDS_TITLE_TEAWITH "Tea with %s" | ||
685 | IDS_TITLE_TEAFORTWO "Tea For Two" | ||
686 | IDS_TITLE_OPTIONS "T42 Options" | ||
687 | IDS_SND_TEADROP "(tea-drop)" | ||
688 | END | ||
689 | |||
690 | STRINGTABLE DISCARDABLE | ||
691 | BEGIN | ||
692 | ID_TALK_ABORT "Close the connection\nClose" | ||
693 | ID_TALK_CLOSE "Close this window\nExit" | ||
694 | ID_WINDOW_CENTERSPLITTER "Center Splitter position" | ||
695 | ID_WINDOW_SPLITEQUALLY "Center splitterbar position\nEquisplit" | ||
696 | ID_WINDOW_SAVELAYOUT "Save window layout\nSave" | ||
697 | ID_WINDOW_AUTOSAVELAYOUT "Automatically save layout\nAutosave" | ||
698 | ID_TALK_REMOTEUSER "Issue talk request to specific user\nTea" | ||
699 | ID_WINDOW_HORIZONTALSPLIT "Make split horizontal\nHorizontal" | ||
700 | ID_WINDOW_VERTICALSPLIT "Make split vertical\nVertical" | ||
701 | END | ||
702 | |||
703 | STRINGTABLE DISCARDABLE | ||
704 | BEGIN | ||
705 | ID_FILE_MRU_FIRST "Call this user\nCall" | ||
706 | END | ||
707 | |||
708 | STRINGTABLE DISCARDABLE | ||
709 | BEGIN | ||
710 | ID_EDIT_COPY "Copy selection to clipboard\nCopy" | ||
711 | ID_EDIT_PASTE "Paste clipboard to remote\nPaste" | ||
712 | END | ||
713 | |||
714 | STRINGTABLE DISCARDABLE | ||
715 | BEGIN | ||
716 | AFX_IDS_APP_TITLE "T42" | ||
717 | AFX_IDS_IDLEMESSAGE "No connection, yet." | ||
718 | END | ||
719 | |||
720 | STRINGTABLE DISCARDABLE | ||
721 | BEGIN | ||
722 | IDS_ERR_TCPGETFAILED "Failed to get conversation socket name: %s" | ||
723 | IDS_STATUS_LOOKUPINVITE "Looking up invitation on remote.." | ||
724 | IDS_ERR_TCPASELFAILED "Failed to select conversation socket: %s" | ||
725 | IDS_STATUS_WAITINGTOCONNECT "Waiting to connect with remote.." | ||
726 | IDS_ERR_TCPCONNECTFAILED "Failed to connect to remote: %s" | ||
727 | IDS_ERR_TCPLISTENFAILED "Listen on conversation socket failed: %s" | ||
728 | IDS_ERR_LTNASELFAILED "Failed to select listening socket: %s" | ||
729 | IDS_ERR_CTLLOOKUPFAILED "Failed to connect to remote talk daemon." | ||
730 | IDS_ERR_ANNOUNCEFAILURE "Failed to page user: %s" | ||
731 | IDS_CTL_NOTHERE "Your party isn't logged in." | ||
732 | IDS_CTL_FAILED "Remote talk daemon failed to explain the reason." | ||
733 | IDS_CTL_MACHUNKNOWN "Remote talk daemon doesn't want to talk to us." | ||
734 | IDS_CTL_PERMISSIONDENIED "Your party is refusing messages." | ||
735 | IDS_CTL_BADREQUEST "Remote talk daemon doesn't recognize our request" | ||
736 | IDS_CTL_BADVERSION "Protocol version mismatch." | ||
737 | IDS_CTL_BADADDR "Remote didn't like our address." | ||
738 | END | ||
739 | |||
740 | STRINGTABLE DISCARDABLE | ||
741 | BEGIN | ||
742 | ID_TALK_RECONNECT "Connect again to the same user\nReconnect" | ||
743 | ID_WINDOW_HIDEINTRAYONMINIMIZE | ||
744 | "When minimizing window hide into tray icon\nTray Minimize" | ||
745 | ID_SLEEP_SLEEP "Put window into sleep mode\nSleep" | ||
746 | ID_SLEEP_MAKESOUND "Make sound on wake-up\nWake-Alarm" | ||
747 | ID_SLEEP_POPUP "Bring window to top on wake-up\nPop-up on wake" | ||
748 | ID_SLEEP_WAKEUPACTION_MAKESOUND "Make sound when waking-up\nWake-alarm" | ||
749 | ID_SLEEP_WAKEUPACTION_POPUP | ||
750 | "Bring window to top when waking-up\nWake-popup" | ||
751 | ID_SLEEP_SLEEPONMINIMIZE | ||
752 | "Put window into sleep mode when minimizing\nMinimize-sleep" | ||
753 | ID_SLEEP_MINIMIZEONSLEEP | ||
754 | "Minimize (or hide to tray area) on sleep\nSleep-minimize" | ||
755 | END | ||
756 | |||
757 | STRINGTABLE DISCARDABLE | ||
758 | BEGIN | ||
759 | IDS_SND_BOILINGTEAPOT "(boiling-teapot)" | ||
760 | IDS_SND_TEAPOTWHISTLE "(teapot-whistle)" | ||
761 | IDS_TITLE_WAV "Select Sound.." | ||
762 | IDS_FILTER_WAV "Sound Files (*.wav)|*.wav||" | ||
763 | IDS_FMT_T42LOCAL "Local\nFont used for local user pane in Tea For Two conversation window." | ||
764 | IDS_FMT_T42REMOTE "Remote\nFont used for remote user pane in Tea For Two conversation window." | ||
765 | IDS_FMT_T42SYSTEM "System\nFont used for system messages. Background color is taken from appropriate window format." | ||
766 | IDS_CHARSET_AUTO "(Auto)" | ||
767 | IDS_DEFAULTGREETING "Hello, I'm just a secretary, but feel free to have a tea with me - I have my pencil ready and I'll write down what you say, unless it will take longer than %t minutes and this small piece of paper can hold only %c characters, so drink fast and wisely!\n" | ||
768 | IDS_FILENAME_T42 "Tea for %s and %s.rtf" | ||
769 | IDS_RTF_HEAD "{\\rtf1\\ansi\n\\tgraph500\\trqc\\cellx4000\\cellx8000\n\\qc\\sa100\\intbl {\\b %s } \\cell {\\b\\qc %s } \\cell\\row\n\\pard\n\\intbl\n\n" | ||
770 | IDS_FILE_T42CALLS "T42.Calls" | ||
771 | IDS_FORMAT_CALLTIME "%c" | ||
772 | IDS_FILTER_RTF "Rich Text Format (*.rtf)|*.rtf||" | ||
773 | IDS_FORMAT_CALLDURATION "%D.%H:%M:%S" | ||
774 | IDS_FORMAT_CALLTIMELONG "%#c" | ||
775 | END | ||
776 | |||
777 | STRINGTABLE DISCARDABLE | ||
778 | BEGIN | ||
779 | IDS_FORMAT_T42CALLHEADER | ||
780 | "---\\\nTime: %s\\\nCaller: %s\\\nCallee: %s\\\nCall Duration: %s\\\n--\\\n" | ||
781 | IDS_WSA_ENETDOWN "Network is down" | ||
782 | IDS_WSA_ECONNRESET "Connection reset by peer" | ||
783 | IDS_WSA_ECONNABORTED "Connection aborted" | ||
784 | IDS_WSA_ECONNREFUSED "Connection refused" | ||
785 | IDS_WSA_ENETUNREACH "Network is unreachable" | ||
786 | IDS_WSA_ETIMEDOUT "Connection timed out" | ||
787 | IDS_CONNECTIONCLOSED "Connection closed" | ||
788 | IDS_WSA_NODATA "Valid name, no data" | ||
789 | IDS_ERR_CONNECTIONCLOSED "Connection closed: %s" | ||
790 | IDS_WSA_HOSTNOTFOUND "Host not found" | ||
791 | IDS_KLEVERNET_URL "http://www.klever.net/" | ||
792 | IDS_RTF_DELIMITER "\n\n\\cell\n\n" | ||
793 | IDS_RTF_TAIL "\\cell\\row\n}\n" | ||
794 | IDS_FAILVALIDATE_NTALKPORT | ||
795 | "Set ntalk port to either readable representation of existing service or number between 1 and 65535." | ||
796 | IDS_CALLOG_OPEN_FAILED "Failed to open/create secretary log database." | ||
797 | END | ||
798 | |||
799 | STRINGTABLE DISCARDABLE | ||
800 | BEGIN | ||
801 | ID_TEA_SAVE "Save conversation as RTF file\nSave" | ||
802 | END | ||
803 | |||
804 | STRINGTABLE DISCARDABLE | ||
805 | BEGIN | ||
806 | IDS_CALLOG_CLOSE_FAILED "Failed to gracefully close secretary log database." | ||
807 | IDS_DAEMON_FAIL "Failed to set up ntalk daemon. You may still be able to use T42 for outgoing calls if you have other talk daemon installed." | ||
808 | IDS_REGISTRYKEY "Klever Group, Inc." | ||
809 | IDS_DEFAULTCALLER "tealover" | ||
810 | END | ||
811 | |||
812 | #endif // English (U.S.) resources | ||
813 | ///////////////////////////////////////////////////////////////////////////// | ||
814 | |||
815 | |||
816 | |||
817 | #ifndef APSTUDIO_INVOKED | ||
818 | ///////////////////////////////////////////////////////////////////////////// | ||
819 | // | ||
820 | // Generated from the TEXTINCLUDE 3 resource. | ||
821 | // | ||
822 | #define _AFX_NO_SPLITTER_RESOURCES | ||
823 | #define _AFX_NO_OLE_RESOURCES | ||
824 | #define _AFX_NO_TRACKER_RESOURCES | ||
825 | #define _AFX_NO_PROPERTY_RESOURCES | ||
826 | |||
827 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) | ||
828 | #ifdef _WIN32 | ||
829 | LANGUAGE 9, 1 | ||
830 | #pragma code_page(1252) | ||
831 | #endif | ||
832 | #include "res\T42.rc2" // non-Microsoft Visual C++ edited resources | ||
833 | #include "afxres.rc" // Standard components | ||
834 | #endif | ||
835 | ///////////////////////////////////////////////////////////////////////////// | ||
836 | #endif // not APSTUDIO_INVOKED | ||
837 | |||
diff --git a/T42AnnounceDlg.cpp b/T42AnnounceDlg.cpp new file mode 100644 index 0000000..874a898 --- a/dev/null +++ b/T42AnnounceDlg.cpp | |||
@@ -0,0 +1,144 @@ | |||
1 | // T42AnnounceDlg.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "T42AnnounceDlg.h" | ||
7 | |||
8 | #ifdef _DEBUG | ||
9 | #define new DEBUG_NEW | ||
10 | #undef THIS_FILE | ||
11 | static char THIS_FILE[] = __FILE__; | ||
12 | #endif | ||
13 | |||
14 | ///////////////////////////////////////////////////////////////////////////// | ||
15 | // T42AnnounceDlg dialog | ||
16 | |||
17 | |||
18 | T42AnnounceDlg::T42AnnounceDlg(TalkCtlMessage& rq,CWnd* pParent /*=NULL*/) | ||
19 | : CDialog(T42AnnounceDlg::IDD, pParent), m_RQ(rq) | ||
20 | { | ||
21 | //{{AFX_DATA_INIT(T42AnnounceDlg) | ||
22 | m_Callee = _T(""); | ||
23 | m_Caller = _T(""); | ||
24 | m_TTY = _T(""); | ||
25 | //}}AFX_DATA_INIT | ||
26 | m_Callee = rq.m_RName; | ||
27 | m_Caller = rq.m_LName; | ||
28 | m_Caller+= '@'; | ||
29 | m_Caller+= inet_ntoa(((sockaddr_in*)&rq.m_Addr)->sin_addr); | ||
30 | m_TTY = rq.m_RTTY; | ||
31 | m_asyncRequest=NULL; | ||
32 | m_timeOut = 30; | ||
33 | m_ipCaller = m_Caller; | ||
34 | m_bLooped=FALSE; | ||
35 | } | ||
36 | |||
37 | |||
38 | void T42AnnounceDlg::DoDataExchange(CDataExchange* pDX) | ||
39 | { | ||
40 | CDialog::DoDataExchange(pDX); | ||
41 | //{{AFX_DATA_MAP(T42AnnounceDlg) | ||
42 | DDX_Control(pDX, IDC_CALLEE, m_CalleeCtl); | ||
43 | DDX_Control(pDX, IDC_TTY, m_TTYCtl); | ||
44 | DDX_Control(pDX, IDOK, m_YesCtl); | ||
45 | DDX_Control(pDX, IDCANCEL, m_NotMeCtl); | ||
46 | DDX_Control(pDX, IDC_SECRETARY, m_SecretaryCtl); | ||
47 | DDX_Control(pDX, IDC_CALLER, m_CallerCtl); | ||
48 | DDX_Text(pDX, IDC_CALLEE, m_Callee); | ||
49 | DDX_Text(pDX, IDC_CALLER, m_Caller); | ||
50 | DDX_Text(pDX, IDC_TTY, m_TTY); | ||
51 | //}}AFX_DATA_MAP | ||
52 | } | ||
53 | |||
54 | |||
55 | BEGIN_MESSAGE_MAP(T42AnnounceDlg, CDialog) | ||
56 | //{{AFX_MSG_MAP(T42AnnounceDlg) | ||
57 | ON_MESSAGE(WM_SOURCERESOLVED, OnSourceResolved) | ||
58 | ON_WM_DESTROY() | ||
59 | ON_WM_TIMER() | ||
60 | ON_BN_CLICKED(IDC_SECRETARY, OnSecretary) | ||
61 | //}}AFX_MSG_MAP | ||
62 | END_MESSAGE_MAP() | ||
63 | |||
64 | ///////////////////////////////////////////////////////////////////////////// | ||
65 | // T42AnnounceDlg message handlers | ||
66 | |||
67 | BOOL T42AnnounceDlg::OnInitDialog() | ||
68 | { | ||
69 | CDialog::OnInitDialog(); | ||
70 | |||
71 | m_asyncRequest = WSAAsyncGetHostByAddr(m_hWnd,WM_SOURCERESOLVED, | ||
72 | (CHAR*)&((sockaddr_in*)&m_RQ.m_Addr)->sin_addr, | ||
73 | 4,AF_INET, | ||
74 | m_ResolveBuffer,sizeof(m_ResolveBuffer) | ||
75 | ); | ||
76 | |||
77 | CT42App* app = (CT42App*)AfxGetApp(); | ||
78 | ASSERT(app); | ||
79 | m_bLooped = app->StartSound(app->m_sndT42Prompt,app->m_bT42PromptLoop); | ||
80 | SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); | ||
81 | SetTimer(timerTimeout,m_timeOut*1000,NULL); | ||
82 | CFont* f = GetFont(); | ||
83 | LOGFONT lf; | ||
84 | if(f->GetLogFont(&lf)){ | ||
85 | if(lf.lfWeight) | ||
86 | lf.lfWeight = 1000-lf.lfWeight; | ||
87 | else | ||
88 | lf.lfWeight = 700; | ||
89 | if(m_Font.CreateFontIndirect(&lf)){ | ||
90 | m_CalleeCtl.SetFont(&m_Font); | ||
91 | m_CallerCtl.SetFont(&m_Font); | ||
92 | m_TTYCtl.SetFont(&m_Font); | ||
93 | } | ||
94 | } | ||
95 | return TRUE; // return TRUE unless you set the focus to a control | ||
96 | // EXCEPTION: OCX Property Pages should return FALSE | ||
97 | } | ||
98 | |||
99 | LRESULT T42AnnounceDlg::OnSourceResolved(WPARAM,LPARAM lP) | ||
100 | { | ||
101 | if(WSAGETASYNCERROR(lP)){ | ||
102 | TRACE1("Failed to resolve callee's host: %ld\n",WSAGETASYNCERROR(lP)); | ||
103 | return -1; | ||
104 | } | ||
105 | hostent* he = (hostent*)m_ResolveBuffer; | ||
106 | m_Caller = m_RQ.m_LName; | ||
107 | m_Caller+= '@'; | ||
108 | m_Caller+= he->h_name; | ||
109 | m_CallerCtl.SetWindowText(m_Caller); | ||
110 | m_asyncRequest=NULL; | ||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | void T42AnnounceDlg::OnDestroy() | ||
115 | { | ||
116 | if(m_bLooped){ | ||
117 | CT42App* app = (CT42App*)AfxGetApp(); | ||
118 | ASSERT(app); | ||
119 | app->StopSound(app->m_sndT42Prompt); | ||
120 | } | ||
121 | m_bLooped=FALSE; | ||
122 | if(m_asyncRequest){ | ||
123 | WSACancelAsyncRequest(m_asyncRequest); | ||
124 | m_asyncRequest=NULL; | ||
125 | } | ||
126 | CDialog::OnDestroy(); | ||
127 | } | ||
128 | |||
129 | void T42AnnounceDlg::OnTimer(UINT nIDEvent) | ||
130 | { | ||
131 | if(nIDEvent==timerTimeout){ | ||
132 | KillTimer(timerTimeout); | ||
133 | UpdateData(TRUE); | ||
134 | // *** OnPromptTimeout? | ||
135 | EndDialog(IDC_SECRETARY); | ||
136 | }else | ||
137 | CDialog::OnTimer(nIDEvent); | ||
138 | } | ||
139 | |||
140 | void T42AnnounceDlg::OnSecretary() | ||
141 | { | ||
142 | UpdateData(TRUE); | ||
143 | EndDialog(IDC_SECRETARY); | ||
144 | } | ||
diff --git a/T42AnnounceDlg.h b/T42AnnounceDlg.h new file mode 100644 index 0000000..aa3aa58 --- a/dev/null +++ b/T42AnnounceDlg.h | |||
@@ -0,0 +1,55 @@ | |||
1 | // T42AnnounceDlg.h : header file | ||
2 | // | ||
3 | |||
4 | ///////////////////////////////////////////////////////////////////////////// | ||
5 | // T42AnnounceDlg dialog | ||
6 | |||
7 | class T42AnnounceDlg : public CDialog | ||
8 | { | ||
9 | // Construction | ||
10 | public: | ||
11 | CFont m_Font; | ||
12 | LPCSTR m_hSound; | ||
13 | BOOL m_bLooped; | ||
14 | CString m_ipCaller; | ||
15 | UINT m_timeOut; | ||
16 | HANDLE m_asyncRequest; | ||
17 | CHAR m_ResolveBuffer[MAXGETHOSTSTRUCT]; | ||
18 | TalkCtlMessage m_RQ; | ||
19 | T42AnnounceDlg(TalkCtlMessage& rq,CWnd* pParent = NULL); // standard constructor | ||
20 | |||
21 | // Dialog Data | ||
22 | //{{AFX_DATA(T42AnnounceDlg) | ||
23 | enum { IDD = IDD_ANNOUNCE }; | ||
24 | CStaticm_CalleeCtl; | ||
25 | CStaticm_TTYCtl; | ||
26 | CButtonm_YesCtl; | ||
27 | CButtonm_NotMeCtl; | ||
28 | CButtonm_SecretaryCtl; | ||
29 | CStaticm_CallerCtl; | ||
30 | CStringm_Callee; | ||
31 | CStringm_Caller; | ||
32 | CStringm_TTY; | ||
33 | //}}AFX_DATA | ||
34 | |||
35 | |||
36 | // Overrides | ||
37 | // ClassWizard generated virtual function overrides | ||
38 | //{{AFX_VIRTUAL(T42AnnounceDlg) | ||
39 | protected: | ||
40 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support | ||
41 | //}}AFX_VIRTUAL | ||
42 | |||
43 | // Implementation | ||
44 | protected: | ||
45 | |||
46 | // Generated message map functions | ||
47 | //{{AFX_MSG(T42AnnounceDlg) | ||
48 | virtual BOOL OnInitDialog(); | ||
49 | afx_msg LRESULT OnSourceResolved(WPARAM,LPARAM); | ||
50 | afx_msg void OnDestroy(); | ||
51 | afx_msg void OnTimer(UINT nIDEvent); | ||
52 | afx_msg void OnSecretary(); | ||
53 | //}}AFX_MSG | ||
54 | DECLARE_MESSAGE_MAP() | ||
55 | }; | ||
diff --git a/T42CallLog.h b/T42CallLog.h new file mode 100644 index 0000000..fa4a331 --- a/dev/null +++ b/T42CallLog.h | |||
@@ -0,0 +1,53 @@ | |||
1 | class CT42CallLogEntry : public CObject{ | ||
2 | public: | ||
3 | enum { | ||
4 | statusOk = 0, statusFailed, statusProcessed, | ||
5 | statusNone | ||
6 | }; | ||
7 | UINT m_Status; | ||
8 | CTime m_Time; | ||
9 | CString m_Caller; | ||
10 | CString m_Callee; | ||
11 | CString m_TTY; | ||
12 | CTimeSpan m_Duration; | ||
13 | CString m_Message; | ||
14 | |||
15 | CT42CallLogEntry() : m_Status(statusNone) {} | ||
16 | CT42CallLogEntry(CT42CallLogEntry& src) { Copy(src); } | ||
17 | |||
18 | void Copy(const CT42CallLogEntry& src) { | ||
19 | m_Status = src.m_Status; | ||
20 | m_Time = src.m_Time; | ||
21 | m_Caller = src.m_Caller; m_Callee = src.m_Callee; | ||
22 | m_TTY = src.m_TTY; | ||
23 | m_Duration = src.m_Duration; | ||
24 | m_Message = src.m_Message; | ||
25 | } | ||
26 | CT42CallLogEntry& operator=(const CT42CallLogEntry& src) { | ||
27 | Copy(src); | ||
28 | return *this; | ||
29 | } | ||
30 | |||
31 | void Serialize(CArchive& ar) { | ||
32 | if(ar.IsStoring()){ | ||
33 | ar << m_Status; | ||
34 | ar << m_Time; | ||
35 | ar << m_Caller; ar << m_Callee; ar << m_TTY; | ||
36 | ar << m_Duration; | ||
37 | ar << m_Message; | ||
38 | }else{ | ||
39 | ar >> m_Status; | ||
40 | ar >> m_Time; | ||
41 | ar >> m_Caller; ar >> m_Callee; ar >> m_TTY; | ||
42 | ar >> m_Duration; | ||
43 | ar >> m_Message; | ||
44 | } | ||
45 | } | ||
46 | }; | ||
47 | |||
48 | inline void SerializeElements(CArchive& ar, CT42CallLogEntry* pElements, int nCount) { | ||
49 | for(int tmp=0;tmp<nCount;tmp++) | ||
50 | pElements[tmp].Serialize(ar); | ||
51 | } | ||
52 | |||
53 | typedef Klever::CBTreendex<CTime,CT42CallLogEntry,16,512> CT42CallLog; | ||
diff --git a/T42Dlg.cpp b/T42Dlg.cpp new file mode 100644 index 0000000..8990957 --- a/dev/null +++ b/T42Dlg.cpp | |||
@@ -0,0 +1,1251 @@ | |||
1 | // T42Dlg.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "T42Dlg.h" | ||
7 | |||
8 | #include "T42Frame.h" | ||
9 | #include "T42AnnounceDlg.h" | ||
10 | #include "T42Document.h" | ||
11 | #include "T42Secretary.h" | ||
12 | |||
13 | #ifdef _DEBUG | ||
14 | #define new DEBUG_NEW | ||
15 | #undef THIS_FILE | ||
16 | static char THIS_FILE[] = __FILE__; | ||
17 | #endif | ||
18 | |||
19 | ///////////////////////////////////////////////////////////////////////////// | ||
20 | // CAboutDlg dialog used for App About | ||
21 | |||
22 | class CAboutDlg : public CDialog | ||
23 | { | ||
24 | public: | ||
25 | CAboutDlg(); | ||
26 | |||
27 | // Dialog Data | ||
28 | //{{AFX_DATA(CAboutDlg) | ||
29 | enum { IDD = IDD_ABOUTBOX }; | ||
30 | //}}AFX_DATA | ||
31 | |||
32 | // ClassWizard generated virtual function overrides | ||
33 | //{{AFX_VIRTUAL(CAboutDlg) | ||
34 | protected: | ||
35 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support | ||
36 | //}}AFX_VIRTUAL | ||
37 | |||
38 | // Implementation | ||
39 | protected: | ||
40 | //{{AFX_MSG(CAboutDlg) | ||
41 | afx_msg void OnKlevernet(); | ||
42 | //}}AFX_MSG | ||
43 | DECLARE_MESSAGE_MAP() | ||
44 | }; | ||
45 | |||
46 | CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) | ||
47 | { | ||
48 | //{{AFX_DATA_INIT(CAboutDlg) | ||
49 | //}}AFX_DATA_INIT | ||
50 | } | ||
51 | |||
52 | void CAboutDlg::DoDataExchange(CDataExchange* pDX) | ||
53 | { | ||
54 | CDialog::DoDataExchange(pDX); | ||
55 | //{{AFX_DATA_MAP(CAboutDlg) | ||
56 | //}}AFX_DATA_MAP | ||
57 | } | ||
58 | |||
59 | BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) | ||
60 | //{{AFX_MSG_MAP(CAboutDlg) | ||
61 | ON_BN_CLICKED(IDC_KLEVERNET, OnKlevernet) | ||
62 | //}}AFX_MSG_MAP | ||
63 | END_MESSAGE_MAP() | ||
64 | |||
65 | |||
66 | void CAboutDlg::OnKlevernet() | ||
67 | { | ||
68 | CString url; | ||
69 | VERIFY(url.LoadString(IDS_KLEVERNET_URL)); | ||
70 | ShellExecute(::GetDesktopWindow(),"open",url,NULL,NULL,SW_SHOWMAXIMIZED); | ||
71 | } | ||
72 | |||
73 | ///////////////////////////////////////////////////////////////////////////// | ||
74 | // CT42Dlg dialog | ||
75 | |||
76 | CT42Dlg::CT42Dlg(CWnd* pParent /*=NULL*/) | ||
77 | : CDialog(CT42Dlg::IDD, pParent), | ||
78 | m_sizeMin(0,0) | ||
79 | { | ||
80 | //{{AFX_DATA_INIT(CT42Dlg) | ||
81 | //}}AFX_DATA_INIT | ||
82 | // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 | ||
83 | m_hIconEmpty = m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); | ||
84 | m_hIconFull = AfxGetApp()->LoadIcon(IDI_FULLCUP); | ||
85 | m_newCalls = 0; | ||
86 | m_daemonSocket = INVALID_SOCKET; | ||
87 | m_talkLifetime = CTimeSpan(0,0,3,0);// 3 mins.. | ||
88 | m_trackTalkID = 1; | ||
89 | m_bmpBack.LoadBitmap(IDB_BACK); | ||
90 | m_bmpBack.GetBitmap(&m_bitmapBack); | ||
91 | m_bExiting = m_bShown = FALSE; | ||
92 | m_hExFW = NULL; | ||
93 | m_marginX = m_marginY = m_gapY = 0; | ||
94 | m_bAway = FALSE; | ||
95 | m_onCall = 0; | ||
96 | m_onCallAway = IDC_SECRETARY; | ||
97 | LoadSettings(); | ||
98 | } | ||
99 | |||
100 | CT42Dlg::~CT42Dlg() | ||
101 | { | ||
102 | SaveSettings(); | ||
103 | } | ||
104 | |||
105 | void CT42Dlg::DoDataExchange(CDataExchange* pDX) | ||
106 | { | ||
107 | CDialog::DoDataExchange(pDX); | ||
108 | //{{AFX_DATA_MAP(CT42Dlg) | ||
109 | DDX_Control(pDX, IDOK, m_ExitCtl); | ||
110 | DDX_Control(pDX, IDC_TALK, m_TeaCtl); | ||
111 | DDX_Control(pDX, IDC_AWAY, m_AwayCtl); | ||
112 | DDX_Control(pDX, ID_HELP, m_HelpCtl); | ||
113 | DDX_Control(pDX, IDC_OPTIONS, m_OptionsCtl); | ||
114 | DDX_Control(pDX, IDC_ONCALLAWAY, m_OnCallAwayCtl); | ||
115 | DDX_Control(pDX, IDC_ONCALL, m_OnCallCtl); | ||
116 | DDX_Control(pDX, IDC_CALLS, m_CallsCtl); | ||
117 | DDX_Control(pDX, IDC_PREVIEW, m_PreviewCtl); | ||
118 | //}}AFX_DATA_MAP | ||
119 | if(pDX->m_bSaveAndValidate){ | ||
120 | m_onCall = GetOnCtl(m_OnCallCtl); | ||
121 | m_onCallAway = GetOnCtl(m_OnCallAwayCtl); | ||
122 | }else{ | ||
123 | SetOnCtl(m_onCall,m_OnCallCtl); | ||
124 | SetOnCtl(m_onCallAway,m_OnCallAwayCtl); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | BEGIN_MESSAGE_MAP(CT42Dlg, CDialog) | ||
129 | //{{AFX_MSG_MAP(CT42Dlg) | ||
130 | ON_WM_SYSCOMMAND() | ||
131 | ON_WM_DESTROY() | ||
132 | ON_WM_PAINT() | ||
133 | ON_WM_QUERYDRAGICON() | ||
134 | ON_BN_CLICKED(IDC_TALK, OnTalk) | ||
135 | ON_MESSAGE(WM_DAEMON, OnDaemon) | ||
136 | ON_WM_CREATE() | ||
137 | ON_MESSAGE(WM_TRAYICON, OnTrayIcon) | ||
138 | ON_WM_WINDOWPOSCHANGING() | ||
139 | ON_COMMAND(ID_TRAY_EXIT, OnTrayExit) | ||
140 | ON_COMMAND(ID_TRAY_OPTIONS, OnTrayOptions) | ||
141 | ON_COMMAND(ID_TRAY_SHOWMAINWINDOW, OnTrayShowmainwindow) | ||
142 | ON_COMMAND(ID_TRAY_T42, OnTrayT42) | ||
143 | ON_BN_CLICKED(IDC_OPTIONS, OnOptions) | ||
144 | ON_NOTIFY(LVN_GETDISPINFO, IDC_CALLS, OnGetdispinfoCalls) | ||
145 | ON_NOTIFY(LVN_ITEMCHANGED, IDC_CALLS, OnItemchangedCalls) | ||
146 | ON_NOTIFY(NM_RCLICK, IDC_CALLS, OnRclickCalls) | ||
147 | ON_COMMAND(ID_CALLLOG_CALLBACK, OnCalllogCallback) | ||
148 | ON_COMMAND(ID_CALLLOG_DELETE, OnCalllogDelete) | ||
149 | ON_COMMAND(ID_CALLLOG_SAVETOFILE, OnCalllogSavetofile) | ||
150 | ON_COMMAND(ID_CALLLOG_EMPTYLOG, OnCalllogEmptylog) | ||
151 | ON_NOTIFY(LVN_DELETEITEM, IDC_CALLS, OnDeleteitemCalls) | ||
152 | ON_MESSAGE(WM_UPDATEPREVIEW, OnUpdatePreview) | ||
153 | ON_NOTIFY(LVN_KEYDOWN, IDC_CALLS, OnKeydownCalls) | ||
154 | ON_WM_SHOWWINDOW() | ||
155 | ON_COMMAND(ID_CALLLOG_MARKASNEW, OnCalllogMarkasnew) | ||
156 | ON_COMMAND(ID_CALLLOG_MARKASPROCESSED, OnCalllogMarkasprocessed) | ||
157 | ON_WM_SIZE() | ||
158 | ON_WM_GETMINMAXINFO() | ||
159 | ON_BN_CLICKED(IDC_AWAY, OnAway) | ||
160 | ON_CBN_SELENDOK(IDC_ONCALL, OnSelendokOncall) | ||
161 | ON_CBN_SELENDOK(IDC_ONCALLAWAY, OnSelendokOncallaway) | ||
162 | ON_COMMAND(ID_TRAY_AWAY, OnTrayAway) | ||
163 | ON_WM_TIMER() | ||
164 | ON_WM_QUERYENDSESSION() | ||
165 | //}}AFX_MSG_MAP | ||
166 | END_MESSAGE_MAP() | ||
167 | |||
168 | ///////////////////////////////////////////////////////////////////////////// | ||
169 | // CT42Dlg message handlers | ||
170 | |||
171 | BOOL CT42Dlg::OnInitDialog() | ||
172 | { | ||
173 | CDialog::OnInitDialog(); | ||
174 | |||
175 | // Add "About..." menu item to system menu. | ||
176 | |||
177 | // IDM_ABOUTBOX must be in the system command range. | ||
178 | ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); | ||
179 | ASSERT(IDM_ABOUTBOX < 0xF000); | ||
180 | |||
181 | CMenu* pSysMenu = GetSystemMenu(FALSE); | ||
182 | CString strAboutMenu; | ||
183 | strAboutMenu.LoadString(IDS_ABOUTBOX); | ||
184 | if (!strAboutMenu.IsEmpty()) | ||
185 | { | ||
186 | pSysMenu->AppendMenu(MF_SEPARATOR); | ||
187 | pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); | ||
188 | } | ||
189 | |||
190 | // Set the icon for this dialog. The framework does this automatically | ||
191 | // when the application's main window is not a dialog | ||
192 | SetIcon(m_hIcon, TRUE); // Set big icon | ||
193 | SetIcon(m_hIcon, FALSE); // Set small icon | ||
194 | |||
195 | CT42App* app = (CT42App*)AfxGetApp(); | ||
196 | { | ||
197 | int x = -1,y = -1,cx = -1,cy = -1; | ||
198 | x = app->GetProfileInt("T42MainWindow","X",x); | ||
199 | y = app->GetProfileInt("T42MainWindow","Y",y); | ||
200 | cx = app->GetProfileInt("T42MainWindow","Width",cx); | ||
201 | cy = app->GetProfileInt("T42MainWindow","Height",cy); | ||
202 | if(cx>0 && cy>0) | ||
203 | SetWindowPos(NULL,x,y,cx,cy,SWP_NOACTIVATE|SWP_NOZORDER); | ||
204 | } | ||
205 | |||
206 | ::SetForegroundWindow(m_hExFW); | ||
207 | |||
208 | m_PreviewCtl.ModifyStyle(0,WS_VSCROLL); | ||
209 | m_PreviewCtl.SetOptions(ECOOP_SET,ECO_AUTOWORDSELECTION| | ||
210 | ECO_AUTOVSCROLL|ECO_AUTOHSCROLL|ECO_READONLY|ECO_SELECTIONBAR); | ||
211 | m_PreviewCtl.SetReadOnly(TRUE); | ||
212 | m_PreviewCtl.SetTargetDevice(NULL,0); | ||
213 | m_PreviewCtl.SetBackgroundColor(FALSE,((CT42App*)AfxGetApp())->m_crT42RemoteBG); | ||
214 | |||
215 | m_CallsCtl.SetBkColor(RGB(0,192,0)); | ||
216 | m_CallsCtl.SetTextColor(RGB(255,255,0)); | ||
217 | m_CallsCtl.SetTextBkColor(RGB(0,192,0)); | ||
218 | m_Images.Create(16,16,TRUE,2,1); | ||
219 | m_iNew = m_Images.Add(AfxGetApp()->LoadIcon(IDI_T42CALLNEW)); | ||
220 | m_iProcessed = m_Images.Add(AfxGetApp()->LoadIcon(IDI_T42CALLPROCESSED)); | ||
221 | ASSERT( m_iNew>=0 && m_iProcessed>=0); | ||
222 | m_CallsCtl.SetImageList(&m_Images,LVSIL_NORMAL); | ||
223 | m_CallsCtl.SetImageList(&m_Images,LVSIL_SMALL); | ||
224 | m_CallsCtl.SetImageList(&m_Images,LVSIL_STATE); | ||
225 | InitCalls(); | ||
226 | |||
227 | CRect wrci, wrco; | ||
228 | GetWindowRect(&wrco); | ||
229 | GetClientRect(&wrci); | ||
230 | // Pull out margins | ||
231 | CRect crc; | ||
232 | m_CallsCtl.GetWindowRect(crc); ScreenToClient(crc); | ||
233 | m_marginX = crc.left; | ||
234 | CRect trc; | ||
235 | m_TeaCtl.GetWindowRect(trc); ScreenToClient(trc); | ||
236 | m_marginY = trc.top; | ||
237 | CRect prc; | ||
238 | m_PreviewCtl.GetWindowRect(prc); ScreenToClient(prc); | ||
239 | m_gapY = prc.top-crc.bottom; | ||
240 | |||
241 | RecalcLayout(); | ||
242 | SetColumnWidths(); | ||
243 | |||
244 | // Calc minimum size | ||
245 | CRect arc; | ||
246 | m_AwayCtl.GetWindowRect(arc); ScreenToClient(arc); | ||
247 | m_sizeMin.cx = arc.right+m_marginX*2+trc.Width()+wrco.Width()-wrci.Width(); | ||
248 | m_sizeMin.cy = crc.top+m_marginY+m_gapY+40*2+wrco.Height()-wrci.Height(); | ||
249 | |||
250 | SetTimer(timerMinutes,60000,NULL); | ||
251 | |||
252 | m_daemonSocket = socket(AF_INET,SOCK_DGRAM,0); | ||
253 | if(m_daemonSocket == INVALID_SOCKET){ | ||
254 | TRACE0("Failed to initialize daemon\n"); | ||
255 | return TRUE; | ||
256 | } | ||
257 | sockaddr_in da; | ||
258 | da.sin_family = AF_INET; | ||
259 | da.sin_port = htons(app->m_T42TalkPort); | ||
260 | da.sin_addr.s_addr = INADDR_ANY; | ||
261 | if(bind(m_daemonSocket,(sockaddr*)&da,sizeof(da))){ | ||
262 | AfxMessageBox(IDS_DAEMON_FAIL,MB_OK|MB_ICONSTOP); | ||
263 | TRACE0("Failed to bind daemon socket\n"); | ||
264 | return TRUE; | ||
265 | } | ||
266 | if(WSAAsyncSelect(m_daemonSocket,m_hWnd,WM_DAEMON,FD_READ)){ | ||
267 | AfxMessageBox(IDS_DAEMON_FAIL,MB_OK|MB_ICONSTOP); | ||
268 | TRACE0("AsyncSelect failed on daemon socket\n"); | ||
269 | return TRUE; | ||
270 | } | ||
271 | |||
272 | return TRUE; // return TRUE unless you set the focus to a control | ||
273 | } | ||
274 | |||
275 | void CT42Dlg::OnSysCommand(UINT nID, LPARAM lParam) | ||
276 | { | ||
277 | if ((nID & 0xFFF0) == IDM_ABOUTBOX){ | ||
278 | CAboutDlg dlgAbout; | ||
279 | dlgAbout.DoModal(); | ||
280 | }else{ | ||
281 | if(nID==SC_SCREENSAVE){ | ||
282 | TRACE0("SCRS\n"); | ||
283 | }else if(nID==SC_MONITORPOWER){ | ||
284 | TRACE0("MP\n"); | ||
285 | }else | ||
286 | TRACE1("SYSCOM: 0x%04X\n",nID); | ||
287 | CDialog::OnSysCommand(nID, lParam); | ||
288 | } | ||
289 | } | ||
290 | |||
291 | void CT42Dlg::OnDestroy() | ||
292 | { | ||
293 | CT42App* app = (CT42App*)AfxGetApp(); | ||
294 | CDocTemplate* pTemplate = app->m_pTemplate; | ||
295 | pTemplate->CloseAllDocuments(FALSE); | ||
296 | CRect rc; | ||
297 | GetWindowRect(rc); | ||
298 | app->WriteProfileInt("T42MainWindow","X",rc.left); | ||
299 | app->WriteProfileInt("T42MainWindow","Y",rc.top); | ||
300 | app->WriteProfileInt("T42MainWindow","Width",rc.Width()); | ||
301 | app->WriteProfileInt("T42MainWindow","Height",rc.Height()); | ||
302 | |||
303 | NOTIFYICONDATA nid; | ||
304 | memset(&nid,0,sizeof(nid)); | ||
305 | nid.cbSize=sizeof(nid); | ||
306 | nid.hWnd=m_hWnd; | ||
307 | nid.uID=IDC_TRAYICON; | ||
308 | nid.uFlags=0; | ||
309 | VERIFY(Shell_NotifyIcon(NIM_DELETE,&nid)); | ||
310 | |||
311 | WinHelp(0L, HELP_QUIT); | ||
312 | CDialog::OnDestroy(); | ||
313 | } | ||
314 | |||
315 | // If you add a minimize button to your dialog, you will need the code below | ||
316 | // to draw the icon. For MFC applications using the document/view model, | ||
317 | // this is automatically done for you by the framework. | ||
318 | |||
319 | void CT42Dlg::OnPaint() | ||
320 | { | ||
321 | if (IsIconic()) | ||
322 | { | ||
323 | CPaintDC dc(this); // device context for painting | ||
324 | |||
325 | SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); | ||
326 | |||
327 | // Center icon in client rectangle | ||
328 | int cxIcon = GetSystemMetrics(SM_CXICON); | ||
329 | int cyIcon = GetSystemMetrics(SM_CYICON); | ||
330 | CRect rect; | ||
331 | GetClientRect(&rect); | ||
332 | int x = (rect.Width() - cxIcon + 1) / 2; | ||
333 | int y = (rect.Height() - cyIcon + 1) / 2; | ||
334 | |||
335 | // Draw the icon | ||
336 | dc.DrawIcon(x, y, m_hIcon); | ||
337 | } | ||
338 | else | ||
339 | { | ||
340 | CPaintDC pDC(this); | ||
341 | CDC bmpDC; | ||
342 | bmpDC.CreateCompatibleDC(&pDC); | ||
343 | bmpDC.SelectObject(&m_bmpBack); | ||
344 | CRect rc; | ||
345 | GetClientRect(&rc); | ||
346 | for(int x=-m_bitmapBack.bmWidth*2/4;x<rc.Width();x+=m_bitmapBack.bmWidth) | ||
347 | for(int y=-m_bitmapBack.bmHeight*2/4;y<rc.Height();y+=m_bitmapBack.bmHeight) | ||
348 | pDC.BitBlt(x,y,m_bitmapBack.bmWidth,m_bitmapBack.bmHeight,&bmpDC,0,0,SRCCOPY); | ||
349 | bmpDC.DeleteDC(); | ||
350 | CDialog::OnPaint(); | ||
351 | } | ||
352 | } | ||
353 | |||
354 | // The system calls this to obtain the cursor to display while the user drags | ||
355 | // the minimized window. | ||
356 | HCURSOR CT42Dlg::OnQueryDragIcon() | ||
357 | { | ||
358 | return (HCURSOR) m_hIcon; | ||
359 | } | ||
360 | |||
361 | void CT42Dlg::OnTalk() | ||
362 | { | ||
363 | CDocTemplate* pTemplate = ((CT42App*)AfxGetApp())->m_pTemplate; | ||
364 | T42Document* pDoc = (T42Document*)pTemplate->OpenDocumentFile(NULL); | ||
365 | ASSERT_KINDOF(T42Document,pDoc); | ||
366 | pDoc->Talk(); | ||
367 | } | ||
368 | |||
369 | LRESULT CT42Dlg::OnDaemon(WPARAM wP,LPARAM lP) | ||
370 | { | ||
371 | if(WSAGETSELECTERROR(lP)){ | ||
372 | TRACE1("Error on daemon socket: %ld\n", WSAGETSELECTERROR(lP)); | ||
373 | return -1; | ||
374 | } | ||
375 | ASSERT(WSAGETSELECTEVENT(lP)&FD_READ); | ||
376 | TalkCtlMessage rq; | ||
377 | if(recv(m_daemonSocket,(char*)&rq,sizeof(rq),0)!=sizeof(rq)){ | ||
378 | TRACE("Bad packet size on daemon socket\n"); | ||
379 | return -1; | ||
380 | } | ||
381 | TalkCtlResponse rp; | ||
382 | TRACE3("*DAEMON-REQUEST*\nV: %d, T: %d, ID: %ld\n", | ||
383 | (int)rq.m_Version, (int)rq.m_Type, ntohl(rq.m_ID) | ||
384 | ); | ||
385 | TRACE2("ADDR: %s:%d\n", | ||
386 | inet_ntoa(((sockaddr_in*)&rq.m_Addr)->sin_addr), | ||
387 | ntohs(((sockaddr_in*)&rq.m_Addr)->sin_port) | ||
388 | ); | ||
389 | TRACE2("CTL ADDR: %s:%d\n", | ||
390 | inet_ntoa(((sockaddr_in*)&rq.m_ctlAddr)->sin_addr), | ||
391 | ntohs(((sockaddr_in*)&rq.m_ctlAddr)->sin_port) | ||
392 | ); | ||
393 | TRACE3("PID: %ld, LU: %s, RU: %s\n", | ||
394 | rq.m_PID,rq.m_LName,rq.m_RName | ||
395 | ); | ||
396 | TRACE1("TTY: %s\n---\n",rq.m_RTTY); | ||
397 | |||
398 | rp.m_Version = talkCtlVersion; | ||
399 | rp.m_Type = rq.m_Type; | ||
400 | rp.m_ID = htonl(0); | ||
401 | rp.m_Answer = talkCtlReserved; | ||
402 | sockaddr_in a; | ||
403 | memmove(&a,&rq.m_ctlAddr,sizeof(a)); | ||
404 | a.sin_family = ntohs(a.sin_family); | ||
405 | do{ | ||
406 | if(rq.m_Version!=talkCtlVersion){ | ||
407 | rp.m_Answer = talkCtlBadVersion; | ||
408 | break; | ||
409 | } | ||
410 | if(rq.m_Addr.sa_family!=htons(AF_INET)){ | ||
411 | rp.m_Answer = talkCtlBadAddr; | ||
412 | break; | ||
413 | } | ||
414 | if(rq.m_ctlAddr.sa_family!=htons(AF_INET)){ | ||
415 | rp.m_Answer = talkCtlBadCtlAddr; | ||
416 | break; | ||
417 | } | ||
418 | switch(rq.m_Type){ | ||
419 | case talkCtlReqAnnounce: | ||
420 | { | ||
421 | CTime ct = CTime::GetCurrentTime(); | ||
422 | POSITION p = m_talks.GetHeadPosition(); | ||
423 | BOOL bFound = FALSE; | ||
424 | while(p){ | ||
425 | POSITION dp = p; | ||
426 | CTTable& t = m_talks.GetNext(p); | ||
427 | if((ct-t.m_Time)>m_talkLifetime){ | ||
428 | TRACE0("Removing Expired request\n"); | ||
429 | m_talks.RemoveAt(dp); | ||
430 | }else if(t==rq){ | ||
431 | t.m_Time = ct; | ||
432 | rp.m_ID = t.m_RQ.m_ID; | ||
433 | bFound = TRUE; | ||
434 | break; | ||
435 | } | ||
436 | } | ||
437 | if(bFound){ | ||
438 | // ** handle re-announces | ||
439 | rp.m_Answer = talkCtlSuccess; | ||
440 | break; | ||
441 | } | ||
442 | UINT nAction = m_bAway?m_onCallAway:m_onCall; | ||
443 | T42AnnounceDlg ad(rq); | ||
444 | CT42App* app = (CT42App*)AfxGetApp(); | ||
445 | if( | ||
446 | nAction==IDC_SECRETARY | ||
447 | && app->m_T42SWinLimit | ||
448 | && app->m_T42LinesBusy>=app->m_T42SWinLimit | ||
449 | ) | ||
450 | nAction = IDC_NOTHERE;// ?? | ||
451 | if(nAction!=IDC_SECRETARY && nAction!=IDC_NOTHERE | ||
452 | && nAction!=IDC_REFUSE && nAction!=IDCANCEL | ||
453 | ){ | ||
454 | CTTable t; | ||
455 | memmove(&t.m_RQ,&rq,sizeof(t.m_RQ)); | ||
456 | t.m_Time = ct; | ||
457 | t.m_RQ.m_ID = rp.m_ID = htonl(m_trackTalkID++); | ||
458 | m_talks.AddHead(t); | ||
459 | rp.m_Answer = talkCtlSuccess; | ||
460 | if(sendto(m_daemonSocket,(char*)&rp,sizeof(rp),0,(sockaddr*)&a,sizeof(a))!=sizeof(rp)){ | ||
461 | TRACE0("Failed to send daemon response\n"); | ||
462 | return -1; | ||
463 | } | ||
464 | HWND hFW = ::GetForegroundWindow(); | ||
465 | nAction = ad.DoModal(); | ||
466 | ::SetForegroundWindow(hFW); | ||
467 | }else{ | ||
468 | if(nAction==IDC_NOTHERE || nAction==IDC_REFUSE){ | ||
469 | rp.m_Answer=(nAction==IDC_NOTHERE)?talkCtlNotHere:talkCtlPermissionDenied; | ||
470 | break; | ||
471 | } | ||
472 | CTTable t; | ||
473 | memmove(&t.m_RQ,&rq,sizeof(t.m_RQ)); | ||
474 | t.m_Time = ct; | ||
475 | t.m_RQ.m_ID = rp.m_ID = htonl(m_trackTalkID++); | ||
476 | m_talks.AddHead(t); | ||
477 | rp.m_Answer = talkCtlSuccess; | ||
478 | if(sendto(m_daemonSocket,(char*)&rp,sizeof(rp),0,(sockaddr*)&a,sizeof(a))!=sizeof(rp)){ | ||
479 | TRACE0("Failed to send daemon response\n"); | ||
480 | return -1; | ||
481 | } | ||
482 | } | ||
483 | rp.m_Answer=talkCtlReserved; | ||
484 | switch(nAction){ | ||
485 | case IDOK: | ||
486 | { | ||
487 | CDocTemplate* pTemplate = ((CT42App*)AfxGetApp())->m_pTemplate; | ||
488 | T42Document* pDoc = (T42Document*)pTemplate->OpenDocumentFile(NULL); | ||
489 | ASSERT_KINDOF(T42Document,pDoc); | ||
490 | pDoc->Talk(ad.m_Callee,ad.m_ipCaller,NULL); | ||
491 | } | ||
492 | break; | ||
493 | case IDC_SECRETARY: | ||
494 | { | ||
495 | HWND hFW = ::GetForegroundWindow(); | ||
496 | CDocTemplate* pTemplate = ((CT42App*)AfxGetApp())->m_pTemplate; | ||
497 | T42Document* pDoc = (T42Document*)pTemplate->OpenDocumentFile("hidden"); | ||
498 | ASSERT_KINDOF(T42Document,pDoc); | ||
499 | pDoc->AttachRobot(new CT42Secretary); | ||
500 | pDoc->Talk(ad.m_Callee,ad.m_ipCaller,NULL); | ||
501 | ::SetForegroundWindow(hFW); | ||
502 | } | ||
503 | break; | ||
504 | case IDCANCEL: | ||
505 | break; | ||
506 | } | ||
507 | } | ||
508 | break; | ||
509 | case talkCtlReqLeaveInvite: | ||
510 | { | ||
511 | CTime ct = CTime::GetCurrentTime(); | ||
512 | POSITION p = m_talks.GetHeadPosition(); | ||
513 | while(p){ | ||
514 | POSITION dp = p; | ||
515 | CTTable& t = m_talks.GetNext(p); | ||
516 | if((ct-t.m_Time)>m_talkLifetime){ | ||
517 | TRACE0("Removing Expired request\n"); | ||
518 | m_talks.RemoveAt(dp); | ||
519 | }else if(t==rq){ | ||
520 | t.m_Time = ct; | ||
521 | rp.m_ID = rq.m_ID; | ||
522 | rp.m_Answer = talkCtlSuccess; | ||
523 | break; | ||
524 | } | ||
525 | } | ||
526 | if(rp.m_Answer!=talkCtlSuccess){ | ||
527 | CTTable t; | ||
528 | memmove(&t.m_RQ,&rq,sizeof(t.m_RQ)); | ||
529 | t.m_Time = ct; | ||
530 | t.m_RQ.m_ID = rp.m_ID = htonl(m_trackTalkID++); | ||
531 | m_talks.AddHead(t); | ||
532 | rp.m_Answer = talkCtlSuccess; | ||
533 | } | ||
534 | } | ||
535 | break; | ||
536 | case talkCtlReqLookUp: | ||
537 | { | ||
538 | CTime ct = CTime::GetCurrentTime(); | ||
539 | POSITION p = m_talks.GetHeadPosition(); | ||
540 | while(p){ | ||
541 | POSITION dp = p; | ||
542 | CTTable& t = m_talks.GetNext(p); | ||
543 | if((ct-t.m_Time)>m_talkLifetime){ | ||
544 | TRACE0("Removing Expired request\n"); | ||
545 | m_talks.RemoveAt(dp); | ||
546 | }else if(t.Match(rq)){ | ||
547 | rp.m_ID = t.m_RQ.m_ID; | ||
548 | memmove(&rp.m_Addr,&t.m_RQ.m_Addr,sizeof(rp.m_Addr)); | ||
549 | rp.m_Answer = talkCtlSuccess; | ||
550 | break; | ||
551 | } | ||
552 | } | ||
553 | if(rp.m_Answer!=talkCtlSuccess) | ||
554 | rp.m_Answer = talkCtlNotHere; | ||
555 | } | ||
556 | break; | ||
557 | case talkCtlReqDelete: | ||
558 | { | ||
559 | CTime ct = CTime::GetCurrentTime(); | ||
560 | POSITION p = m_talks.GetHeadPosition(); | ||
561 | while(p){ | ||
562 | POSITION dp = p; | ||
563 | CTTable& t = m_talks.GetNext(p); | ||
564 | if((ct-t.m_Time)>m_talkLifetime){ | ||
565 | TRACE0("Removing Expired request\n"); | ||
566 | m_talks.RemoveAt(dp); | ||
567 | }else if(t.m_RQ.m_ID == rq.m_ID){ | ||
568 | m_talks.RemoveAt(dp); | ||
569 | rp.m_Answer=talkCtlSuccess; | ||
570 | break; | ||
571 | } | ||
572 | } | ||
573 | if(rp.m_Answer!=talkCtlSuccess) | ||
574 | rp.m_Answer = talkCtlNotHere; | ||
575 | break; | ||
576 | } | ||
577 | break; | ||
578 | default: | ||
579 | TRACE0("Unknown request type\n"); | ||
580 | rp.m_Answer=talkCtlUnknownRequest; | ||
581 | break; | ||
582 | } | ||
583 | }while(FALSE); | ||
584 | if(rp.m_Answer==talkCtlReserved || rp.m_Answer==talkCtlBadCtlAddr) | ||
585 | return -1; | ||
586 | if(sendto(m_daemonSocket,(char*)&rp,sizeof(rp),0,(sockaddr*)&a,sizeof(a))!=sizeof(rp)){ | ||
587 | TRACE0("Failed to send daemon response\n"); | ||
588 | return -1; | ||
589 | } | ||
590 | return 0; | ||
591 | } | ||
592 | |||
593 | int CT42Dlg::OnCreate(LPCREATESTRUCT lpCreateStruct) | ||
594 | { | ||
595 | if (CDialog::OnCreate(lpCreateStruct) == -1) | ||
596 | return -1; | ||
597 | CRichEditCtrl tmp; | ||
598 | tmp.Create(WS_CHILD,CRect(0,0,0,0),this,0); | ||
599 | |||
600 | NOTIFYICONDATA nid; | ||
601 | memset(&nid,0,sizeof(nid)); | ||
602 | nid.cbSize = sizeof(nid); | ||
603 | nid.hWnd = m_hWnd; | ||
604 | nid.uID = IDC_TRAYICON; | ||
605 | nid.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP; | ||
606 | nid.uCallbackMessage=WM_TRAYICON; | ||
607 | nid.hIcon = m_hIcon; | ||
608 | // *** | ||
609 | strcpy(nid.szTip,"Tea For Two"); | ||
610 | VERIFY(Shell_NotifyIcon(NIM_ADD,&nid)); | ||
611 | |||
612 | return 0; | ||
613 | } | ||
614 | |||
615 | LRESULT CT42Dlg::OnTrayIcon(WPARAM wP,LPARAM lP) | ||
616 | { | ||
617 | ASSERT(wP==IDC_TRAYICON); | ||
618 | switch(lP){ | ||
619 | case WM_LBUTTONDOWN: | ||
620 | ToggleVisibility(); | ||
621 | break; | ||
622 | case WM_RBUTTONDOWN: | ||
623 | { | ||
624 | CMenu popups; | ||
625 | VERIFY(popups.LoadMenu(IDM_POPUPS)); | ||
626 | CMenu* popUp = popups.GetSubMenu(0); | ||
627 | ASSERT(popUp); | ||
628 | CPoint pt; | ||
629 | VERIFY(::GetCursorPos(&pt)); | ||
630 | SetForegroundWindow(); | ||
631 | popUp->CheckMenuItem(ID_TRAY_SHOWMAINWINDOW,MF_BYCOMMAND|(IsWindowVisible()?MF_CHECKED:MF_UNCHECKED)); | ||
632 | popUp->CheckMenuItem(ID_TRAY_AWAY,MF_BYCOMMAND|(m_bAway?MF_CHECKED:MF_UNCHECKED)); | ||
633 | popUp->TrackPopupMenu(TPM_RIGHTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, | ||
634 | pt.x,pt.y,this); | ||
635 | SendMessage(WM_NULL); | ||
636 | } | ||
637 | break; | ||
638 | } | ||
639 | return 0; | ||
640 | } | ||
641 | |||
642 | void CT42Dlg::ToggleVisibility() | ||
643 | { | ||
644 | if(IsWindowVisible()){ | ||
645 | m_bShown=FALSE; | ||
646 | ShowWindow(SW_HIDE); | ||
647 | CWnd* pWnd = GetNextWindow(); | ||
648 | if(pWnd){ | ||
649 | pWnd->SetForegroundWindow(); | ||
650 | pWnd->SetFocus(); | ||
651 | } | ||
652 | }else{ | ||
653 | m_bShown=TRUE; | ||
654 | ShowWindow(SW_SHOW); | ||
655 | SetForegroundWindow(); | ||
656 | SetFocus(); | ||
657 | } | ||
658 | } | ||
659 | |||
660 | void CT42Dlg::OnCancel() | ||
661 | { | ||
662 | ToggleVisibility(); | ||
663 | } | ||
664 | |||
665 | |||
666 | void CT42Dlg::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) | ||
667 | { | ||
668 | CDialog::OnWindowPosChanging(lpwndpos); | ||
669 | |||
670 | if(m_bExiting) | ||
671 | return; | ||
672 | if(m_bShown){ | ||
673 | lpwndpos->flags&=~SWP_HIDEWINDOW; | ||
674 | lpwndpos->flags|=SWP_SHOWWINDOW; | ||
675 | }else{ | ||
676 | lpwndpos->flags&=~SWP_SHOWWINDOW; | ||
677 | lpwndpos->flags|=SWP_HIDEWINDOW; | ||
678 | } | ||
679 | } | ||
680 | |||
681 | void CT42Dlg::OnOK() | ||
682 | { | ||
683 | m_bExiting = TRUE; | ||
684 | CDialog::OnOK(); | ||
685 | } | ||
686 | |||
687 | void CT42Dlg::OnTrayExit() | ||
688 | { | ||
689 | OnOK(); | ||
690 | } | ||
691 | |||
692 | void CT42Dlg::OnTrayOptions() | ||
693 | { | ||
694 | OnOptions(); | ||
695 | } | ||
696 | |||
697 | void CT42Dlg::OnTrayShowmainwindow() | ||
698 | { | ||
699 | ToggleVisibility(); | ||
700 | } | ||
701 | |||
702 | void CT42Dlg::OnTrayT42() | ||
703 | { | ||
704 | OnTalk(); | ||
705 | } | ||
706 | |||
707 | void CT42Dlg::OnOptions() | ||
708 | { | ||
709 | CT42App* app = (CT42App*)AfxGetApp(); | ||
710 | app->Options(this); | ||
711 | } | ||
712 | |||
713 | void CT42Dlg::InitCalls() | ||
714 | { | ||
715 | CT42App* app = (CT42App*)AfxGetApp(); | ||
716 | m_CallsCtl.InsertColumn(0,"Time",LVCFMT_LEFT,-1,subitemTime); | ||
717 | m_CallsCtl.InsertColumn(1,"Caller",LVCFMT_LEFT,-1,subitemCaller); | ||
718 | m_CallsCtl.InsertColumn(2,"Callee",LVCFMT_LEFT,-1,subitemCallee); | ||
719 | LONG calls = app->GetT42Calls(); | ||
720 | if(calls>0){ | ||
721 | m_CallsCtl.SetItemCount(calls); | ||
722 | for(LONG tmp=0;tmp<calls;tmp++){ | ||
723 | m_CallsCtl.InsertItem( | ||
724 | LVIF_TEXT, | ||
725 | tmp, | ||
726 | LPSTR_TEXTCALLBACK, | ||
727 | 0,0,// state,statemask | ||
728 | I_IMAGECALLBACK, | ||
729 | 0 // lParam | ||
730 | ); | ||
731 | } | ||
732 | } | ||
733 | SetColumnWidths(); | ||
734 | } | ||
735 | |||
736 | void CT42Dlg::OnGetdispinfoCalls(NMHDR* pNMHDR, LRESULT* pResult) | ||
737 | { | ||
738 | CT42App* app = (CT42App*)AfxGetApp(); | ||
739 | LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; | ||
740 | int iItem = pDispInfo->item.iItem; | ||
741 | CT42CallLogEntry entry; | ||
742 | VERIFY(app->GetT42Call(iItem,entry)); | ||
743 | CString tmp; | ||
744 | switch(pDispInfo->item.iSubItem){ | ||
745 | case subitemTime: | ||
746 | tmp = entry.m_Time.Format(IDS_FORMAT_CALLTIME); | ||
747 | if(entry.m_Status==CT42CallLogEntry::statusProcessed) | ||
748 | pDispInfo->item.iImage = m_iProcessed; | ||
749 | else | ||
750 | pDispInfo->item.iImage = m_iNew; | ||
751 | break; | ||
752 | case subitemCaller: | ||
753 | tmp = entry.m_Caller; | ||
754 | break; | ||
755 | case subitemCallee: | ||
756 | tmp = entry.m_Callee; | ||
757 | break; | ||
758 | default: | ||
759 | ASSERT(FALSE); | ||
760 | break; | ||
761 | } | ||
762 | if(tmp.GetLength()>=pDispInfo->item.cchTextMax) | ||
763 | tmp = tmp.Left(pDispInfo->item.cchTextMax-4)+".."; | ||
764 | strcpy(pDispInfo->item.pszText,tmp); | ||
765 | pDispInfo->item.mask|=LVIF_IMAGE; | ||
766 | pDispInfo->item.mask|=LVIF_TEXT; | ||
767 | |||
768 | *pResult = 0; | ||
769 | } | ||
770 | |||
771 | void CT42Dlg::OnAddT42Call() | ||
772 | { | ||
773 | m_CallsCtl.InsertItem( | ||
774 | LVIF_TEXT, | ||
775 | m_CallsCtl.GetItemCount(), | ||
776 | LPSTR_TEXTCALLBACK, | ||
777 | 0,0,// state,statemask | ||
778 | I_IMAGECALLBACK, | ||
779 | 0 // lParam | ||
780 | ); | ||
781 | m_CallsCtl.RedrawItems(0,m_CallsCtl.GetItemCount()); | ||
782 | m_CallsCtl.Invalidate(); | ||
783 | PostMessage(WM_UPDATEPREVIEW,(WPARAM)-1); | ||
784 | if(!IsWindowVisible()){ | ||
785 | m_newCalls++; | ||
786 | SetTheIcon(m_hIconFull); | ||
787 | } | ||
788 | } | ||
789 | |||
790 | void CT42Dlg::OnDelT42Call() | ||
791 | { | ||
792 | m_CallsCtl.DeleteItem( | ||
793 | m_CallsCtl.GetItemCount()-1 | ||
794 | ); | ||
795 | m_CallsCtl.RedrawItems(0,m_CallsCtl.GetItemCount()); | ||
796 | m_CallsCtl.Invalidate(); | ||
797 | PostMessage(WM_UPDATEPREVIEW,(WPARAM)-1); | ||
798 | } | ||
799 | |||
800 | void CT42Dlg::SetColumnWidths() | ||
801 | { | ||
802 | CTime ct = CTime::GetCurrentTime(); | ||
803 | CString t = ct.Format(IDS_FORMAT_CALLTIME); | ||
804 | CRect rc; | ||
805 | m_CallsCtl.GetClientRect(rc); | ||
806 | INT tw = m_CallsCtl.GetStringWidth(t)+40; | ||
807 | INT cew = m_CallsCtl.GetStringWidth("wwwwwwww"); | ||
808 | INT crw = rc.Width()-(tw+cew); | ||
809 | m_CallsCtl.SetColumnWidth(subitemTime,tw); | ||
810 | m_CallsCtl.SetColumnWidth(subitemCaller,crw); | ||
811 | m_CallsCtl.SetColumnWidth(subitemCallee,cew); | ||
812 | } | ||
813 | |||
814 | void CT42Dlg::OnItemchangedCalls(NMHDR* pNMHDR, LRESULT* pResult) | ||
815 | { | ||
816 | NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; | ||
817 | |||
818 | if( | ||
819 | pNMListView->uChanged&LVIF_STATE | ||
820 | && pNMListView->uNewState&LVIS_FOCUSED | ||
821 | && !(pNMListView->uOldState&LVIS_FOCUSED) | ||
822 | ){ | ||
823 | PostMessage(WM_UPDATEPREVIEW,pNMListView->iItem); | ||
824 | } | ||
825 | *pResult = 0; | ||
826 | } | ||
827 | |||
828 | DWORD CALLBACK CT42Dlg::ESOUTProc(DWORD dwCookie,LPBYTE pbBuff,LONG cb,LONG FAR *pcb) | ||
829 | { | ||
830 | CString* str = (CString*)dwCookie; | ||
831 | if(cb>str->GetLength()) | ||
832 | cb = str->GetLength(); | ||
833 | if(!cb){ | ||
834 | (*pcb)=0; | ||
835 | return 0; | ||
836 | } | ||
837 | memmove(pbBuff,(LPCTSTR)*str,cb); | ||
838 | (*str) = str->Mid(cb); | ||
839 | (*pcb)=cb; | ||
840 | return 0; | ||
841 | } | ||
842 | |||
843 | void CT42Dlg::OnRclickCalls(NMHDR* pNMHDR, LRESULT* pResult) | ||
844 | { | ||
845 | CPoint pt; | ||
846 | VERIFY(GetCursorPos(&pt)); | ||
847 | CMenu popups; | ||
848 | VERIFY(popups.LoadMenu(IDM_POPUPS)); | ||
849 | CMenu* popup = popups.GetSubMenu(1); | ||
850 | ASSERT(popup); | ||
851 | BOOL bYes = ( | ||
852 | m_CallsCtl.GetNextItem(-1,LVNI_ALL|LVNI_FOCUSED)>=0 | ||
853 | || m_CallsCtl.GetNextItem(-1,LVNI_ALL|LVNI_SELECTED)>=0 | ||
854 | ); | ||
855 | popup->EnableMenuItem(ID_CALLLOG_CALLBACK,MF_BYCOMMAND|( | ||
856 | bYes?MF_ENABLED:MF_GRAYED | ||
857 | )); | ||
858 | popup->EnableMenuItem(ID_CALLLOG_DELETE,MF_BYCOMMAND|( | ||
859 | bYes?MF_ENABLED:MF_GRAYED | ||
860 | )); | ||
861 | popup->EnableMenuItem(ID_CALLLOG_SAVETOFILE,MF_BYCOMMAND|( | ||
862 | bYes?MF_ENABLED:MF_GRAYED | ||
863 | )); | ||
864 | popup->EnableMenuItem(ID_CALLLOG_MARKASNEW,MF_BYCOMMAND|( | ||
865 | bYes?MF_ENABLED:MF_GRAYED | ||
866 | )); | ||
867 | popup->EnableMenuItem(ID_CALLLOG_MARKASPROCESSED,MF_BYCOMMAND|( | ||
868 | bYes?MF_ENABLED:MF_GRAYED | ||
869 | )); | ||
870 | popup->EnableMenuItem(ID_CALLLOG_EMPTYLOG,MF_BYCOMMAND|( | ||
871 | (m_CallsCtl.GetItemCount())?MF_ENABLED:MF_GRAYED | ||
872 | )); | ||
873 | popup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_LEFTBUTTON, | ||
874 | pt.x,pt.y,this); | ||
875 | *pResult = 0; | ||
876 | } | ||
877 | |||
878 | void CT42Dlg::OnCalllogCallback() | ||
879 | { | ||
880 | int item = m_CallsCtl.GetNextItem(-1,LVNI_ALL|LVNI_FOCUSED); | ||
881 | if(item<0) | ||
882 | return; | ||
883 | CT42App* app = (CT42App*)AfxGetApp(); | ||
884 | CT42CallLogEntry entry; | ||
885 | VERIFY(app->GetT42Call(item,entry)); | ||
886 | CDocTemplate* pTemplate = app->m_pTemplate; | ||
887 | T42Document* pDoc = (T42Document*)pTemplate->OpenDocumentFile(NULL); | ||
888 | ASSERT_KINDOF(T42Document,pDoc); | ||
889 | pDoc->Talk(entry.m_Callee,entry.m_Caller,NULL); | ||
890 | entry.m_Status=CT42CallLogEntry::statusProcessed; | ||
891 | VERIFY(app->UpdateT42Call(entry)); | ||
892 | m_CallsCtl.Update(item); | ||
893 | } | ||
894 | |||
895 | void CT42Dlg::OnCalllogDelete() | ||
896 | { | ||
897 | CT42App* app = (CT42App*)AfxGetApp(); | ||
898 | int ii = m_CallsCtl.GetItemCount(); | ||
899 | if(ii<=0) | ||
900 | return; | ||
901 | Klever::CBitSet bs(ii); | ||
902 | for(int i=0;i<ii;i++) | ||
903 | if(m_CallsCtl.GetItemState(i,LVIS_FOCUSED|LVIS_SELECTED)) | ||
904 | bs.BitSet(i); | ||
905 | for(i = (ii-1);i>=0;i--){ | ||
906 | if(!bs.IsSet(i)) | ||
907 | continue; | ||
908 | CT42CallLogEntry entry; | ||
909 | VERIFY(app->GetT42Call(i,entry)); | ||
910 | VERIFY(app->DelT42Call(entry.m_Time)); | ||
911 | } | ||
912 | } | ||
913 | |||
914 | void CT42Dlg::OnCalllogSavetofile() | ||
915 | { | ||
916 | CT42App* app = (CT42App*)AfxGetApp(); | ||
917 | CT42CallLogEntry entry; | ||
918 | CString filter; | ||
919 | VERIFY(filter.LoadString(IDS_FILTER_RTF)); | ||
920 | CFileDialog fd(FALSE,".rtf",NULL, | ||
921 | OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_EXPLORER| | ||
922 | OFN_LONGNAMES|OFN_NOREADONLYRETURN|OFN_PATHMUSTEXIST, | ||
923 | filter,this | ||
924 | ); | ||
925 | if(fd.DoModal()==IDOK){ | ||
926 | int ii = m_CallsCtl.GetItemCount(); | ||
927 | if(ii<=0) | ||
928 | return; | ||
929 | Klever::CBitSet bs(ii); | ||
930 | for(int i=0;i<ii;i++) | ||
931 | if(m_CallsCtl.GetItemState(i,LVIS_FOCUSED|LVIS_SELECTED)) | ||
932 | bs.BitSet(i); | ||
933 | try{ | ||
934 | CStdioFile f(fd.GetPathName(), | ||
935 | CFile::modeCreate|CFile::modeWrite|CFile::shareDenyWrite| | ||
936 | CFile::typeText); | ||
937 | f.WriteString("{\\rtf1\\ansi\n"); | ||
938 | for(i = (ii-1);i>=0;i--){ | ||
939 | if(!bs.IsSet(i)) | ||
940 | continue; | ||
941 | CT42CallLogEntry entry; | ||
942 | VERIFY(app->GetT42Call(i,entry)); | ||
943 | CString tmp; | ||
944 | tmp.Format(IDS_FORMAT_T42CALLHEADER, | ||
945 | entry.m_Time.Format(IDS_FORMAT_CALLTIMELONG), | ||
946 | entry.m_Caller, entry.m_Callee, | ||
947 | entry.m_Duration.Format(IDS_FORMAT_CALLDURATION) | ||
948 | ); | ||
949 | f.WriteString(tmp); | ||
950 | f.WriteString(entry.m_Message); | ||
951 | } | ||
952 | f.WriteString("\n}\n"); | ||
953 | }catch(CException* e){ | ||
954 | TRACE0("Save exc\n"); | ||
955 | e->Delete(); | ||
956 | } | ||
957 | } | ||
958 | } | ||
959 | |||
960 | void CT42Dlg::OnCalllogEmptylog() | ||
961 | { | ||
962 | CT42App* app = (CT42App*)AfxGetApp(); | ||
963 | int ii = m_CallsCtl.GetItemCount(); | ||
964 | if(ii<=0) | ||
965 | return; | ||
966 | for(int i = (ii-1);i>=0;i--){ | ||
967 | CT42CallLogEntry entry; | ||
968 | VERIFY(app->GetT42Call(i,entry)); | ||
969 | VERIFY(app->DelT42Call(entry.m_Time)); | ||
970 | } | ||
971 | } | ||
972 | |||
973 | void CT42Dlg::OnDeleteitemCalls(NMHDR* pNMHDR, LRESULT* pResult) | ||
974 | { | ||
975 | NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; | ||
976 | PostMessage(WM_UPDATEPREVIEW,(WPARAM)-1); | ||
977 | *pResult = 0; | ||
978 | } | ||
979 | |||
980 | LRESULT CT42Dlg::OnUpdatePreview(WPARAM wP,LPARAM) | ||
981 | { | ||
982 | int iItem = (int)wP; | ||
983 | if(iItem<0) | ||
984 | iItem = m_CallsCtl.GetNextItem(-1,LVNI_ALL|LVNI_FOCUSED); | ||
985 | CT42App* app = (CT42App*)AfxGetApp(); | ||
986 | CT42CallLogEntry entry; | ||
987 | if(iItem<0 ||!app->GetT42Call(iItem,entry)){ | ||
988 | m_PreviewCtl.SetWindowText(""); | ||
989 | return 0; | ||
990 | } | ||
991 | EDITSTREAM es; | ||
992 | memset(&es,0,sizeof(es)); | ||
993 | es.dwCookie = (DWORD)&entry.m_Message; | ||
994 | es.pfnCallback = ESOUTProc; | ||
995 | m_PreviewCtl.StreamIn(SF_RTF,es); | ||
996 | return 0; | ||
997 | } | ||
998 | |||
999 | void CT42Dlg::OnKeydownCalls(NMHDR* pNMHDR, LRESULT* pResult) | ||
1000 | { | ||
1001 | LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR; | ||
1002 | |||
1003 | switch(pLVKeyDow->wVKey){ | ||
1004 | case 'R': | ||
1005 | if(GetKeyState(VK_CONTROL)&0x8000) | ||
1006 | OnCalllogCallback(); | ||
1007 | break; | ||
1008 | case VK_DELETE: | ||
1009 | OnCalllogDelete(); | ||
1010 | break; | ||
1011 | case 'D': | ||
1012 | if(GetKeyState(VK_CONTROL)&0x8000) | ||
1013 | OnCalllogDelete(); | ||
1014 | break; | ||
1015 | } | ||
1016 | *pResult = 0; | ||
1017 | } | ||
1018 | |||
1019 | BOOL CT42Dlg::PreCreateWindow(CREATESTRUCT& cs) | ||
1020 | { | ||
1021 | m_hExFW = ::GetForegroundWindow(); | ||
1022 | return CDialog::PreCreateWindow(cs); | ||
1023 | } | ||
1024 | |||
1025 | void CT42Dlg::SetTheIcon(HICON hIcon) | ||
1026 | { | ||
1027 | m_hIcon = hIcon; | ||
1028 | SetIcon(m_hIcon, TRUE); // Set big icon | ||
1029 | SetIcon(m_hIcon, FALSE); // Set small icon | ||
1030 | NOTIFYICONDATA nid; | ||
1031 | memset(&nid,0,sizeof(nid)); | ||
1032 | nid.cbSize = sizeof(nid); | ||
1033 | nid.hWnd = m_hWnd; | ||
1034 | nid.uID = IDC_TRAYICON; | ||
1035 | nid.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP; | ||
1036 | nid.uCallbackMessage=WM_TRAYICON; | ||
1037 | nid.hIcon = hIcon; | ||
1038 | if(m_newCalls) | ||
1039 | _snprintf(nid.szTip,sizeof(nid.szTip)-1,"%d new calls waiting",m_newCalls); | ||
1040 | else | ||
1041 | strcpy(nid.szTip,"Tea For Two"); | ||
1042 | VERIFY(Shell_NotifyIcon(NIM_MODIFY,&nid)); | ||
1043 | } | ||
1044 | |||
1045 | void CT42Dlg::OnShowWindow(BOOL bShow, UINT nStatus) | ||
1046 | { | ||
1047 | CDialog::OnShowWindow(bShow, nStatus); | ||
1048 | if(bShow){ | ||
1049 | m_newCalls=0; | ||
1050 | SetTheIcon(m_hIconEmpty); | ||
1051 | } | ||
1052 | } | ||
1053 | |||
1054 | void CT42Dlg::OnCalllogMarkasnew() | ||
1055 | { | ||
1056 | CT42App* app = (CT42App*)AfxGetApp(); | ||
1057 | int ii = m_CallsCtl.GetItemCount(); | ||
1058 | if(ii<=0) | ||
1059 | return; | ||
1060 | Klever::CBitSet bs(ii); | ||
1061 | for(int i=0;i<ii;i++) | ||
1062 | if(m_CallsCtl.GetItemState(i,LVIS_FOCUSED|LVIS_SELECTED)) | ||
1063 | bs.BitSet(i); | ||
1064 | int f = -1,t = -1; | ||
1065 | for(i = 0;i<ii;i++){ | ||
1066 | if(!bs.IsSet(i)) | ||
1067 | continue; | ||
1068 | CT42CallLogEntry entry; | ||
1069 | VERIFY(app->GetT42Call(i,entry)); | ||
1070 | if(entry.m_Status==CT42CallLogEntry::statusProcessed){ | ||
1071 | entry.m_Status=CT42CallLogEntry::statusOk; | ||
1072 | VERIFY(app->UpdateT42Call(entry)); | ||
1073 | if(f<0) | ||
1074 | f=i; | ||
1075 | if(t<i) | ||
1076 | t=i; | ||
1077 | } | ||
1078 | } | ||
1079 | if(f<0 || t<0) | ||
1080 | return; | ||
1081 | m_CallsCtl.RedrawItems(f,t); | ||
1082 | m_CallsCtl.Invalidate(); | ||
1083 | } | ||
1084 | |||
1085 | void CT42Dlg::OnCalllogMarkasprocessed() | ||
1086 | { | ||
1087 | CT42App* app = (CT42App*)AfxGetApp(); | ||
1088 | int ii = m_CallsCtl.GetItemCount(); | ||
1089 | if(ii<=0) | ||
1090 | return; | ||
1091 | Klever::CBitSet bs(ii); | ||
1092 | for(int i=0;i<ii;i++) | ||
1093 | if(m_CallsCtl.GetItemState(i,LVIS_FOCUSED|LVIS_SELECTED)) | ||
1094 | bs.BitSet(i); | ||
1095 | int f = -1,t = -1; | ||
1096 | for(i = 0;i<ii;i++){ | ||
1097 | if(!bs.IsSet(i)) | ||
1098 | continue; | ||
1099 | CT42CallLogEntry entry; | ||
1100 | VERIFY(app->GetT42Call(i,entry)); | ||
1101 | if(entry.m_Status!=CT42CallLogEntry::statusProcessed){ | ||
1102 | entry.m_Status=CT42CallLogEntry::statusProcessed; | ||
1103 | VERIFY(app->UpdateT42Call(entry)); | ||
1104 | if(f<0) | ||
1105 | f=i; | ||
1106 | if(t<i) | ||
1107 | t=i; | ||
1108 | } | ||
1109 | } | ||
1110 | if(f<0 || t<0) | ||
1111 | return; | ||
1112 | m_CallsCtl.RedrawItems(f,t); | ||
1113 | m_CallsCtl.Invalidate(); | ||
1114 | } | ||
1115 | |||
1116 | void CT42Dlg::RecalcLayout() | ||
1117 | { | ||
1118 | CRect crc; | ||
1119 | GetClientRect(&crc); | ||
1120 | CRect rcCalls; | ||
1121 | m_CallsCtl.GetWindowRect(&rcCalls); | ||
1122 | ScreenToClient(rcCalls); | ||
1123 | // Calculate windows height. | ||
1124 | UINT wHeight = (crc.Height()-rcCalls.top-m_marginY-m_gapY)/2; | ||
1125 | UINT wWidth = crc.Width()-(2*m_marginX); | ||
1126 | // Position windows | ||
1127 | m_CallsCtl.SetWindowPos( | ||
1128 | NULL, | ||
1129 | m_marginX,rcCalls.top-crc.top, wWidth,wHeight, | ||
1130 | SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER | ||
1131 | ); | ||
1132 | m_PreviewCtl.SetWindowPos( | ||
1133 | NULL, | ||
1134 | m_marginX,rcCalls.top-crc.top+wHeight+m_gapY, wWidth,wHeight, | ||
1135 | SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER | ||
1136 | ); | ||
1137 | |||
1138 | CRect brc; | ||
1139 | m_TeaCtl.GetWindowRect(brc); ScreenToClient(brc); | ||
1140 | UINT bX = crc.Width()-m_marginX-brc.Width(); | ||
1141 | m_TeaCtl.SetWindowPos(NULL,bX,brc.top, 0,0,SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCOPYBITS); | ||
1142 | m_OptionsCtl.GetWindowRect(brc); ScreenToClient(brc); | ||
1143 | m_OptionsCtl.SetWindowPos(NULL,bX,brc.top,0,0,SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCOPYBITS); | ||
1144 | m_ExitCtl.GetWindowRect(brc); ScreenToClient(brc); | ||
1145 | m_ExitCtl.SetWindowPos(NULL,bX,brc.top,0,0,SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCOPYBITS); | ||
1146 | m_HelpCtl.GetWindowRect(brc); ScreenToClient(brc); | ||
1147 | m_HelpCtl.SetWindowPos(NULL,bX,brc.top,0,0,SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCOPYBITS); | ||
1148 | } | ||
1149 | |||
1150 | void CT42Dlg::OnSize(UINT nType, int cx, int cy) | ||
1151 | { | ||
1152 | CDialog::OnSize(nType, cx, cy); | ||
1153 | |||
1154 | if(m_marginX && m_marginY && m_gapY){ | ||
1155 | RecalcLayout(); | ||
1156 | SetColumnWidths(); | ||
1157 | } | ||
1158 | |||
1159 | } | ||
1160 | |||
1161 | void CT42Dlg::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) | ||
1162 | { | ||
1163 | if(m_sizeMin.cx && m_sizeMin.cy){ | ||
1164 | lpMMI->ptMinTrackSize.x = m_sizeMin.cx; | ||
1165 | lpMMI->ptMinTrackSize.y = m_sizeMin.cy; | ||
1166 | } | ||
1167 | |||
1168 | CDialog::OnGetMinMaxInfo(lpMMI); | ||
1169 | } | ||
1170 | |||
1171 | void CT42Dlg::SetOnCtl(UINT nAction,CComboBox& ctl) | ||
1172 | { | ||
1173 | int n = 0; | ||
1174 | switch(nAction){ | ||
1175 | case IDC_SECRETARY: n = 1; break; | ||
1176 | case IDC_NOTHERE: n = 2; break; | ||
1177 | case IDC_REFUSE: n = 3; break; | ||
1178 | case IDCANCEL: n = 4; break; | ||
1179 | } | ||
1180 | ctl.SetCurSel(n); | ||
1181 | } | ||
1182 | |||
1183 | UINT CT42Dlg::GetOnCtl(CComboBox& ctl) | ||
1184 | { | ||
1185 | switch(ctl.GetCurSel()){ | ||
1186 | case 1: return IDC_SECRETARY; | ||
1187 | case 2: return IDC_NOTHERE; | ||
1188 | case 3: return IDC_REFUSE; | ||
1189 | case 4: return IDCANCEL; | ||
1190 | } | ||
1191 | return 0; | ||
1192 | } | ||
1193 | |||
1194 | void CT42Dlg::OnAway() | ||
1195 | { | ||
1196 | m_bAway = m_AwayCtl.GetCheck(); | ||
1197 | } | ||
1198 | void CT42Dlg::OnSelendokOncall() | ||
1199 | { | ||
1200 | m_onCall = GetOnCtl(m_OnCallCtl); | ||
1201 | } | ||
1202 | void CT42Dlg::OnSelendokOncallaway() | ||
1203 | { | ||
1204 | m_onCallAway = GetOnCtl(m_OnCallAwayCtl); | ||
1205 | } | ||
1206 | |||
1207 | void CT42Dlg::LoadSettings() | ||
1208 | { | ||
1209 | CT42App* app = (CT42App*)AfxGetApp(); | ||
1210 | m_onCall = app->GetProfileInt("Settings","T42OnCall",m_onCall); | ||
1211 | m_onCallAway = app->GetProfileInt("Settings","T42OnCallAway",m_onCallAway); | ||
1212 | } | ||
1213 | |||
1214 | void CT42Dlg::SaveSettings() | ||
1215 | { | ||
1216 | CT42App* app = (CT42App*)AfxGetApp(); | ||
1217 | app->WriteProfileInt("Settings","T42OnCall",m_onCall); | ||
1218 | app->WriteProfileInt("Settings","T42OnCallAway",m_onCallAway); | ||
1219 | } | ||
1220 | |||
1221 | void CT42Dlg::OnTrayAway() | ||
1222 | { | ||
1223 | m_AwayCtl.SetCheck((m_bAway=!m_bAway)?1:0); | ||
1224 | } | ||
1225 | |||
1226 | void CT42Dlg::OnTimer(UINT nIDEvent) | ||
1227 | { | ||
1228 | if(nIDEvent==timerMinutes){ | ||
1229 | KillTimer(timerMinutes); | ||
1230 | CDocTemplate* pTemplate = ((CT42App*)AfxGetApp())->m_pTemplate; | ||
1231 | POSITION p = pTemplate->GetFirstDocPosition(); | ||
1232 | while(p){ | ||
1233 | T42Document* pDoc = (T42Document*)pTemplate->GetNextDoc(p); | ||
1234 | pDoc->OnMinute(); | ||
1235 | } | ||
1236 | SetTimer(timerMinutes,60000,NULL); | ||
1237 | } | ||
1238 | |||
1239 | CDialog::OnTimer(nIDEvent); | ||
1240 | } | ||
1241 | |||
1242 | BOOL CT42Dlg::OnQueryEndSession() | ||
1243 | { | ||
1244 | if (!CDialog::OnQueryEndSession()) | ||
1245 | return FALSE; | ||
1246 | |||
1247 | CT42App* app = (CT42App*)AfxGetApp(); | ||
1248 | app->SaveSettings(); | ||
1249 | |||
1250 | return TRUE; | ||
1251 | } | ||
diff --git a/T42Dlg.h b/T42Dlg.h new file mode 100644 index 0000000..5f0b6d4 --- a/dev/null +++ b/T42Dlg.h | |||
@@ -0,0 +1,159 @@ | |||
1 | // T42Dlg.h : header file | ||
2 | // | ||
3 | |||
4 | ///////////////////////////////////////////////////////////////////////////// | ||
5 | // CT42Dlg dialog | ||
6 | |||
7 | class CTTable : public CObject { | ||
8 | public: | ||
9 | TalkCtlMessagem_RQ; | ||
10 | CTimem_Time; | ||
11 | |||
12 | CTTable() {} | ||
13 | CTTable(CTTable& src) { Copy(src); } | ||
14 | |||
15 | void Copy(CTTable& src) { | ||
16 | memmove(&m_RQ,&src.m_RQ,sizeof(m_RQ)); | ||
17 | m_Time = src.m_Time; | ||
18 | } | ||
19 | |||
20 | CTTable& operator=(CTTable& src) { | ||
21 | Copy(src); | ||
22 | return *this; | ||
23 | } | ||
24 | |||
25 | BOOL operator==(TalkCtlMessage& m) { | ||
26 | return ( | ||
27 | strcmp(m_RQ.m_LName,m.m_LName)==0 | ||
28 | && strcmp(m_RQ.m_RName,m.m_RName)==0 | ||
29 | && m_RQ.m_Type == m.m_Type | ||
30 | && m_RQ.m_PID == m.m_PID | ||
31 | ); | ||
32 | } | ||
33 | |||
34 | BOOL Match(TalkCtlMessage& m) { | ||
35 | return ( | ||
36 | strcmp(m_RQ.m_LName,m.m_RName)==0 | ||
37 | && strcmp(m_RQ.m_RName,m.m_LName)==0 | ||
38 | && m_RQ.m_Type == talkCtlReqLeaveInvite | ||
39 | ); | ||
40 | } | ||
41 | }; | ||
42 | |||
43 | typedefCList<CTTable,CTTable&> CTRestaurant; | ||
44 | |||
45 | class CT42Dlg : public CDialog | ||
46 | { | ||
47 | // Construction | ||
48 | public: | ||
49 | ~CT42Dlg(); | ||
50 | void SaveSettings(); | ||
51 | void LoadSettings(); | ||
52 | UINT GetOnCtl(CComboBox& ctl); | ||
53 | void SetOnCtl(UINT nAction,CComboBox& ctl); | ||
54 | UINT m_onCall; | ||
55 | UINT m_onCallAway; | ||
56 | BOOL m_bAway; | ||
57 | CSize m_sizeMin; | ||
58 | UINT m_gapY; | ||
59 | UINT m_marginY; | ||
60 | UINT m_marginX; | ||
61 | void RecalcLayout(); | ||
62 | void SetTheIcon(HICON hIcon); | ||
63 | UINT m_newCalls; | ||
64 | HICON m_hIconEmpty; | ||
65 | HICON m_hIconFull; | ||
66 | HWND m_hExFW; | ||
67 | int m_iProcessed; | ||
68 | int m_iNew; | ||
69 | CImageList m_Images; | ||
70 | static DWORD CALLBACK ESOUTProc(DWORD dwCookie,LPBYTE pbBuff,LONG cb,LONG FAR *pcb); | ||
71 | void SetColumnWidths(); | ||
72 | void OnDelT42Call(); | ||
73 | void OnAddT42Call(); | ||
74 | enum{ | ||
75 | subitemTime=0, | ||
76 | subitemCaller, subitemCallee, subitemDuration, | ||
77 | subitemTTY | ||
78 | }; | ||
79 | void InitCalls(); | ||
80 | BOOL m_bShown; | ||
81 | BOOL m_bExiting; | ||
82 | void ToggleVisibility(); | ||
83 | BITMAP m_bitmapBack; | ||
84 | CBitmap m_bmpBack; | ||
85 | DWORD m_trackTalkID; | ||
86 | CTimeSpan m_talkLifetime; | ||
87 | CTRestaurant m_talks; | ||
88 | CTRestaurant m_announcements; | ||
89 | SOCKET m_daemonSocket; | ||
90 | CT42Dlg(CWnd* pParent = NULL);// standard constructor | ||
91 | |||
92 | // Dialog Data | ||
93 | //{{AFX_DATA(CT42Dlg) | ||
94 | enum { IDD = IDD_T42_DIALOG }; | ||
95 | CButtonm_ExitCtl; | ||
96 | CButtonm_TeaCtl; | ||
97 | CButtonm_AwayCtl; | ||
98 | CButtonm_HelpCtl; | ||
99 | CButtonm_OptionsCtl; | ||
100 | CComboBoxm_OnCallAwayCtl; | ||
101 | CComboBoxm_OnCallCtl; | ||
102 | CListCtrlm_CallsCtl; | ||
103 | CRichEditCtrl m_PreviewCtl; | ||
104 | //}}AFX_DATA | ||
105 | |||
106 | // ClassWizard generated virtual function overrides | ||
107 | //{{AFX_VIRTUAL(CT42Dlg) | ||
108 | protected: | ||
109 | virtual void DoDataExchange(CDataExchange* pDX);// DDX/DDV support | ||
110 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); | ||
111 | //}}AFX_VIRTUAL | ||
112 | |||
113 | // Implementation | ||
114 | protected: | ||
115 | HICON m_hIcon; | ||
116 | |||
117 | // Generated message map functions | ||
118 | //{{AFX_MSG(CT42Dlg) | ||
119 | virtual BOOL OnInitDialog(); | ||
120 | afx_msg void OnSysCommand(UINT nID, LPARAM lParam); | ||
121 | afx_msg void OnDestroy(); | ||
122 | afx_msg void OnPaint(); | ||
123 | afx_msg HCURSOR OnQueryDragIcon(); | ||
124 | afx_msg void OnTalk(); | ||
125 | afx_msg LRESULT OnDaemon(WPARAM,LPARAM); | ||
126 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); | ||
127 | afx_msg LRESULT OnTrayIcon(WPARAM,LPARAM); | ||
128 | virtual void OnCancel(); | ||
129 | afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos); | ||
130 | virtual void OnOK(); | ||
131 | afx_msg void OnTrayExit(); | ||
132 | afx_msg void OnTrayOptions(); | ||
133 | afx_msg void OnTrayShowmainwindow(); | ||
134 | afx_msg void OnTrayT42(); | ||
135 | afx_msg void OnOptions(); | ||
136 | afx_msg void OnGetdispinfoCalls(NMHDR* pNMHDR, LRESULT* pResult); | ||
137 | afx_msg void OnItemchangedCalls(NMHDR* pNMHDR, LRESULT* pResult); | ||
138 | afx_msg void OnRclickCalls(NMHDR* pNMHDR, LRESULT* pResult); | ||
139 | afx_msg void OnCalllogCallback(); | ||
140 | afx_msg void OnCalllogDelete(); | ||
141 | afx_msg void OnCalllogSavetofile(); | ||
142 | afx_msg void OnCalllogEmptylog(); | ||
143 | afx_msg void OnDeleteitemCalls(NMHDR* pNMHDR, LRESULT* pResult); | ||
144 | afx_msg LRESULT OnUpdatePreview(WPARAM,LPARAM); | ||
145 | afx_msg void OnKeydownCalls(NMHDR* pNMHDR, LRESULT* pResult); | ||
146 | afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); | ||
147 | afx_msg void OnCalllogMarkasnew(); | ||
148 | afx_msg void OnCalllogMarkasprocessed(); | ||
149 | afx_msg void OnSize(UINT nType, int cx, int cy); | ||
150 | afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI); | ||
151 | afx_msg void OnAway(); | ||
152 | afx_msg void OnSelendokOncall(); | ||
153 | afx_msg void OnSelendokOncallaway(); | ||
154 | afx_msg void OnTrayAway(); | ||
155 | afx_msg void OnTimer(UINT nIDEvent); | ||
156 | afx_msg BOOL OnQueryEndSession(); | ||
157 | //}}AFX_MSG | ||
158 | DECLARE_MESSAGE_MAP() | ||
159 | }; | ||
diff --git a/T42Document.cpp b/T42Document.cpp new file mode 100644 index 0000000..3eeb427 --- a/dev/null +++ b/T42Document.cpp | |||
@@ -0,0 +1,181 @@ | |||
1 | // T42Document.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "T42Document.h" | ||
7 | |||
8 | #include "T42View.h" | ||
9 | #include "T42Frame.h" | ||
10 | |||
11 | #ifdef _DEBUG | ||
12 | #define new DEBUG_NEW | ||
13 | #undef THIS_FILE | ||
14 | static char THIS_FILE[] = __FILE__; | ||
15 | #endif | ||
16 | |||
17 | ///////////////////////////////////////////////////////////////////////////// | ||
18 | // T42Document | ||
19 | |||
20 | IMPLEMENT_DYNCREATE(T42Document, CDocument) | ||
21 | |||
22 | T42Document::T42Document() | ||
23 | { | ||
24 | m_pView=NULL; | ||
25 | m_pRobot = NULL; | ||
26 | m_bHidden = FALSE; | ||
27 | } | ||
28 | |||
29 | BOOL T42Document::OnNewDocument() | ||
30 | { | ||
31 | if (!CDocument::OnNewDocument()) | ||
32 | return FALSE; | ||
33 | return TRUE; | ||
34 | } | ||
35 | |||
36 | T42Document::~T42Document() | ||
37 | { | ||
38 | if(m_pRobot) | ||
39 | DetachRobot(); | ||
40 | } | ||
41 | |||
42 | |||
43 | BEGIN_MESSAGE_MAP(T42Document, CDocument) | ||
44 | //{{AFX_MSG_MAP(T42Document) | ||
45 | ON_COMMAND(ID_WINDOW_SAVELAYOUT, OnWindowSavelayout) | ||
46 | ON_UPDATE_COMMAND_UI(ID_WINDOW_AUTOSAVELAYOUT, OnUpdateWindowAutosavelayout) | ||
47 | ON_COMMAND(ID_WINDOW_AUTOSAVELAYOUT, OnWindowAutosavelayout) | ||
48 | //}}AFX_MSG_MAP | ||
49 | END_MESSAGE_MAP() | ||
50 | |||
51 | ///////////////////////////////////////////////////////////////////////////// | ||
52 | // T42Document diagnostics | ||
53 | |||
54 | #ifdef _DEBUG | ||
55 | void T42Document::AssertValid() const | ||
56 | { | ||
57 | CDocument::AssertValid(); | ||
58 | } | ||
59 | |||
60 | void T42Document::Dump(CDumpContext& dc) const | ||
61 | { | ||
62 | CDocument::Dump(dc); | ||
63 | } | ||
64 | #endif //_DEBUG | ||
65 | |||
66 | ///////////////////////////////////////////////////////////////////////////// | ||
67 | // T42Document serialization | ||
68 | |||
69 | void T42Document::Serialize(CArchive& ar) | ||
70 | { | ||
71 | if (ar.IsStoring()) | ||
72 | { | ||
73 | } | ||
74 | else | ||
75 | { | ||
76 | } | ||
77 | } | ||
78 | |||
79 | ///////////////////////////////////////////////////////////////////////////// | ||
80 | // T42Document commands | ||
81 | |||
82 | void T42Document::Talk(LPCTSTR from,LPCTSTR to,LPCTSTR tty,BOOL bPrompt) | ||
83 | { | ||
84 | ASSERT(m_pView); | ||
85 | ASSERT(m_pView->m_pFrame); | ||
86 | m_pView->m_pFrame->m_Target = to?to:""; | ||
87 | m_pView->m_pFrame->m_LocalUser = from?from:""; | ||
88 | m_pView->m_pFrame->m_TargetTTY = tty?tty:""; | ||
89 | if(bPrompt || !(to && from)) | ||
90 | m_pView->m_pFrame->PostMessage(WM_COMMAND,MAKELONG(ID_TALK_REMOTEUSER,0),NULL); | ||
91 | else | ||
92 | m_pView->m_pFrame->PostMessage(WM_INITIATETALK); | ||
93 | } | ||
94 | |||
95 | void T42Document::OnChangedViewList() | ||
96 | { | ||
97 | CDocument::OnChangedViewList(); | ||
98 | POSITION p = GetFirstViewPosition(); | ||
99 | m_pView=NULL; | ||
100 | while(p){ | ||
101 | CView* pView = GetNextView(p); | ||
102 | ASSERT_KINDOF(T42View,pView); | ||
103 | ASSERT(!m_pView); | ||
104 | m_pView=(T42View*)pView; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | void T42Document::SaveLayout() | ||
109 | { | ||
110 | ASSERT(m_pView); | ||
111 | m_pView->SaveLayout(); | ||
112 | ASSERT(m_pView->m_pFrame); | ||
113 | m_pView->m_pFrame->SaveLayout(); | ||
114 | } | ||
115 | |||
116 | void T42Document::OnWindowSavelayout() | ||
117 | { | ||
118 | SaveLayout(); | ||
119 | } | ||
120 | |||
121 | void T42Document::OnUpdateWindowAutosavelayout(CCmdUI* pCmdUI) | ||
122 | { | ||
123 | CT42App* app = (CT42App*)AfxGetApp(); | ||
124 | pCmdUI->SetCheck(app->m_bt42AutosaveLayout?1:0); | ||
125 | } | ||
126 | |||
127 | void T42Document::OnWindowAutosavelayout() | ||
128 | { | ||
129 | CT42App* app = (CT42App*)AfxGetApp(); | ||
130 | app->m_bt42AutosaveLayout=!app->m_bt42AutosaveLayout; | ||
131 | } | ||
132 | |||
133 | void T42Document::AutosaveLayout() | ||
134 | { | ||
135 | CT42App* app = (CT42App*)AfxGetApp(); | ||
136 | if(app->m_bt42AutosaveLayout) | ||
137 | SaveLayout(); | ||
138 | } | ||
139 | |||
140 | BOOL T42Document::AttachRobot(CT42Robot* pRobot) | ||
141 | { | ||
142 | if(m_pRobot) | ||
143 | DetachRobot(); | ||
144 | m_pRobot = pRobot; | ||
145 | return m_pRobot->OnAttach(this); | ||
146 | } | ||
147 | |||
148 | BOOL T42Document::DetachRobot() | ||
149 | { | ||
150 | ASSERT(m_pRobot); | ||
151 | BOOL rv = m_pRobot->OnDetach(); | ||
152 | m_pRobot=NULL; | ||
153 | return rv; | ||
154 | } | ||
155 | |||
156 | BOOL T42Document::SendOver(LPCTSTR str) | ||
157 | { | ||
158 | // *** Or call T42View function? | ||
159 | for(LPCTSTR ptr=str;*ptr;ptr++){ | ||
160 | m_pView->m_localCtl.PutCharacter(*ptr); | ||
161 | m_pView->m_pFrame->PostMessage(WM_TALKCHAR,0xFF&((WORD)*ptr)); | ||
162 | } | ||
163 | return TRUE; | ||
164 | } | ||
165 | |||
166 | BOOL T42Document::OnOpenDocument(LPCTSTR lpszPathName) | ||
167 | { | ||
168 | //if (!CDocument::OnOpenDocument(lpszPathName)) | ||
169 | // return FALSE; | ||
170 | |||
171 | if(lpszPathName) | ||
172 | m_bHidden = TRUE; | ||
173 | |||
174 | return TRUE; | ||
175 | } | ||
176 | |||
177 | void T42Document::OnMinute() | ||
178 | { | ||
179 | if(m_pRobot) | ||
180 | m_pRobot->OnMinute(); | ||
181 | } | ||
diff --git a/T42Document.h b/T42Document.h new file mode 100644 index 0000000..fd59368 --- a/dev/null +++ b/T42Document.h | |||
@@ -0,0 +1,81 @@ | |||
1 | // T42Document.h : header file | ||
2 | // | ||
3 | |||
4 | ///////////////////////////////////////////////////////////////////////////// | ||
5 | // T42Document document | ||
6 | |||
7 | class T42Document; | ||
8 | class T42View; | ||
9 | |||
10 | class CT42Robot{ | ||
11 | public: | ||
12 | T42Document* m_pDocument; | ||
13 | |||
14 | CT42Robot() : m_pDocument(NULL){} | ||
15 | virtual ~CT42Robot() {} | ||
16 | |||
17 | virtual BOOL OnAttach(T42Document* pDocument) { | ||
18 | m_pDocument = pDocument; | ||
19 | return TRUE; | ||
20 | } | ||
21 | virtual BOOL OnDetach() { return TRUE; } | ||
22 | |||
23 | virtual BOOL OnConnect() { return TRUE; } | ||
24 | virtual BOOL OnReceive(char*,int){ return TRUE; } | ||
25 | virtual BOOL OnDisconnect() { return TRUE; } | ||
26 | |||
27 | virtual BOOL OnIPResolved() { return TRUE; } | ||
28 | |||
29 | virtual BOOL OnMinute() { return TRUE; } | ||
30 | }; | ||
31 | |||
32 | class T42Document : public CDocument | ||
33 | { | ||
34 | protected: | ||
35 | T42Document(); // protected constructor used by dynamic creation | ||
36 | DECLARE_DYNCREATE(T42Document) | ||
37 | |||
38 | // Attributes | ||
39 | public: | ||
40 | void OnMinute(); | ||
41 | BOOL m_bHidden; | ||
42 | BOOL SendOver(LPCTSTR str); | ||
43 | BOOL DetachRobot(); | ||
44 | BOOL AttachRobot(CT42Robot* pRobot); | ||
45 | CT42Robot* m_pRobot; | ||
46 | void AutosaveLayout(); | ||
47 | void SaveLayout(); | ||
48 | T42View* m_pView; | ||
49 | void Talk(LPCTSTR from=NULL,LPCTSTR to=NULL,LPCTSTR tty=NULL,BOOL bPrompt=FALSE); | ||
50 | |||
51 | // Operations | ||
52 | public: | ||
53 | |||
54 | // Overrides | ||
55 | // ClassWizard generated virtual function overrides | ||
56 | //{{AFX_VIRTUAL(T42Document) | ||
57 | public: | ||
58 | virtual void Serialize(CArchive& ar); // overridden for document i/o | ||
59 | virtual void OnChangedViewList(); | ||
60 | virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); | ||
61 | protected: | ||
62 | virtual BOOL OnNewDocument(); | ||
63 | //}}AFX_VIRTUAL | ||
64 | |||
65 | // Implementation | ||
66 | public: | ||
67 | virtual ~T42Document(); | ||
68 | #ifdef _DEBUG | ||
69 | virtual void AssertValid() const; | ||
70 | virtual void Dump(CDumpContext& dc) const; | ||
71 | #endif | ||
72 | |||
73 | // Generated message map functions | ||
74 | protected: | ||
75 | //{{AFX_MSG(T42Document) | ||
76 | afx_msg void OnWindowSavelayout(); | ||
77 | afx_msg void OnUpdateWindowAutosavelayout(CCmdUI* pCmdUI); | ||
78 | afx_msg void OnWindowAutosavelayout(); | ||
79 | //}}AFX_MSG | ||
80 | DECLARE_MESSAGE_MAP() | ||
81 | }; | ||
diff --git a/T42Frame.cpp b/T42Frame.cpp new file mode 100644 index 0000000..96bc522 --- a/dev/null +++ b/T42Frame.cpp | |||
@@ -0,0 +1,1212 @@ | |||
1 | // T42Frame.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "T42Frame.h" | ||
7 | |||
8 | #include "T42View.h" | ||
9 | #include "CalleeDlg.h" | ||
10 | #include "shared-code/RegEx.h" | ||
11 | #include "T42Document.h" | ||
12 | |||
13 | #include <snmp.h> | ||
14 | |||
15 | #ifdef _DEBUG | ||
16 | #define new DEBUG_NEW | ||
17 | #undef THIS_FILE | ||
18 | static char THIS_FILE[] = __FILE__; | ||
19 | #endif | ||
20 | |||
21 | ///////////////////////////////////////////////////////////////////////////// | ||
22 | // T42Frame | ||
23 | |||
24 | IMPLEMENT_DYNCREATE(T42Frame, CFrameWnd) | ||
25 | |||
26 | T42Frame::T42Frame() | ||
27 | { | ||
28 | VERIFY(m_hNormal=AfxGetApp()->LoadIcon(IDR_T42FRAME)); | ||
29 | VERIFY(m_hFullCup=AfxGetApp()->LoadIcon(IDR_FULLT42)); | ||
30 | |||
31 | m_bTrayMinimize = TRUE; | ||
32 | m_bSleepMinimize = TRUE; | ||
33 | m_bMinimizeSleep = TRUE; | ||
34 | m_onWake = wakeSound|wakePopup; | ||
35 | LoadLayout(); | ||
36 | |||
37 | m_bHaveFocus = FALSE; | ||
38 | m_bTrayed = FALSE; | ||
39 | m_bSleep = FALSE; | ||
40 | |||
41 | m_asyncHandle = NULL; | ||
42 | m_resolveHandle = NULL; | ||
43 | m_ctlSocket = INVALID_SOCKET; | ||
44 | m_Socket = INVALID_SOCKET; | ||
45 | m_localEC.m_cErase = 0177; | ||
46 | m_localEC.m_kill = 025; // ^U | ||
47 | m_localEC.m_wErase = 027;// ^W | ||
48 | m_bEstablished = FALSE; | ||
49 | |||
50 | CleanUp(); | ||
51 | } | ||
52 | |||
53 | T42Frame::~T42Frame() | ||
54 | { | ||
55 | } | ||
56 | |||
57 | BEGIN_MESSAGE_MAP(T42Frame, CFrameWnd) | ||
58 | //{{AFX_MSG_MAP(T42Frame) | ||
59 | ON_WM_CLOSE() | ||
60 | ON_COMMAND(ID_TALK_REMOTEUSER, OnTalkRemoteuser) | ||
61 | ON_MESSAGE(WM_INITIATETALK, OnInitiateTalk) | ||
62 | ON_MESSAGE(WM_TARGETRESOLVED, OnTargetResolved) | ||
63 | ON_MESSAGE(WM_SOURCERESOLVED, OnSourceResolved) | ||
64 | ON_WM_TIMER() | ||
65 | ON_MESSAGE(WM_CTLTRANSACT, OnCTLTransact) | ||
66 | ON_MESSAGE(WM_LOOKUP_SUCCESS, OnLookupSuccess) | ||
67 | ON_MESSAGE(WM_LOOKUP_FAILURE, OnLookupFailure) | ||
68 | ON_MESSAGE(WM_ANNOUNCE_SUCCESS, OnAnnounceSuccess) | ||
69 | ON_MESSAGE(WM_ANNOUNCE_FAILURE, OnAnnounceFailure) | ||
70 | ON_MESSAGE(WM_LEAVEINVITE_SUCCESS, OnLeaveInviteSuccess) | ||
71 | ON_MESSAGE(WM_LEAVEINVITE_FAILURE, OnLeaveInviteFailure) | ||
72 | ON_MESSAGE(WM_TALKACCEPT, OnTalkAccept) | ||
73 | ON_MESSAGE(WM_LOCAL_REMOVE_SUCCESS, OnLocalRemoveSuccess) | ||
74 | ON_MESSAGE(WM_LOCAL_REMOVE_FAILURE, OnLocalRemoveFailure) | ||
75 | ON_MESSAGE(WM_REMOTE_REMOVE_SUCCESS, OnRemoteRemoveSuccess) | ||
76 | ON_MESSAGE(WM_REMOTE_REMOVE_FAILURE, OnRemoteRemoveFailure) | ||
77 | ON_MESSAGE(WM_TALK, OnTalk) | ||
78 | ON_MESSAGE(WM_TALKCHAR, OnTalkChar) | ||
79 | ON_MESSAGE(WM_TALKCONNECT, OnTalkConnect) | ||
80 | ON_WM_CREATE() | ||
81 | ON_UPDATE_COMMAND_UI(ID_INDICATOR_DATE, OnUpdateDate) | ||
82 | ON_MESSAGE(WM_EXITMENULOOP, OnExitMenuLoop) | ||
83 | ON_WM_DESTROY() | ||
84 | ON_WM_SYSCOMMAND() | ||
85 | ON_MESSAGE(WM_NAMERESOLVED, OnNameResolved) | ||
86 | ON_MESSAGE(WM_IPRESOLVED, OnIPResolved) | ||
87 | ON_WM_ACTIVATE() | ||
88 | ON_MESSAGE(WM_TRAYICON, OnTrayIcon) | ||
89 | ON_UPDATE_COMMAND_UI(ID_WINDOW_HIDEINTRAYONMINIMIZE, OnUpdateWindowHideintrayonminimize) | ||
90 | ON_COMMAND(ID_WINDOW_HIDEINTRAYONMINIMIZE, OnWindowHideintrayonminimize) | ||
91 | ON_COMMAND(ID_TALK_ABORT, OnTalkAbort) | ||
92 | ON_UPDATE_COMMAND_UI(ID_TALK_ABORT, OnUpdateTalkAbort) | ||
93 | ON_COMMAND(ID_TALK_RECONNECT, OnTalkReconnect) | ||
94 | ON_UPDATE_COMMAND_UI(ID_TALK_RECONNECT, OnUpdateTalkReconnect) | ||
95 | ON_UPDATE_COMMAND_UI(ID_TALK_REMOTEUSER, OnUpdateTalkRemoteuser) | ||
96 | ON_UPDATE_COMMAND_UI(ID_SLEEP_SLEEP, OnUpdateSleepSleep) | ||
97 | ON_COMMAND(ID_SLEEP_SLEEP, OnSleepSleep) | ||
98 | ON_UPDATE_COMMAND_UI(ID_SLEEP_SLEEPONMINIMIZE, OnUpdateSleepSleeponminimize) | ||
99 | ON_COMMAND(ID_SLEEP_SLEEPONMINIMIZE, OnSleepSleeponminimize) | ||
100 | ON_UPDATE_COMMAND_UI(ID_SLEEP_WAKEUPACTION_MAKESOUND, OnUpdateSleepWakeupactionMakesound) | ||
101 | ON_COMMAND(ID_SLEEP_WAKEUPACTION_MAKESOUND, OnSleepWakeupactionMakesound) | ||
102 | ON_UPDATE_COMMAND_UI(ID_SLEEP_WAKEUPACTION_POPUP, OnUpdateSleepWakeupactionPopup) | ||
103 | ON_COMMAND(ID_SLEEP_WAKEUPACTION_POPUP, OnSleepWakeupactionPopup) | ||
104 | ON_UPDATE_COMMAND_UI(ID_SLEEP_MINIMIZEONSLEEP, OnUpdateSleepMinimizeonsleep) | ||
105 | ON_COMMAND(ID_SLEEP_MINIMIZEONSLEEP, OnSleepMinimizeonsleep) | ||
106 | ON_COMMAND(ID_TALK_CLOSE, OnTalkClose) | ||
107 | //}}AFX_MSG_MAP | ||
108 | END_MESSAGE_MAP() | ||
109 | |||
110 | ///////////////////////////////////////////////////////////////////////////// | ||
111 | // T42Frame message handlers | ||
112 | |||
113 | void T42Frame::OnClose() | ||
114 | { | ||
115 | if(GetKeyState(VK_SHIFT)&0x8000){ | ||
116 | T42Document* pDoc = (T42Document*)GetActiveDocument(); | ||
117 | ASSERT_KINDOF(T42Document,pDoc); | ||
118 | pDoc->AutosaveLayout(); | ||
119 | } | ||
120 | CFrameWnd::OnClose(); | ||
121 | } | ||
122 | |||
123 | BOOL T42Frame::PreCreateWindow(CREATESTRUCT& cs) | ||
124 | { | ||
125 | CWinApp* app = AfxGetApp(); | ||
126 | ASSERT(app); | ||
127 | cs.x = app->GetProfileInt("T42Window","X",cs.x); | ||
128 | cs.y = app->GetProfileInt("T42Window","Y",cs.y); | ||
129 | cs.cx = app->GetProfileInt("T42Window","Width",cs.cx); | ||
130 | cs.cy = app->GetProfileInt("T42Window","Height",cs.cy); | ||
131 | |||
132 | BOOL rv = CFrameWnd::PreCreateWindow(cs); | ||
133 | |||
134 | //cs.style&=~FWS_PREFIXTITLE; | ||
135 | //cs.style|=FWS_ADDTOTITLE; | ||
136 | |||
137 | return rv; | ||
138 | } | ||
139 | |||
140 | void T42Frame::OnTalkRemoteuser() | ||
141 | { | ||
142 | CCalleeDlg callee(this); | ||
143 | callee.m_Callee = m_Target; | ||
144 | callee.m_Caller = m_LocalUser; | ||
145 | callee.m_TTY = m_TargetTTY; | ||
146 | if(callee.DoModal() == IDOK){ | ||
147 | m_Target = callee.m_Callee; | ||
148 | m_LocalUser = callee.m_Caller; | ||
149 | m_TargetTTY = callee.m_TTY; | ||
150 | PostMessage(WM_INITIATETALK); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | LRESULT T42Frame::OnInitiateTalk(WPARAM,LPARAM) | ||
155 | { | ||
156 | if( | ||
157 | (!((T42Document*)GetActiveDocument())->m_bHidden) | ||
158 | && !m_bTrayed | ||
159 | ) | ||
160 | SetForegroundWindow(); | ||
161 | CRegEx atRE, bangRE; | ||
162 | VERIFY(atRE.Compile("([-À-ßà-ÿ[:alnum:]_.]+)@([-[:alnum:].]+)",CRegEx::regExtended));// u, h | ||
163 | VERIFY(bangRE.Compile("([-[:alnum:].]+)[!:]([-À-ßà-ÿ[:alnum:]._]+)",CRegEx::regExtended));// h, u | ||
164 | if(atRE.Match(m_Target,CRegEx::regExtended)){ | ||
165 | m_TargetUser = atRE.GetMatch(1); | ||
166 | m_TargetHost = atRE.GetMatch(2); | ||
167 | }else if(bangRE.Match(m_Target,CRegEx::regExtended)){ | ||
168 | m_TargetUser = bangRE.GetMatch(2); | ||
169 | m_TargetHost = bangRE.GetMatch(1); | ||
170 | }else{ | ||
171 | ShowMessage(IDS_ERR_MALFORMEDREMOTE,MB_ICONSTOP|MB_OK); | ||
172 | return -1; | ||
173 | } | ||
174 | SetPeerName(); | ||
175 | memset(&m_TargetAddr,0,sizeof(m_TargetAddr)); | ||
176 | m_TargetAddr.sin_addr.s_addr = inet_addr(m_TargetHost); | ||
177 | if(m_TargetAddr.sin_addr.s_addr == INADDR_NONE){ | ||
178 | StatusLine(IDS_STATUS_RESOLVING); | ||
179 | m_asyncHandle = WSAAsyncGetHostByName( | ||
180 | m_hWnd,WM_TARGETRESOLVED, | ||
181 | (LPCTSTR)m_TargetHost, | ||
182 | (char*)m_gethostData,sizeof(m_gethostData) | ||
183 | ); | ||
184 | if(!m_asyncHandle){ | ||
185 | WSSystemMessage(IDS_ERR_REMOTERESOLVEFAILED,WSAGetLastError()); | ||
186 | return -1; | ||
187 | } | ||
188 | // Here we're trying to establish connection using hostname (as opposed | ||
189 | // to ip address) - no further investigation needed. | ||
190 | AddToHotList(); | ||
191 | }else{ | ||
192 | if(!Klever::FindIFace(m_TargetAddr.sin_addr,m_SourceAddr.sin_addr)) | ||
193 | m_SourceAddr.sin_addr.s_addr = INADDR_ANY; | ||
194 | PostMessage(WM_SOURCERESOLVED); | ||
195 | // Try to resolve hostname if it resolves back to the same IP - this | ||
196 | // is the canonical name we need. If not - leave it as IP. | ||
197 | m_resolveHandle = WSAAsyncGetHostByAddr( | ||
198 | m_hWnd,WM_NAMERESOLVED, | ||
199 | (char*)&m_TargetAddr.sin_addr,sizeof(m_TargetAddr.sin_addr),AF_INET, | ||
200 | (char*)m_ghResolve,sizeof(m_ghResolve) | ||
201 | ); | ||
202 | if(!m_resolveHandle){ | ||
203 | // We've failed to resolve hostname - leave IP - do nothing. | ||
204 | TRACE0("Failed to initiate IP resolve\n"); | ||
205 | AddToHotList(); | ||
206 | } | ||
207 | } | ||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | LRESULT T42Frame::OnNameResolved(WPARAM,LPARAM lP) | ||
212 | { | ||
213 | m_resolveHandle=NULL; | ||
214 | if(WSAGETASYNCERROR(lP)){ | ||
215 | // We've failed to resolve hostname - leave IP - do nothing. | ||
216 | TRACE0("Failed to resolve name by ip\n"); | ||
217 | AddToHotList(); | ||
218 | }else{ | ||
219 | hostent* he = (hostent*)m_ghResolve; | ||
220 | m_nameFromIP = he->h_name; | ||
221 | m_resolveHandle = WSAAsyncGetHostByName( | ||
222 | m_hWnd,WM_IPRESOLVED, | ||
223 | (LPCTSTR)m_nameFromIP, | ||
224 | (char*)m_ghResolve,sizeof(m_ghResolve) | ||
225 | ); | ||
226 | if(!m_resolveHandle){ | ||
227 | // We've failed to resolve hostname - leave IP - do nothing. | ||
228 | TRACE0("Failed to initiate name resolve\n"); | ||
229 | AddToHotList(); | ||
230 | } | ||
231 | } | ||
232 | return 0; | ||
233 | } | ||
234 | |||
235 | LRESULT T42Frame::OnIPResolved(WPARAM,LPARAM lP) | ||
236 | { | ||
237 | m_resolveHandle=NULL; | ||
238 | if(WSAGETASYNCERROR(lP)){ | ||
239 | // We've failed to resolve hostname - leave IP - do nothing. | ||
240 | TRACE0("Failed to resolve name by ip\n"); | ||
241 | AddToHotList(); | ||
242 | }else{ | ||
243 | hostent* he = (hostent*)m_ghResolve; | ||
244 | if( | ||
245 | he->h_length!=sizeof(m_TargetAddr.sin_addr) | ||
246 | || he->h_addrtype!=m_TargetAddr.sin_family | ||
247 | || memcmp(*he->h_addr_list,&m_TargetAddr.sin_addr,he->h_length) | ||
248 | ){ | ||
249 | // The host resolved to different IP address.. | ||
250 | // maybe we should warn user about it? | ||
251 | TRACE0("IP/NAME investigations sucked in result\n"); | ||
252 | AddToHotList(); | ||
253 | }else{ | ||
254 | // We got new hostname!! Hurray! What do we do? | ||
255 | // Yes, we set new Target.. | ||
256 | m_TargetHost = m_nameFromIP; | ||
257 | m_Target = m_TargetUser + '@' + m_TargetHost; | ||
258 | SetPeerName(); | ||
259 | AddToHotList(); | ||
260 | T42Document* pDoc = (T42Document*)GetActiveDocument(); | ||
261 | ASSERT_KINDOF(T42Document,pDoc); | ||
262 | if(pDoc->m_pRobot) | ||
263 | pDoc->m_pRobot->OnIPResolved(); | ||
264 | TRACE0("IP/NAME investigations succeeded\n"); | ||
265 | } | ||
266 | } | ||
267 | return 0; | ||
268 | } | ||
269 | |||
270 | LRESULT T42Frame::OnTargetResolved(WPARAM,LPARAM lP) | ||
271 | { | ||
272 | m_asyncHandle=NULL; | ||
273 | if(WSAGETASYNCERROR(lP)){ | ||
274 | WSSystemMessage(IDS_ERR_REMOTERESOLVEFAILED,WSAGetLastError()); | ||
275 | return 0; | ||
276 | } | ||
277 | ASSERT(((hostent*)m_gethostData)->h_length==4); | ||
278 | memmove(&m_TargetAddr.sin_addr,*((hostent*)m_gethostData)->h_addr_list,sizeof(m_TargetAddr.sin_addr)); | ||
279 | if(!Klever::FindIFace(m_TargetAddr.sin_addr,m_SourceAddr.sin_addr)) | ||
280 | m_SourceAddr.sin_addr.s_addr = INADDR_ANY; | ||
281 | PostMessage(WM_SOURCERESOLVED); | ||
282 | return 0; | ||
283 | } | ||
284 | |||
285 | LRESULT T42Frame::OnSourceResolved(WPARAM,LPARAM) | ||
286 | { | ||
287 | // Open ctl socket | ||
288 | m_SourceAddr.sin_port = 0; | ||
289 | m_SourceAddr.sin_family = AF_INET; | ||
290 | m_ctlSocket = socket(AF_INET,SOCK_DGRAM,0); | ||
291 | if(m_ctlSocket==INVALID_SOCKET){ | ||
292 | WSSystemMessage(IDS_ERR_CTLCREATEFAILED,WSAGetLastError()); | ||
293 | return -1; | ||
294 | } | ||
295 | if(bind(m_ctlSocket,(sockaddr*)&m_SourceAddr,sizeof(m_SourceAddr))){ | ||
296 | WSSystemMessage(IDS_ERR_CTLBINDFAILED,WSAGetLastError()); | ||
297 | return -1; | ||
298 | } | ||
299 | int length = sizeof(m_ctlAddr); | ||
300 | if(getsockname(m_ctlSocket,(sockaddr*)&m_ctlAddr,&length)){ | ||
301 | WSSystemMessage(IDS_ERR_CTLGETFAILED,WSAGetLastError()); | ||
302 | return -1; | ||
303 | } | ||
304 | // Open socket for connection | ||
305 | m_SourceAddr.sin_port = 0; | ||
306 | m_SourceAddr.sin_family = AF_INET; | ||
307 | m_Socket = socket(AF_INET,SOCK_STREAM,0); | ||
308 | if(m_Socket==INVALID_SOCKET){ | ||
309 | WSSystemMessage(IDS_ERR_TCPCREATEFAILED,WSAGetLastError()); | ||
310 | return -1; | ||
311 | } | ||
312 | if(bind(m_Socket,(sockaddr*)&m_SourceAddr,sizeof(m_SourceAddr))){ | ||
313 | WSSystemMessage(IDS_ERR_TCPBINDFAILED,WSAGetLastError()); | ||
314 | return -1; | ||
315 | } | ||
316 | length = sizeof(m_SourceAddr); | ||
317 | if(getsockname(m_Socket,(sockaddr*)&m_SourceAddr,&length)){ | ||
318 | WSSystemMessage(IDS_ERR_TCPGETFAILED,WSAGetLastError()); | ||
319 | return -1; | ||
320 | } | ||
321 | StatusLine(IDS_STATUS_LOOKUPINVITE); | ||
322 | TalkCtlMessage rq; | ||
323 | FillInMessage(rq); | ||
324 | rq.m_Type = talkCtlReqLookUp; | ||
325 | m_TargetAddr.sin_family = AF_INET; | ||
326 | CT42App* app = (CT42App*)AfxGetApp(); | ||
327 | m_TargetAddr.sin_port = htons(app->m_T42TalkPort); | ||
328 | VERIFY(AsyncCtlTransact(rq,m_TargetAddr,WM_LOOKUP_SUCCESS,WM_LOOKUP_FAILURE)); | ||
329 | return 0; | ||
330 | } | ||
331 | |||
332 | BOOL T42Frame::FillInMessage(TalkCtlMessage& msg) | ||
333 | { | ||
334 | memset(&msg,0,sizeof(msg)); | ||
335 | msg.m_Version = talkCtlVersion; | ||
336 | msg.m_Addr = m_SourceAddr; | ||
337 | msg.m_ctlAddr = m_ctlAddr; | ||
338 | msg.m_ID = htonl(0); | ||
339 | msg.m_PID = htonl((LONG)m_hWnd); | ||
340 | ASSERT(m_LocalUser.GetLength()>0 && m_LocalUser.GetLength()<sizeof(msg.m_LName)); | ||
341 | strcpy(msg.m_LName,m_LocalUser); | ||
342 | ASSERT(m_TargetUser.GetLength()>0 && m_TargetUser.GetLength()<sizeof(msg.m_RName)); | ||
343 | strcpy(msg.m_RName,m_TargetUser); | ||
344 | ASSERT(m_TargetTTY.GetLength()>=0 && m_TargetTTY.GetLength()<sizeof(msg.m_RTTY)); | ||
345 | strcpy(msg.m_RTTY,m_TargetTTY); | ||
346 | return TRUE; | ||
347 | } | ||
348 | |||
349 | BOOL T42Frame::AsyncCtlTransact(TalkCtlMessage& msg,sockaddr_in& target, UINT wmSuccess,UINT wmFailure) | ||
350 | { | ||
351 | if(m_ctlSuccess || m_ctlFailure) | ||
352 | return FALSE; | ||
353 | memmove(&m_ctlTarget,&target,sizeof(m_ctlTarget)); | ||
354 | memmove(&m_ctlRequest,&msg,sizeof(m_ctlRequest)); | ||
355 | m_ctlSuccess = wmSuccess; | ||
356 | m_ctlFailure = wmFailure; | ||
357 | TRACE2("Initiating CTL Transaction to %s:%d\n", | ||
358 | inet_ntoa(m_ctlTarget.sin_addr),ntohs(m_ctlTarget.sin_port) | ||
359 | ); | ||
360 | TRACE3("V: %d, T: %d, ID: %ld\n", | ||
361 | (int)m_ctlRequest.m_Version, (int)m_ctlRequest.m_Type, | ||
362 | ntohl(m_ctlRequest.m_ID) | ||
363 | ); | ||
364 | TRACE("ADDR: %s:%d\n", | ||
365 | inet_ntoa(((sockaddr_in*)&m_ctlRequest.m_Addr)->sin_addr), | ||
366 | ntohs(((sockaddr_in*)&m_ctlRequest.m_Addr)->sin_port) | ||
367 | ); | ||
368 | TRACE("CTL ADDR: %s:%d\n", | ||
369 | inet_ntoa(((sockaddr_in*)&m_ctlRequest.m_ctlAddr)->sin_addr), | ||
370 | ntohs(((sockaddr_in*)&m_ctlRequest.m_ctlAddr)->sin_port) | ||
371 | ); | ||
372 | if(sendto(m_ctlSocket,(char*)&m_ctlRequest,sizeof(m_ctlRequest),0, | ||
373 | (sockaddr*)&m_ctlTarget,sizeof(m_ctlTarget))!=sizeof(m_ctlRequest) | ||
374 | ){ | ||
375 | AsyncCtlTransactFailed(ctlFailSendto,WSAGetLastError()); | ||
376 | return TRUE; | ||
377 | } | ||
378 | if(WSAAsyncSelect(m_ctlSocket,m_hWnd,WM_CTLTRANSACT,FD_READ)){ | ||
379 | AsyncCtlTransactFailed(ctlFailSelect,WSAGetLastError()); | ||
380 | return TRUE; | ||
381 | } | ||
382 | SetTimer(timerTransact,2000,NULL); | ||
383 | return TRUE; | ||
384 | } | ||
385 | |||
386 | LRESULT T42Frame::OnCTLTransact(WPARAM,LPARAM lP) | ||
387 | { | ||
388 | KillTimer(timerTransact); | ||
389 | if(!(m_ctlSuccess && m_ctlFailure)) | ||
390 | return -1; | ||
391 | if(WSAGETSELECTERROR(lP)){ | ||
392 | AsyncCtlTransactFailed(ctlFailError,WSAGETSELECTERROR(lP)); | ||
393 | return -1; | ||
394 | } | ||
395 | ASSERT(WSAGETSELECTEVENT(lP)&FD_READ); | ||
396 | long length; | ||
397 | do{ | ||
398 | if(ioctlsocket(m_ctlSocket,FIONREAD,(u_long*)&length) || length<=0) | ||
399 | break; | ||
400 | if(recv(m_ctlSocket,(char*)&m_ctlResponse,sizeof(m_ctlResponse),0)!=sizeof(m_ctlResponse)) | ||
401 | continue; | ||
402 | if( | ||
403 | m_ctlResponse.m_Version != talkCtlVersion | ||
404 | || m_ctlResponse.m_Type!=m_ctlRequest.m_Type | ||
405 | ) | ||
406 | continue; | ||
407 | // We got the datagram we need here | ||
408 | AsyncCtlTransactSucceeded(m_ctlResponse); | ||
409 | }while(1); | ||
410 | if(WSAAsyncSelect(m_ctlSocket,m_hWnd,WM_CTLTRANSACT,FD_READ)){ | ||
411 | AsyncCtlTransactFailed(ctlFailSelect,WSAGetLastError()); | ||
412 | return -1; | ||
413 | } | ||
414 | SetTimer(timerTransact,2000,NULL); | ||
415 | return 0; | ||
416 | } | ||
417 | |||
418 | void T42Frame::OnTimer(UINT nIDEvent) | ||
419 | { | ||
420 | switch(nIDEvent){ | ||
421 | case timerTransact: | ||
422 | KillTimer(timerTransact); | ||
423 | if(!(m_ctlSuccess && m_ctlFailure)){ | ||
424 | TRACE0("VERY STRANGE\n"); | ||
425 | break; | ||
426 | } | ||
427 | TRACE0("Transact timed out\n"); | ||
428 | if(sendto(m_ctlSocket,(char*)&m_ctlRequest,sizeof(m_ctlRequest),0, | ||
429 | (sockaddr*)&m_ctlTarget,sizeof(m_ctlTarget))!=sizeof(m_ctlRequest) | ||
430 | ){ | ||
431 | AsyncCtlTransactFailed(ctlFailSendto,WSAGetLastError()); | ||
432 | break; | ||
433 | } | ||
434 | if(WSAAsyncSelect(m_ctlSocket,m_hWnd,WM_CTLTRANSACT,FD_READ)){ | ||
435 | AsyncCtlTransactFailed(ctlFailSelect,WSAGetLastError()); | ||
436 | break; | ||
437 | } | ||
438 | SetTimer(timerTransact,2000,NULL); | ||
439 | break; | ||
440 | } | ||
441 | |||
442 | CFrameWnd::OnTimer(nIDEvent); | ||
443 | } | ||
444 | |||
445 | |||
446 | void T42Frame::AsyncCtlTransactFailed(UINT code,LONG error) | ||
447 | { | ||
448 | ASSERT(m_ctlSuccess && m_ctlFailure); | ||
449 | UINT m = m_ctlFailure; | ||
450 | m_ctlFailure = m_ctlSuccess = 0; | ||
451 | WSAAsyncSelect(m_ctlSocket,NULL,0,0); | ||
452 | TRACE2("CTL Transact failed %d (%ld)\n",(int)code,error); | ||
453 | PostMessage(m,code,error); | ||
454 | } | ||
455 | |||
456 | void T42Frame::AsyncCtlTransactSucceeded(TalkCtlResponse& response) | ||
457 | { | ||
458 | ASSERT(m_ctlSuccess && m_ctlFailure); | ||
459 | UINT m = m_ctlSuccess; | ||
460 | m_ctlFailure = m_ctlSuccess = 0; | ||
461 | WSAAsyncSelect(m_ctlSocket,NULL,0,0); | ||
462 | TRACE2("CTL Transaction succeeded - A: %d, ID: %ld\n", | ||
463 | (int)response.m_Answer, ntohl(response.m_ID) | ||
464 | ); | ||
465 | TRACE2("ADDR: %s:%d\n", | ||
466 | inet_ntoa(((sockaddr_in*)&response.m_Addr)->sin_addr), | ||
467 | ntohs(((sockaddr_in*)&response.m_Addr)->sin_port) | ||
468 | ); | ||
469 | PostMessage(m,0,(LPARAM)&response); | ||
470 | } | ||
471 | |||
472 | LRESULT T42Frame::OnLookupSuccess(WPARAM,LPARAM lP) | ||
473 | { | ||
474 | TalkCtlResponse& rp = *(TalkCtlResponse*)lP; | ||
475 | if(rp.m_Answer==talkCtlSuccess){ | ||
476 | TRACE0("Found an invitation\n"); | ||
477 | if(WSAAsyncSelect(m_Socket,m_hWnd,WM_TALKCONNECT,FD_CONNECT)){ | ||
478 | WSSystemMessage(IDS_ERR_TCPASELFAILED,WSAGetLastError()); | ||
479 | return -1; | ||
480 | } | ||
481 | SOCKADDR_IN sin; | ||
482 | memmove(&sin,&rp.m_Addr,sizeof(sin)); | ||
483 | sin.sin_family = ntohs(sin.sin_family); | ||
484 | StatusLine(IDS_STATUS_WAITINGTOCONNECT); | ||
485 | if(connect(m_Socket,(sockaddr*)&sin,sizeof(sin))){ | ||
486 | if(WSAGetLastError()!=WSAEWOULDBLOCK){ | ||
487 | WSSystemMessage(IDS_ERR_TCPCONNECTFAILED,WSAGetLastError()); | ||
488 | return -1; | ||
489 | } | ||
490 | }else | ||
491 | PostMessage(WM_TALKCONNECT,0,WSAMAKESELECTREPLY(FD_CONNECT,0)); | ||
492 | }else{ | ||
493 | if(listen(m_Socket,5)){ | ||
494 | WSSystemMessage(IDS_ERR_TCPLISTENFAILED,WSAGetLastError()); | ||
495 | return -1; | ||
496 | } | ||
497 | if(WSAAsyncSelect(m_Socket,m_hWnd,WM_TALKACCEPT,FD_ACCEPT)){ | ||
498 | WSSystemMessage(IDS_ERR_LTNASELFAILED,WSAGetLastError()); | ||
499 | return -1; | ||
500 | } | ||
501 | TalkCtlMessage rq; | ||
502 | FillInMessage(rq); | ||
503 | rq.m_Type = talkCtlReqLeaveInvite; | ||
504 | rq.m_ID = htonl(-1); | ||
505 | SOCKADDR_IN tgt; | ||
506 | memmove(&tgt,&m_SourceAddr,sizeof(tgt)); | ||
507 | CT42App* app = (CT42App*)AfxGetApp(); | ||
508 | tgt.sin_port = htons(app->m_T42TalkPort); | ||
509 | VERIFY(AsyncCtlTransact(rq,tgt,WM_LEAVEINVITE_SUCCESS,WM_LEAVEINVITE_FAILURE)); | ||
510 | } | ||
511 | return 0; | ||
512 | } | ||
513 | LRESULTT42Frame::OnLookupFailure(WPARAM wP,LPARAM lP) | ||
514 | { | ||
515 | SystemMessage(IDS_ERR_CTLLOOKUPFAILED); | ||
516 | TRACE2("Lookup failed %d, %ld",(int)wP,lP); | ||
517 | return -1; | ||
518 | } | ||
519 | |||
520 | LRESULT T42Frame::OnAnnounceSuccess(WPARAM,LPARAM lP) | ||
521 | { | ||
522 | TalkCtlResponse& rp = *(TalkCtlResponse*)lP; | ||
523 | if(rp.m_Answer != talkCtlSuccess){ | ||
524 | static | ||
525 | UINT nReasons[] = {0,IDS_CTL_NOTHERE,IDS_CTL_FAILED,IDS_CTL_MACHUNKNOWN, | ||
526 | IDS_CTL_PERMISSIONDENIED, IDS_CTL_BADREQUEST, IDS_CTL_BADVERSION, | ||
527 | IDS_CTL_BADADDR, IDS_CTL_BADCTL}; | ||
528 | CString reason; | ||
529 | if(rp.m_Answer<(sizeof(nReasons)/sizeof(*nReasons))) | ||
530 | SystemMessage(IDS_ERR_ANNOUNCEFAILURE,nReasons[rp.m_Answer]); | ||
531 | else | ||
532 | SystemMessage(IDS_ERR_ANNOUNCEFAILURE,IDS_CTL_UNKNOWNERROR); | ||
533 | return -1; | ||
534 | } | ||
535 | m_remoteID = rp.m_ID; | ||
536 | return 0; | ||
537 | } | ||
538 | LRESULT T42Frame::OnAnnounceFailure(WPARAM wP,LPARAM lP) | ||
539 | { | ||
540 | SystemMessage(IDS_ERR_ANNOUNCEFAILED); | ||
541 | return -1; | ||
542 | } | ||
543 | |||
544 | LRESULT T42Frame::OnLeaveInviteSuccess(WPARAM,LPARAM lP) | ||
545 | { | ||
546 | TalkCtlResponse& rp = *(TalkCtlResponse*)lP; | ||
547 | m_localID = rp.m_ID; | ||
548 | TalkCtlMessage rq; | ||
549 | FillInMessage(rq); | ||
550 | rq.m_ID = htonl(-1); | ||
551 | StatusLine(IDS_STATUS_ANNOUNCING); | ||
552 | rq.m_Type = talkCtlReqAnnounce; | ||
553 | m_TargetAddr.sin_family = AF_INET; | ||
554 | CT42App* app = (CT42App*)AfxGetApp(); | ||
555 | m_TargetAddr.sin_port = htons(app->m_T42TalkPort); | ||
556 | VERIFY(AsyncCtlTransact(rq,m_TargetAddr,WM_ANNOUNCE_SUCCESS,WM_ANNOUNCE_FAILURE)); | ||
557 | return 0;// Or? | ||
558 | } | ||
559 | LRESULT T42Frame::OnLeaveInviteFailure(WPARAM wP,LPARAM lP) | ||
560 | { | ||
561 | SystemMessage(IDS_ERR_LEAVINVITEFAILED); | ||
562 | TRACE2("LeaveInvite failed %d, %ld",(int)wP,lP); | ||
563 | return -1; | ||
564 | } | ||
565 | |||
566 | LRESULT T42Frame::OnTalkAccept(WPARAM,LPARAM lP) | ||
567 | { | ||
568 | if(WSAGETSELECTERROR(lP)){ | ||
569 | WSSystemMessage(IDS_ERR_TCPACCEPTFAILED,WSAGETSELECTERROR(lP)); | ||
570 | return -1; | ||
571 | } | ||
572 | ASSERT(WSAGETSELECTEVENT(lP)&FD_ACCEPT); | ||
573 | SOCKET s = accept(m_Socket,NULL,NULL); | ||
574 | ASSERT(s!=INVALID_SOCKET); | ||
575 | VERIFY(!closesocket(m_Socket)); | ||
576 | m_Socket = s; | ||
577 | m_bConnected=TRUE; | ||
578 | SelectTalkSocket(); | ||
579 | StatusLine(IDS_STATUS_WAITINGTOCONNECT); | ||
580 | TalkCtlMessage rq; | ||
581 | FillInMessage(rq); | ||
582 | rq.m_Type = talkCtlReqDelete; | ||
583 | rq.m_ID = m_localID; | ||
584 | SOCKADDR_IN t; | ||
585 | memmove(&t,&m_SourceAddr,sizeof(t)); | ||
586 | CT42App* app = (CT42App*)AfxGetApp(); | ||
587 | t.sin_port = htons(app->m_T42TalkPort); | ||
588 | AsyncCtlTransact(rq,t,WM_LOCAL_REMOVE_SUCCESS,WM_LOCAL_REMOVE_FAILURE); | ||
589 | return 0; | ||
590 | } | ||
591 | |||
592 | LRESULT T42Frame::OnTalkConnect(WPARAM,LPARAM lP) | ||
593 | { | ||
594 | if(WSAGETSELECTERROR(lP)){ | ||
595 | WSSystemMessage(IDS_ERR_TCPCONNECTFAILED,WSAGETSELECTERROR(lP)); | ||
596 | return -1; | ||
597 | } | ||
598 | m_bConnected=TRUE; | ||
599 | ASSERT(WSAGETSELECTEVENT(lP)&FD_CONNECT); | ||
600 | SelectTalkSocket(); | ||
601 | StatusLine(IDS_STATUS_WAITINGTOCONNECT); | ||
602 | return 0; | ||
603 | } | ||
604 | |||
605 | LRESULT T42Frame::OnLocalRemoveSuccess(WPARAM,LPARAM lP) | ||
606 | { | ||
607 | TalkCtlResponse& rp = *(TalkCtlResponse*)lP; | ||
608 | ASSERT(rp.m_Answer==talkCtlSuccess); | ||
609 | TalkCtlMessage rq; | ||
610 | FillInMessage(rq); | ||
611 | rq.m_Type = talkCtlReqDelete; | ||
612 | rq.m_ID = m_remoteID; | ||
613 | SOCKADDR_IN t; | ||
614 | memmove(&t,&m_TargetAddr,sizeof(t)); | ||
615 | CT42App* app = (CT42App*)AfxGetApp(); | ||
616 | t.sin_port = htons(app->m_T42TalkPort); | ||
617 | AsyncCtlTransact(rq,t,WM_REMOTE_REMOVE_SUCCESS,WM_REMOTE_REMOVE_FAILURE); | ||
618 | return 0; | ||
619 | } | ||
620 | LRESULT T42Frame::OnLocalRemoveFailure(WPARAM wP,LPARAM lP) | ||
621 | { | ||
622 | //SystemMessage(IDS_ERR_CTLLDELETEFAILED); | ||
623 | TRACE2("Local delete failed %d, %ld",(int)wP,lP); | ||
624 | return -1; | ||
625 | } | ||
626 | |||
627 | LRESULT T42Frame::OnRemoteRemoveSuccess(WPARAM,LPARAM lP) | ||
628 | { | ||
629 | TalkCtlResponse& rp = *(TalkCtlResponse*)lP; | ||
630 | // ASSERT(rp.m_Answer==talkCtlSuccess);// ??? | ||
631 | return 0; | ||
632 | } | ||
633 | LRESULT T42Frame::OnRemoteRemoveFailure(WPARAM wP,LPARAM lP) | ||
634 | { | ||
635 | //SystemMessage(IDS_ERR_CTLRDELETEFAILED); | ||
636 | TRACE2("Local delete failed %d, %ld",(int)wP,lP); | ||
637 | return -1; | ||
638 | } | ||
639 | |||
640 | LRESULT T42Frame::OnTalk(WPARAM wP,LPARAM lP) | ||
641 | { | ||
642 | if(WSAGETSELECTEVENT(lP)&FD_CLOSE){ | ||
643 | StatusLine(IDS_STATUS_CONNECTIONCLOSED); | ||
644 | if(WSAGETSELECTERROR(lP)) | ||
645 | WSSystemMessage(IDS_ERR_CONNECTIONCLOSED,WSAGETSELECTERROR(lP)); | ||
646 | else | ||
647 | SystemMessage(IDS_CONNECTIONCLOSED); | ||
648 | Established(FALSE); | ||
649 | return 0; | ||
650 | } | ||
651 | if(WSAGETSELECTERROR(lP)){ | ||
652 | WSSystemMessage(IDS_ERR_TCPERROR,WSAGETSELECTERROR(lP)); | ||
653 | Established(FALSE); | ||
654 | TRACE1("Error on conversation socket: %ld\n",WSAGETSELECTERROR(lP)); | ||
655 | return -1; | ||
656 | } | ||
657 | if(WSAGETSELECTEVENT(lP)&FD_READ){ | ||
658 | CHAR rb[512+1]; | ||
659 | int rbytes = recv(m_Socket,rb,sizeof(rb)-1,0); | ||
660 | if(rbytes>0){ | ||
661 | if(m_receivedEC<sizeof(m_remoteEC)){ | ||
662 | int ms = min(sizeof(m_remoteEC)-m_receivedEC,rbytes); | ||
663 | memmove( | ||
664 | &((CHAR*)&m_remoteEC)[m_receivedEC],rb,ms | ||
665 | ); | ||
666 | memmove(rb,&rb[ms],sizeof(rb)-ms); | ||
667 | rbytes-=ms; | ||
668 | m_receivedEC+=ms; | ||
669 | // Under some circumstances we can claim connection | ||
670 | // establishment here. | ||
671 | if(m_receivedEC==sizeof(m_remoteEC)){ | ||
672 | StatusLine(IDS_STATUS_ESTABLISHED); | ||
673 | Established(TRUE); | ||
674 | } | ||
675 | } | ||
676 | if(rbytes){ | ||
677 | rb[rbytes]=0; | ||
678 | T42Document* pDoc = (T42Document*)GetActiveDocument(); | ||
679 | ASSERT_KINDOF(T42Document,pDoc); | ||
680 | if(pDoc->m_pRobot) | ||
681 | pDoc->m_pRobot->OnReceive(rb,rbytes); | ||
682 | PutRemote(rb); | ||
683 | if(!m_bHaveFocus){ | ||
684 | SetTheIcon(m_hFullCup); | ||
685 | if(m_bSleep) | ||
686 | WakeUp(); | ||
687 | } | ||
688 | } | ||
689 | } | ||
690 | } | ||
691 | if(WSAGETSELECTEVENT(lP)&FD_WRITE){ | ||
692 | if(!m_bSentEC){ | ||
693 | if(send(m_Socket,(char*)&m_localEC,sizeof(m_localEC),0)!=sizeof(m_localEC)){ | ||
694 | WSSystemMessage(IDS_ERR_TCPERROR,WSAGetLastError()); | ||
695 | Established(FALSE); | ||
696 | }else | ||
697 | m_bSentEC = TRUE; | ||
698 | }else{ | ||
699 | int sb = send(m_Socket,(char*)(LPCTSTR)m_sendBuffer,m_sendBuffer.GetLength(),0); | ||
700 | if(sb<0){ | ||
701 | WSSystemMessage(IDS_ERR_TCPERROR,WSAGetLastError()); | ||
702 | Established(FALSE); | ||
703 | }else | ||
704 | m_sendBuffer = m_sendBuffer.Mid(sb); | ||
705 | } | ||
706 | } | ||
707 | SelectTalkSocket(); | ||
708 | return 0; | ||
709 | } | ||
710 | |||
711 | void T42Frame::SelectTalkSocket() | ||
712 | { | ||
713 | if(!m_bConnected) | ||
714 | return; | ||
715 | UINT mask = FD_READ|FD_CLOSE; | ||
716 | if(!(m_bSentEC && m_sendBuffer.IsEmpty())) | ||
717 | mask|=FD_WRITE; | ||
718 | if(WSAAsyncSelect(m_Socket,m_hWnd,WM_TALK,mask)){ | ||
719 | WSSystemMessage(IDS_ERR_TCPERROR,WSAGetLastError()); | ||
720 | Established(FALSE); | ||
721 | } | ||
722 | } | ||
723 | |||
724 | BOOL T42Frame::PutRemote(LPCTSTR str) | ||
725 | { | ||
726 | T42View* pView = (T42View*)GetActiveView(); | ||
727 | ASSERT_KINDOF(T42View,pView); | ||
728 | pView->m_remoteCtl.PutString(str); | ||
729 | return TRUE; | ||
730 | } | ||
731 | |||
732 | LRESULT T42Frame::OnTalkChar(WPARAM wP,LPARAM lP) | ||
733 | { | ||
734 | if(wP){ | ||
735 | CHAR c=(CHAR)(wP&0xFF); | ||
736 | // if(c=='\r') | ||
737 | //?? c='\n'; | ||
738 | m_sendBuffer+=c; | ||
739 | }else{ | ||
740 | CString str = (LPCTSTR)lP; | ||
741 | int cr; | ||
742 | while((cr=str.Find('\r'))>=0) | ||
743 | str = str.Left(cr)+str.Mid(cr+1); | ||
744 | m_sendBuffer+=str; | ||
745 | } | ||
746 | SelectTalkSocket(); | ||
747 | return 0; | ||
748 | } | ||
749 | |||
750 | int T42Frame::OnCreate(LPCREATESTRUCT lpCreateStruct) | ||
751 | { | ||
752 | if(CFrameWnd::OnCreate(lpCreateStruct)==-1) | ||
753 | return -1; | ||
754 | // CG: The following block was inserted by 'Status Bar' component. | ||
755 | { | ||
756 | // Create an array for status bar indicators | ||
757 | UINT pIndicators[3] = { ID_SEPARATOR }; | ||
758 | if (!m_wndStatusBar.Create(this) || | ||
759 | !InitStatusBar(pIndicators, 1, 60)) | ||
760 | { | ||
761 | TRACE0("Failed to create Status Bar\n"); | ||
762 | return -1; | ||
763 | } | ||
764 | } | ||
765 | |||
766 | m_wndFake.CreateEx( | ||
767 | 0,AfxRegisterWndClass(0,0,0,0),"",WS_OVERLAPPED, | ||
768 | 0,0,0,0, | ||
769 | NULL,NULL,NULL | ||
770 | ); | ||
771 | |||
772 | return 0; | ||
773 | } | ||
774 | |||
775 | void T42Frame::OnUpdateDate(CCmdUI* pCmdUI) | ||
776 | { | ||
777 | // CG: This function was inserted by 'Status Bar' component. | ||
778 | |||
779 | // Get current date and format it | ||
780 | CTime time = CTime::GetCurrentTime(); | ||
781 | CString strDate = time.Format(_T("%A, %B %d, %y ")); | ||
782 | |||
783 | // BLOCK: compute the width of the date string | ||
784 | CSize size; | ||
785 | { | ||
786 | HGDIOBJ hOldFont = NULL; | ||
787 | HFONT hFont = (HFONT)m_wndStatusBar.SendMessage(WM_GETFONT); | ||
788 | CClientDC dc(NULL); | ||
789 | if (hFont != NULL) | ||
790 | hOldFont = dc.SelectObject(hFont); | ||
791 | size = dc.GetTextExtent(strDate); | ||
792 | if (hOldFont != NULL) | ||
793 | dc.SelectObject(hOldFont); | ||
794 | } | ||
795 | |||
796 | // Update the pane to reflect the current date | ||
797 | UINT nID, nStyle; | ||
798 | int nWidth; | ||
799 | m_wndStatusBar.GetPaneInfo(m_nDatePaneNo, nID, nStyle, nWidth); | ||
800 | m_wndStatusBar.SetPaneInfo(m_nDatePaneNo, nID, nStyle, size.cx); | ||
801 | pCmdUI->SetText(strDate); | ||
802 | pCmdUI->Enable(TRUE); | ||
803 | |||
804 | } | ||
805 | |||
806 | BOOL T42Frame::InitStatusBar(UINT *pIndicators, int nSize, int nSeconds) | ||
807 | { | ||
808 | // CG: This function was inserted by 'Status Bar' component. | ||
809 | |||
810 | // Create an index for the DATE pane | ||
811 | m_nDatePaneNo = nSize++; | ||
812 | pIndicators[m_nDatePaneNo] = ID_INDICATOR_DATE; | ||
813 | |||
814 | m_wndStatusBar.SetTimer(0x1000, nSeconds * 1000, NULL); | ||
815 | |||
816 | return m_wndStatusBar.SetIndicators(pIndicators, nSize); | ||
817 | |||
818 | } | ||
819 | |||
820 | void T42Frame::StatusLine(LPCTSTR str) | ||
821 | { | ||
822 | m_wndStatusBar.SetPaneText(0,m_Status=str); | ||
823 | } | ||
824 | |||
825 | void T42Frame::StatusLine(UINT nID) | ||
826 | { | ||
827 | VERIFY(m_Status.LoadString(nID)); | ||
828 | m_wndStatusBar.SetPaneText(0,m_Status); | ||
829 | } | ||
830 | |||
831 | LRESULT T42Frame::OnExitMenuLoop(WPARAM,LPARAM) | ||
832 | { | ||
833 | m_wndStatusBar.SetPaneText(0,m_Status); | ||
834 | return 0; | ||
835 | } | ||
836 | |||
837 | void T42Frame::OnDestroy() | ||
838 | { | ||
839 | if(m_bTrayed){ | ||
840 | NOTIFYICONDATA nid; | ||
841 | memset(&nid,0,sizeof(nid)); | ||
842 | nid.cbSize=sizeof(nid); | ||
843 | nid.hWnd = m_hWnd; | ||
844 | nid.uID = IDC_TRAYICON; | ||
845 | nid.uFlags = 0; | ||
846 | VERIFY(Shell_NotifyIcon(NIM_DELETE,&nid)); | ||
847 | } | ||
848 | m_wndFake.DestroyWindow(); | ||
849 | CFrameWnd::OnDestroy(); | ||
850 | |||
851 | CleanUp(); | ||
852 | } | ||
853 | |||
854 | void T42Frame::ShowMessage(UINT nID,UINT flags) | ||
855 | { | ||
856 | CString msg; | ||
857 | VERIFY(msg.LoadString(nID)); | ||
858 | ShowMessage(msg,flags); | ||
859 | } | ||
860 | void T42Frame::ShowMessage(LPCTSTR msg,UINT flags) | ||
861 | { | ||
862 | MessageBox(msg,NULL,flags); | ||
863 | } | ||
864 | |||
865 | void T42Frame::Established(BOOL bEstablished) | ||
866 | { | ||
867 | if(!bEstablished) | ||
868 | CleanUp(); | ||
869 | else{ | ||
870 | if( | ||
871 | (!((T42Document*)GetActiveDocument())->m_bHidden) | ||
872 | && !m_bTrayed | ||
873 | ) | ||
874 | SetForegroundWindow(); | ||
875 | } | ||
876 | T42View* pView = (T42View*)GetActiveView(); | ||
877 | ASSERT_KINDOF(T42View,pView); | ||
878 | pView->SetEnable(bEstablished); | ||
879 | |||
880 | BOOL bRobot = (m_bEstablished && !bEstablished) || (bEstablished && !m_bEstablished); | ||
881 | m_bEstablished = bEstablished; | ||
882 | |||
883 | SetPeerName(); | ||
884 | if(bRobot){ | ||
885 | T42Document* pDoc = (T42Document*)pView->GetDocument(); | ||
886 | ASSERT_KINDOF(T42Document,pDoc); | ||
887 | if(pDoc->m_pRobot){ | ||
888 | if(bEstablished) | ||
889 | pDoc->m_pRobot->OnConnect(); | ||
890 | else | ||
891 | pDoc->m_pRobot->OnDisconnect(); | ||
892 | } | ||
893 | } | ||
894 | } | ||
895 | |||
896 | void T42Frame::CleanUp() | ||
897 | { | ||
898 | if(m_resolveHandle){ | ||
899 | WSACancelAsyncRequest(m_resolveHandle); | ||
900 | m_resolveHandle=NULL; | ||
901 | } | ||
902 | if(m_asyncHandle){ | ||
903 | WSACancelAsyncRequest(m_asyncHandle); | ||
904 | m_asyncHandle=NULL; | ||
905 | } | ||
906 | if(m_ctlSocket!=INVALID_SOCKET){ | ||
907 | closesocket(m_ctlSocket); | ||
908 | m_ctlSocket = INVALID_SOCKET; | ||
909 | } | ||
910 | if(m_Socket!=INVALID_SOCKET){ | ||
911 | closesocket(m_Socket); | ||
912 | m_Socket = INVALID_SOCKET; | ||
913 | } | ||
914 | |||
915 | m_Status.LoadString(AFX_IDS_IDLEMESSAGE); | ||
916 | m_localID = m_remoteID = 0; | ||
917 | m_sendBuffer.Empty(); | ||
918 | m_ctlSuccess = 0; | ||
919 | m_ctlFailure = 0; | ||
920 | m_bSentEC = FALSE; | ||
921 | m_receivedEC = 0; | ||
922 | m_bConnected=FALSE; | ||
923 | } | ||
924 | |||
925 | void T42Frame::OnSysCommand(UINT nID, LPARAM lParam) | ||
926 | { | ||
927 | if(nID==SC_MINIMIZE){ | ||
928 | if(m_bTrayMinimize){ | ||
929 | NOTIFYICONDATA nid; | ||
930 | memset(&nid,0,sizeof(nid)); | ||
931 | nid.cbSize=sizeof(nid); | ||
932 | nid.hWnd = m_hWnd; | ||
933 | nid.uID = IDC_TRAYICON; | ||
934 | nid.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP; | ||
935 | nid.uCallbackMessage = WM_TRAYICON; | ||
936 | nid.hIcon =m_hNormal; | ||
937 | CString tip; | ||
938 | GetWindowText(tip); | ||
939 | if(tip.GetLength()>=sizeof(nid.szTip)) | ||
940 | tip = tip.Left(sizeof(nid.szTip)-3)+".."; | ||
941 | strcpy(nid.szTip,(LPCTSTR)tip); | ||
942 | VERIFY(Shell_NotifyIcon(NIM_ADD,&nid)); | ||
943 | CWnd* pWnd = GetNextWindow(); | ||
944 | ShowWindow(SW_HIDE); | ||
945 | pWnd->SetForegroundWindow(); | ||
946 | m_bTrayed=TRUE; | ||
947 | }else | ||
948 | CFrameWnd::OnSysCommand(nID, lParam); | ||
949 | if(m_bSleepMinimize) | ||
950 | m_bSleep=TRUE; | ||
951 | }else | ||
952 | CFrameWnd::OnSysCommand(nID, lParam); | ||
953 | } | ||
954 | |||
955 | void T42Frame::SaveLayout() | ||
956 | { | ||
957 | CWinApp* app = AfxGetApp(); | ||
958 | CRect rc; | ||
959 | GetWindowRect(rc); | ||
960 | app->WriteProfileInt("T42Window","X",rc.left); | ||
961 | app->WriteProfileInt("T42Window","Y",rc.top); | ||
962 | app->WriteProfileInt("T42Window","Width",rc.Width()); | ||
963 | app->WriteProfileInt("T42Window","Height",rc.Height()); | ||
964 | app->WriteProfileInt("T42Window","TrayMinimize",m_bTrayMinimize); | ||
965 | app->WriteProfileInt("T42Window","SleepMinimize",m_bSleepMinimize); | ||
966 | app->WriteProfileInt("T42Window","OnWake",m_onWake); | ||
967 | app->WriteProfileInt("T42Window","MinimizeSleep",m_bMinimizeSleep); | ||
968 | } | ||
969 | void T42Frame::LoadLayout() | ||
970 | { | ||
971 | CWinApp* app = AfxGetApp(); | ||
972 | m_bTrayMinimize = app->GetProfileInt("T42Window","TrayMinimize",m_bTrayMinimize); | ||
973 | m_bSleepMinimize = app->GetProfileInt("T42Window","SleepMinimize",m_bSleepMinimize); | ||
974 | m_onWake = app->GetProfileInt("T42Window","OnWake",m_onWake); | ||
975 | m_bMinimizeSleep = app->GetProfileInt("T42Window","MinimizeSleep",m_bMinimizeSleep); | ||
976 | } | ||
977 | |||
978 | void T42Frame::SetPeerName(LPCTSTR str) | ||
979 | { | ||
980 | T42Document* pDoc = (T42Document*)GetActiveDocument(); | ||
981 | ASSERT_KINDOF(T42Document,pDoc); | ||
982 | CString n = str?str:m_Target; | ||
983 | pDoc->SetTitle(n); | ||
984 | m_wndFake.SetWindowText("Talk with "+n); | ||
985 | } | ||
986 | |||
987 | void T42Frame::OnUpdateFrameTitle(BOOL bAddToTitle) | ||
988 | { | ||
989 | T42Document* pDoc = (T42Document*)GetActiveDocument(); | ||
990 | ASSERT_KINDOF(T42Document,pDoc); | ||
991 | CString title; | ||
992 | if(bAddToTitle && pDoc && m_bEstablished) | ||
993 | title.Format(IDS_TITLE_TEAWITH,pDoc->GetTitle()); | ||
994 | else | ||
995 | title.LoadString(IDS_TITLE_TEAFORTWO); | ||
996 | SetWindowText(title); | ||
997 | } | ||
998 | |||
999 | void T42Frame::AddToHotList(LPCTSTR str) | ||
1000 | { | ||
1001 | CT42App* app = (CT42App*)AfxGetApp(); | ||
1002 | app->LastCallee(str?str:m_Target); | ||
1003 | } | ||
1004 | |||
1005 | void T42Frame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) | ||
1006 | { | ||
1007 | CFrameWnd::OnActivate(nState, pWndOther, bMinimized); | ||
1008 | if(nState==WA_INACTIVE){ | ||
1009 | m_bHaveFocus=FALSE; | ||
1010 | }else{ | ||
1011 | DeTray(); | ||
1012 | SetTheIcon(m_hNormal); | ||
1013 | m_bHaveFocus=TRUE; | ||
1014 | } | ||
1015 | } | ||
1016 | |||
1017 | LRESULT T42Frame::OnTrayIcon(WPARAM wP,LPARAM lP) | ||
1018 | { | ||
1019 | ASSERT(wP==IDC_TRAYICON); | ||
1020 | if(lP==WM_LBUTTONDOWN) | ||
1021 | SetForegroundWindow(); | ||
1022 | return 0; | ||
1023 | } | ||
1024 | |||
1025 | void T42Frame::SetTheIcon(HICON hicon) | ||
1026 | { | ||
1027 | SetIcon(hicon,TRUE); SetIcon(hicon,FALSE); | ||
1028 | if(m_bTrayed){ | ||
1029 | NOTIFYICONDATA nid; | ||
1030 | memset(&nid,0,sizeof(nid)); | ||
1031 | nid.cbSize=sizeof(nid); | ||
1032 | nid.hWnd = m_hWnd; | ||
1033 | nid.uID = IDC_TRAYICON; | ||
1034 | nid.uFlags = NIF_ICON; | ||
1035 | nid.hIcon =hicon; | ||
1036 | VERIFY(Shell_NotifyIcon(NIM_MODIFY,&nid)); | ||
1037 | } | ||
1038 | } | ||
1039 | |||
1040 | void T42Frame::OnUpdateWindowHideintrayonminimize(CCmdUI* pCmdUI) | ||
1041 | { | ||
1042 | pCmdUI->SetCheck(m_bTrayMinimize?1:0); | ||
1043 | } | ||
1044 | void T42Frame::OnWindowHideintrayonminimize() | ||
1045 | { | ||
1046 | m_bTrayMinimize=!m_bTrayMinimize; | ||
1047 | } | ||
1048 | |||
1049 | void T42Frame::OnTalkAbort() | ||
1050 | { | ||
1051 | ASSERT(m_Socket); | ||
1052 | closesocket(m_Socket); | ||
1053 | StatusLine(IDS_STATUS_CONNECTIONCLOSED); | ||
1054 | SystemMessage(IDS_CONNECTIONCLOSED); | ||
1055 | Established(FALSE); | ||
1056 | } | ||
1057 | void T42Frame::OnUpdateTalkAbort(CCmdUI* pCmdUI) | ||
1058 | { | ||
1059 | pCmdUI->Enable(m_bEstablished); | ||
1060 | } | ||
1061 | void T42Frame::OnTalkReconnect() | ||
1062 | { | ||
1063 | PostMessage(WM_INITIATETALK); | ||
1064 | } | ||
1065 | void T42Frame::OnUpdateTalkReconnect(CCmdUI* pCmdUI) | ||
1066 | { | ||
1067 | pCmdUI->Enable((!m_bEstablished) && (!m_Target.IsEmpty())); | ||
1068 | } | ||
1069 | void T42Frame::OnUpdateTalkRemoteuser(CCmdUI* pCmdUI) | ||
1070 | { | ||
1071 | pCmdUI->Enable(!m_bEstablished); | ||
1072 | } | ||
1073 | |||
1074 | void T42Frame::WakeUp() | ||
1075 | { | ||
1076 | if(m_onWake&wakeSound){ | ||
1077 | CT42App* app = (CT42App*)AfxGetApp(); | ||
1078 | ASSERT(app); | ||
1079 | app->StartSound(app->m_sndT42Wake); | ||
1080 | } | ||
1081 | if(m_onWake&wakePopup) | ||
1082 | SetForegroundWindow(); | ||
1083 | m_bSleep=FALSE; | ||
1084 | } | ||
1085 | |||
1086 | void T42Frame::OnUpdateSleepSleep(CCmdUI* pCmdUI) | ||
1087 | { | ||
1088 | pCmdUI->SetCheck(m_bSleep?1:0); | ||
1089 | } | ||
1090 | void T42Frame::OnSleepSleep() | ||
1091 | { | ||
1092 | m_bSleep=!m_bSleep; | ||
1093 | if(m_bSleep && m_bMinimizeSleep) | ||
1094 | PostMessage(WM_SYSCOMMAND,SC_MINIMIZE); | ||
1095 | } | ||
1096 | |||
1097 | void T42Frame::OnUpdateSleepSleeponminimize(CCmdUI* pCmdUI) | ||
1098 | { | ||
1099 | pCmdUI->SetCheck(m_bSleepMinimize?1:0); | ||
1100 | } | ||
1101 | void T42Frame::OnSleepSleeponminimize() | ||
1102 | { | ||
1103 | m_bSleepMinimize=!m_bSleepMinimize; | ||
1104 | } | ||
1105 | |||
1106 | void T42Frame::OnUpdateSleepWakeupactionMakesound(CCmdUI* pCmdUI) | ||
1107 | { | ||
1108 | pCmdUI->SetCheck((m_onWake&wakeSound)?1:0); | ||
1109 | } | ||
1110 | void T42Frame::OnSleepWakeupactionMakesound() | ||
1111 | { | ||
1112 | m_onWake^=wakeSound; | ||
1113 | } | ||
1114 | |||
1115 | void T42Frame::OnUpdateSleepWakeupactionPopup(CCmdUI* pCmdUI) | ||
1116 | { | ||
1117 | pCmdUI->SetCheck((m_onWake&wakePopup)?1:0); | ||
1118 | } | ||
1119 | void T42Frame::OnSleepWakeupactionPopup() | ||
1120 | { | ||
1121 | m_onWake^=wakePopup; | ||
1122 | } | ||
1123 | |||
1124 | void T42Frame::DeTray() | ||
1125 | { | ||
1126 | if(!m_bTrayed) | ||
1127 | return; | ||
1128 | NOTIFYICONDATA nid; | ||
1129 | memset(&nid,0,sizeof(nid)); | ||
1130 | nid.cbSize=sizeof(nid); | ||
1131 | nid.hWnd = m_hWnd; | ||
1132 | nid.uID = IDC_TRAYICON; | ||
1133 | nid.uFlags = 0; | ||
1134 | VERIFY(Shell_NotifyIcon(NIM_DELETE,&nid)); | ||
1135 | m_bTrayed=FALSE; | ||
1136 | ShowWindow(SW_SHOW); | ||
1137 | } | ||
1138 | |||
1139 | void T42Frame::OnUpdateSleepMinimizeonsleep(CCmdUI* pCmdUI) | ||
1140 | { | ||
1141 | pCmdUI->SetCheck(m_bMinimizeSleep?1:0); | ||
1142 | } | ||
1143 | void T42Frame::OnSleepMinimizeonsleep() | ||
1144 | { | ||
1145 | m_bMinimizeSleep=!m_bMinimizeSleep; | ||
1146 | } | ||
1147 | |||
1148 | void T42Frame::OnTalkClose() | ||
1149 | { | ||
1150 | PostMessage(WM_CLOSE); | ||
1151 | } | ||
1152 | |||
1153 | void T42Frame::SystemMessage(UINT nID) | ||
1154 | { | ||
1155 | CString tmp; | ||
1156 | VERIFY(tmp.LoadString(nID)); | ||
1157 | SystemMessage(tmp); | ||
1158 | } | ||
1159 | |||
1160 | void T42Frame::SystemMessage(LPCTSTR str) | ||
1161 | { | ||
1162 | T42View* pView = (T42View*)GetActiveView(); | ||
1163 | ASSERT_KINDOF(T42View,pView); | ||
1164 | pView->SystemMessage(str); | ||
1165 | } | ||
1166 | |||
1167 | void T42Frame::SystemMessage(UINT nID,UINT nIDi) | ||
1168 | { | ||
1169 | CString idi; | ||
1170 | VERIFY(idi.LoadString(nIDi)); | ||
1171 | CString tmp; | ||
1172 | tmp.Format(nID,idi); | ||
1173 | SystemMessage(tmp); | ||
1174 | } | ||
1175 | |||
1176 | void T42Frame::WSSystemMessage(UINT nID,LONG wsaError) | ||
1177 | { | ||
1178 | UINT wsid = 0; | ||
1179 | switch(wsaError){ | ||
1180 | case WSAENETDOWN: wsid = IDS_WSA_ENETDOWN; break; | ||
1181 | case WSAECONNRESET: wsid = IDS_WSA_ECONNRESET; break; | ||
1182 | case WSAECONNABORTED: wsid = IDS_WSA_ECONNABORTED; break; | ||
1183 | case WSAECONNREFUSED: wsid = IDS_WSA_ECONNREFUSED; break; | ||
1184 | case WSAENETUNREACH: wsid = IDS_WSA_ENETUNREACH; break; | ||
1185 | case WSAETIMEDOUT: wsid = IDS_WSA_ETIMEDOUT; break; | ||
1186 | case WSAHOST_NOT_FOUND: wsid = IDS_WSA_HOSTNOTFOUND; break; | ||
1187 | case WSANO_DATA: wsid = IDS_WSA_NODATA; break; | ||
1188 | } | ||
1189 | if(wsid) | ||
1190 | SystemMessage(nID,wsid); | ||
1191 | else{ | ||
1192 | CString tmp; | ||
1193 | tmp.Format("#%ld",wsaError); | ||
1194 | SystemMessage(nID,tmp); | ||
1195 | } | ||
1196 | } | ||
1197 | |||
1198 | void T42Frame::SystemMessage(UINT nID,LPCTSTR str) | ||
1199 | { | ||
1200 | CString tmp; | ||
1201 | tmp.Format(nID,str); | ||
1202 | SystemMessage(tmp); | ||
1203 | } | ||
1204 | |||
1205 | void T42Frame::ActivateFrame(int nCmdShow) | ||
1206 | { | ||
1207 | T42Document* pDoc = (T42Document*)GetActiveDocument(); | ||
1208 | ASSERT_KINDOF(T42Document,pDoc); | ||
1209 | if(pDoc->m_bHidden) | ||
1210 | nCmdShow=SW_HIDE; | ||
1211 | CFrameWnd::ActivateFrame(nCmdShow); | ||
1212 | } | ||
diff --git a/T42Frame.h b/T42Frame.h new file mode 100644 index 0000000..9f220f1 --- a/dev/null +++ b/T42Frame.h | |||
@@ -0,0 +1,169 @@ | |||
1 | // T42Frame.h : header file | ||
2 | // | ||
3 | |||
4 | ///////////////////////////////////////////////////////////////////////////// | ||
5 | // T42Frame frame | ||
6 | |||
7 | struct TalkEditChars{ | ||
8 | CHARm_cErase; | ||
9 | CHARm_kill; | ||
10 | CHARm_wErase; | ||
11 | }; | ||
12 | |||
13 | class T42View; | ||
14 | class T42Frame : public CFrameWnd | ||
15 | { | ||
16 | DECLARE_DYNCREATE(T42Frame) | ||
17 | |||
18 | // Attributes | ||
19 | public: | ||
20 | BOOL m_bConnected; | ||
21 | void SystemMessage(UINT nID,LPCTSTR str); | ||
22 | void WSSystemMessage(UINT nID,LONG wsaError); | ||
23 | void SystemMessage(UINT nID,UINT nIDi); | ||
24 | void SystemMessage(LPCTSTR str); | ||
25 | void SystemMessage(UINT nID); | ||
26 | BOOL m_bMinimizeSleep; | ||
27 | void DeTray(); | ||
28 | void WakeUp(); | ||
29 | enum _wakeAction{ | ||
30 | wakePopup = 1, | ||
31 | wakeSound = 2 | ||
32 | }; | ||
33 | UINT m_onWake; | ||
34 | BOOL m_bSleep; | ||
35 | BOOL m_bSleepMinimize; | ||
36 | BOOL m_bTrayed; | ||
37 | void SetTheIcon(HICON hicon); | ||
38 | BOOL m_bTrayMinimize; | ||
39 | void LoadLayout(); | ||
40 | BOOL m_bHaveFocus; | ||
41 | HICON m_hFullCup; | ||
42 | HICON m_hNormal; | ||
43 | void AddToHotList(LPCTSTR str=NULL); | ||
44 | BOOL m_bEstablished; | ||
45 | virtual void OnUpdateFrameTitle(BOOL bAddToTitle); | ||
46 | void SetPeerName(LPCTSTR str=NULL); | ||
47 | void SaveLayout(); | ||
48 | CString m_nameFromIP; | ||
49 | BYTE m_ghResolve[MAXGETHOSTSTRUCT]; | ||
50 | HANDLE m_resolveHandle; | ||
51 | void CleanUp(); | ||
52 | CWnd m_wndFake; | ||
53 | void Established(BOOL bEstablished); | ||
54 | void ShowMessage(LPCTSTR msg,UINT flags); | ||
55 | void ShowMessage(UINT nID,UINT flags); | ||
56 | void StatusLine(UINT nID); | ||
57 | CString m_Status; | ||
58 | void StatusLine(LPCTSTR str); | ||
59 | int m_nDatePaneNo; | ||
60 | CString m_sendBuffer; | ||
61 | BOOL m_bSentEC; | ||
62 | UINT m_receivedEC; | ||
63 | TalkEditChars m_localEC; | ||
64 | TalkEditChars m_remoteEC; | ||
65 | BOOL PutRemote(LPCTSTR str); | ||
66 | void SelectTalkSocket(); | ||
67 | LONG m_remoteID; | ||
68 | LONG m_localID; | ||
69 | void AsyncCtlTransactSucceeded(TalkCtlResponse& response); | ||
70 | void AsyncCtlTransactFailed(UINT code,LONG error); | ||
71 | enum{ | ||
72 | ctlFailSendto = 1, | ||
73 | ctlFailSelect, ctlFailError | ||
74 | }; | ||
75 | UINTm_ctlSuccess; | ||
76 | UINTm_ctlFailure; | ||
77 | sockaddr_in m_ctlTarget; | ||
78 | BOOL AsyncCtlTransact(TalkCtlMessage& msg,sockaddr_in& target, UINT wmSuccess,UINT wmFailure); | ||
79 | TalkCtlMessage m_ctlRequest; | ||
80 | TalkCtlResponse m_ctlResponse; | ||
81 | CString m_TargetTTY; | ||
82 | CString m_LocalUser; | ||
83 | BOOL FillInMessage(TalkCtlMessage& msg); | ||
84 | SOCKET m_Socket; | ||
85 | SOCKADDR_IN m_ctlAddr; | ||
86 | SOCKET m_ctlSocket; | ||
87 | SOCKADDR_IN m_SourceAddr; | ||
88 | SOCKADDR_IN m_TargetAddr; | ||
89 | BYTE m_gethostData[MAXGETHOSTSTRUCT]; | ||
90 | HANDLE m_asyncHandle; | ||
91 | CString m_TargetHost; | ||
92 | CString m_TargetUser; | ||
93 | CString m_Target; | ||
94 | |||
95 | // Operations | ||
96 | public: | ||
97 | T42Frame(); // protected constructor used by dynamic creation | ||
98 | |||
99 | // Overrides | ||
100 | // ClassWizard generated virtual function overrides | ||
101 | //{{AFX_VIRTUAL(T42Frame) | ||
102 | public: | ||
103 | virtual void ActivateFrame(int nCmdShow = -1); | ||
104 | protected: | ||
105 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); | ||
106 | //}}AFX_VIRTUAL | ||
107 | |||
108 | // Implementation | ||
109 | protected: | ||
110 | CStatusBar m_wndStatusBar; | ||
111 | virtual ~T42Frame(); | ||
112 | public: | ||
113 | // Generated message map functions | ||
114 | //{{AFX_MSG(T42Frame) | ||
115 | afx_msg void OnClose(); | ||
116 | afx_msg void OnTalkRemoteuser(); | ||
117 | afx_msg LRESULT OnInitiateTalk(WPARAM,LPARAM); | ||
118 | afx_msg LRESULT OnTargetResolved(WPARAM,LPARAM); | ||
119 | afx_msg LRESULT OnSourceResolved(WPARAM,LPARAM); | ||
120 | afx_msg void OnTimer(UINT nIDEvent); | ||
121 | afx_msg LRESULT OnCTLTransact(WPARAM,LPARAM); | ||
122 | afx_msg LRESULT OnLookupSuccess(WPARAM,LPARAM); | ||
123 | afx_msg LRESULT OnLookupFailure(WPARAM,LPARAM); | ||
124 | afx_msg LRESULT OnAnnounceSuccess(WPARAM,LPARAM); | ||
125 | afx_msg LRESULT OnAnnounceFailure(WPARAM,LPARAM); | ||
126 | afx_msg LRESULT OnLeaveInviteSuccess(WPARAM,LPARAM); | ||
127 | afx_msg LRESULT OnLeaveInviteFailure(WPARAM,LPARAM); | ||
128 | afx_msg LRESULT OnTalkAccept(WPARAM,LPARAM); | ||
129 | afx_msg LRESULT OnLocalRemoveSuccess(WPARAM,LPARAM); | ||
130 | afx_msg LRESULT OnLocalRemoveFailure(WPARAM,LPARAM); | ||
131 | afx_msg LRESULT OnRemoteRemoveSuccess(WPARAM,LPARAM); | ||
132 | afx_msg LRESULT OnRemoteRemoveFailure(WPARAM,LPARAM); | ||
133 | afx_msg LRESULT OnTalk(WPARAM,LPARAM); | ||
134 | afx_msg LRESULT OnTalkChar(WPARAM,LPARAM); | ||
135 | afx_msg LRESULT OnTalkConnect(WPARAM,LPARAM); | ||
136 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); | ||
137 | afx_msg void OnUpdateDate(CCmdUI* pCmdUI); | ||
138 | afx_msg LRESULT OnExitMenuLoop(WPARAM,LPARAM); | ||
139 | afx_msg void OnDestroy(); | ||
140 | afx_msg void OnSysCommand(UINT nID, LPARAM lParam); | ||
141 | afx_msg LRESULT OnNameResolved(WPARAM,LPARAM); | ||
142 | afx_msg LRESULT OnIPResolved(WPARAM,LPARAM); | ||
143 | afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized); | ||
144 | afx_msg LRESULT OnTrayIcon(WPARAM,LPARAM); | ||
145 | afx_msg void OnUpdateWindowHideintrayonminimize(CCmdUI* pCmdUI); | ||
146 | afx_msg void OnWindowHideintrayonminimize(); | ||
147 | afx_msg void OnTalkAbort(); | ||
148 | afx_msg void OnUpdateTalkAbort(CCmdUI* pCmdUI); | ||
149 | afx_msg void OnTalkReconnect(); | ||
150 | afx_msg void OnUpdateTalkReconnect(CCmdUI* pCmdUI); | ||
151 | afx_msg void OnUpdateTalkRemoteuser(CCmdUI* pCmdUI); | ||
152 | afx_msg void OnUpdateSleepSleep(CCmdUI* pCmdUI); | ||
153 | afx_msg void OnSleepSleep(); | ||
154 | afx_msg void OnUpdateSleepSleeponminimize(CCmdUI* pCmdUI); | ||
155 | afx_msg void OnSleepSleeponminimize(); | ||
156 | afx_msg void OnUpdateSleepWakeupactionMakesound(CCmdUI* pCmdUI); | ||
157 | afx_msg void OnSleepWakeupactionMakesound(); | ||
158 | afx_msg void OnUpdateSleepWakeupactionPopup(CCmdUI* pCmdUI); | ||
159 | afx_msg void OnSleepWakeupactionPopup(); | ||
160 | afx_msg void OnUpdateSleepMinimizeonsleep(CCmdUI* pCmdUI); | ||
161 | afx_msg void OnSleepMinimizeonsleep(); | ||
162 | afx_msg void OnTalkClose(); | ||
163 | //}}AFX_MSG | ||
164 | DECLARE_MESSAGE_MAP() | ||
165 | private: | ||
166 | BOOL InitStatusBar(UINT *pIndicators, int nSize, int nSeconds); | ||
167 | }; | ||
168 | |||
169 | ///////////////////////////////////////////////////////////////////////////// | ||
diff --git a/T42Secretary.cpp b/T42Secretary.cpp new file mode 100644 index 0000000..62cef87 --- a/dev/null +++ b/T42Secretary.cpp | |||
@@ -0,0 +1,121 @@ | |||
1 | // T42Secretary.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "T42Document.h" | ||
7 | #include "T42Secretary.h" | ||
8 | |||
9 | #include "T42View.h" | ||
10 | #include "T42Frame.h" | ||
11 | |||
12 | CT42Secretary::CT42Secretary() | ||
13 | { | ||
14 | m_logEntry.m_Time = CTime::GetCurrentTime(); | ||
15 | CT42App* app = (CT42App*)AfxGetApp(); | ||
16 | app->m_T42LinesBusy++; | ||
17 | m_limitTime = app->m_T42STimeLimit; | ||
18 | m_limitBytes = app->m_T42SBytesLimit; | ||
19 | TRACE0("Secretary++\n"); | ||
20 | } | ||
21 | |||
22 | CT42Secretary::~CT42Secretary() | ||
23 | { | ||
24 | CT42App* app = (CT42App*)AfxGetApp(); | ||
25 | app->m_T42LinesBusy--; | ||
26 | TRACE0("Secretary--\n"); | ||
27 | } | ||
28 | |||
29 | |||
30 | BOOL CT42Secretary::OnAttach(T42Document* pDocument) | ||
31 | { | ||
32 | TRACE0("T42S - OnAttach\n"); | ||
33 | return CT42Robot::OnAttach(pDocument); | ||
34 | } | ||
35 | |||
36 | BOOL CT42Secretary::OnConnect() | ||
37 | { | ||
38 | m_logEntry.m_Caller = m_pDocument->m_pView->m_pFrame->m_Target; | ||
39 | m_logEntry.m_Callee = m_pDocument->m_pView->m_pFrame->m_LocalUser; | ||
40 | m_logEntry.m_Message.Empty(); | ||
41 | m_logEntry.m_Time = CTime::GetCurrentTime(); | ||
42 | |||
43 | CT42App* app = (CT42App*)AfxGetApp(); | ||
44 | CString greet = app->m_T42SGreeting; | ||
45 | int ix; | ||
46 | while((ix=greet.Find("%t"))>=0){ | ||
47 | CString tmp; | ||
48 | tmp.Format("%lu",app->m_T42STimeLimit.GetTotalSeconds()/60); | ||
49 | greet = greet.Left(ix)+tmp+greet.Mid(ix+2); | ||
50 | } | ||
51 | while((ix=greet.Find("%c"))>=0){ | ||
52 | CString tmp; | ||
53 | tmp.Format("%u",app->m_T42SBytesLimit); | ||
54 | greet = greet.Left(ix)+tmp+greet.Mid(ix+2); | ||
55 | } | ||
56 | m_pDocument->SendOver(greet); | ||
57 | return TRUE; | ||
58 | } | ||
59 | |||
60 | BOOL CT42Secretary::OnReceive(char* pData,int nBytes) | ||
61 | { | ||
62 | if(m_limitBytes && m_pDocument->m_pView->m_remoteCtl.GetTextLength()>=m_limitBytes) | ||
63 | OnDisconnect(); | ||
64 | return TRUE; | ||
65 | } | ||
66 | |||
67 | BOOL CT42Secretary::OnDisconnect() | ||
68 | { | ||
69 | m_logEntry.m_Duration = CTime::GetCurrentTime()-m_logEntry.m_Time; | ||
70 | EDITSTREAM es; | ||
71 | memset(&es,0,sizeof(es)); | ||
72 | es.dwCookie = (DWORD)&m_logEntry.m_Message; | ||
73 | es.pfnCallback = ESINProc; | ||
74 | m_pDocument->m_pView->m_remoteCtl.StreamOut(SF_RTF,es); | ||
75 | m_logEntry.m_Status = CT42CallLogEntry::statusOk; | ||
76 | CT42App* app = (CT42App*)AfxGetApp(); | ||
77 | VERIFY(app->AddT42Call(m_logEntry)); | ||
78 | m_pDocument->m_pView->m_pFrame->OnTalkClose(); | ||
79 | return TRUE; | ||
80 | } | ||
81 | |||
82 | BOOL CT42Secretary::OnDetach() | ||
83 | { | ||
84 | TRACE0("T42S - OnDetach\n"); | ||
85 | delete this; | ||
86 | return TRUE; | ||
87 | } | ||
88 | |||
89 | |||
90 | BOOL CT42Secretary::OnIPResolved() | ||
91 | { | ||
92 | m_logEntry.m_Caller = m_pDocument->m_pView->m_pFrame->m_Target; | ||
93 | return TRUE; | ||
94 | } | ||
95 | |||
96 | DWORD CALLBACK CT42Secretary::ESINProc(DWORD dwCookie,LPBYTE pbBuff,LONG cb,LONG FAR *pcb) | ||
97 | { | ||
98 | CString* str = (CString*)dwCookie; | ||
99 | if(memchr(pbBuff,0,cb-1)){ | ||
100 | (*pcb) = 0; | ||
101 | return 1; | ||
102 | } | ||
103 | UINT p = str->GetLength(); | ||
104 | CHAR* s = str->GetBuffer(p+cb+1); | ||
105 | memmove(&s[p],pbBuff,cb); | ||
106 | s[p+cb]=0; | ||
107 | str->ReleaseBuffer(); | ||
108 | (*pcb)=cb; | ||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | BOOL CT42Secretary::OnMinute() | ||
113 | { | ||
114 | if( | ||
115 | m_limitTime.GetTotalSeconds() && | ||
116 | (CTime::GetCurrentTime()-m_logEntry.m_Time)>=m_limitTime | ||
117 | ) | ||
118 | OnDisconnect(); | ||
119 | return TRUE; | ||
120 | } | ||
121 | |||
diff --git a/T42Secretary.h b/T42Secretary.h new file mode 100644 index 0000000..97d1440 --- a/dev/null +++ b/T42Secretary.h | |||
@@ -0,0 +1,17 @@ | |||
1 | class CT42Secretary : public CT42Robot{ | ||
2 | public: | ||
3 | virtual ~CT42Secretary(); | ||
4 | BOOL OnMinute(); | ||
5 | UINT m_limitBytes; | ||
6 | CTimeSpan m_limitTime; | ||
7 | static DWORD CALLBACK ESINProc(DWORD dwCookie,LPBYTE pbBuff,LONG cb,LONG FAR *pcb); | ||
8 | BOOL OnIPResolved(); | ||
9 | CT42Secretary(); | ||
10 | CT42CallLogEntry m_logEntry; | ||
11 | BOOL OnDetach(); | ||
12 | BOOL OnDisconnect(); | ||
13 | BOOL OnReceive(char* pData,int nBytes); | ||
14 | BOOL OnConnect(); | ||
15 | BOOL OnAttach(T42Document* pDocument); | ||
16 | }; | ||
17 | |||
diff --git a/T42View.cpp b/T42View.cpp new file mode 100644 index 0000000..8ccad1c --- a/dev/null +++ b/T42View.cpp | |||
@@ -0,0 +1,703 @@ | |||
1 | // T42View.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "T42.h" | ||
6 | #include "T42View.h" | ||
7 | |||
8 | #include "T42Frame.h" | ||
9 | |||
10 | #ifdef _DEBUG | ||
11 | #define new DEBUG_NEW | ||
12 | #undef THIS_FILE | ||
13 | static char THIS_FILE[] = __FILE__; | ||
14 | #endif | ||
15 | |||
16 | ///////////////////////////////////////////////////////////////////////////// | ||
17 | // T42View | ||
18 | |||
19 | IMPLEMENT_DYNCREATE(T42View, CFormView) | ||
20 | |||
21 | T42View::T42View() | ||
22 | : CFormView(T42View::IDD) | ||
23 | { | ||
24 | //{{AFX_DATA_INIT(T42View) | ||
25 | //}}AFX_DATA_INIT | ||
26 | m_localCtl.m_pView = m_remoteCtl.m_pView = this; | ||
27 | m_pFrame = NULL; | ||
28 | m_localSize = 50; | ||
29 | m_remoteSize = 50; | ||
30 | m_gapSize = 5; | ||
31 | m_Ort = ortHorizontal; | ||
32 | m_bShown = FALSE; | ||
33 | m_bTracking = FALSE; | ||
34 | m_hHorzCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZENS); | ||
35 | m_hVertCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE); | ||
36 | m_bEnabled = FALSE; | ||
37 | } | ||
38 | |||
39 | T42View::~T42View() | ||
40 | { | ||
41 | } | ||
42 | |||
43 | void T42View::DoDataExchange(CDataExchange* pDX) | ||
44 | { | ||
45 | CFormView::DoDataExchange(pDX); | ||
46 | //{{AFX_DATA_MAP(T42View) | ||
47 | DDX_Control(pDX, IDC_SPLIT, m_splitCtl); | ||
48 | //}}AFX_DATA_MAP | ||
49 | } | ||
50 | |||
51 | |||
52 | BEGIN_MESSAGE_MAP(T42View, CFormView) | ||
53 | //{{AFX_MSG_MAP(T42View) | ||
54 | ON_WM_SIZE() | ||
55 | ON_MESSAGE(WM_SPLITTERBDOWN, OnSplitterBDown) | ||
56 | ON_WM_MOUSEMOVE() | ||
57 | ON_WM_LBUTTONUP() | ||
58 | ON_WM_SETCURSOR() | ||
59 | ON_COMMAND(ID_WINDOW_SPLITEQUALLY, OnWindowSplitequally) | ||
60 | ON_UPDATE_COMMAND_UI(ID_WINDOW_HORIZONTALSPLIT, OnUpdateWindowHorizontalsplit) | ||
61 | ON_UPDATE_COMMAND_UI(ID_WINDOW_VERTICALSPLIT, OnUpdateWindowVerticalsplit) | ||
62 | ON_COMMAND(ID_WINDOW_HORIZONTALSPLIT, OnWindowHorizontalsplit) | ||
63 | ON_COMMAND(ID_WINDOW_VERTICALSPLIT, OnWindowVerticalsplit) | ||
64 | ON_COMMAND(ID_EDIT_COPY, OnEditCopy) | ||
65 | ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) | ||
66 | ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste) | ||
67 | ON_WM_CANCELMODE() | ||
68 | ON_UPDATE_COMMAND_UI(ID_TEA_SAVE, OnUpdateTeaSave) | ||
69 | ON_COMMAND(ID_TEA_SAVE, OnTeaSave) | ||
70 | //}}AFX_MSG_MAP | ||
71 | END_MESSAGE_MAP() | ||
72 | |||
73 | ///////////////////////////////////////////////////////////////////////////// | ||
74 | // T42View diagnostics | ||
75 | |||
76 | #ifdef _DEBUG | ||
77 | void T42View::AssertValid() const | ||
78 | { | ||
79 | CFormView::AssertValid(); | ||
80 | } | ||
81 | |||
82 | void T42View::Dump(CDumpContext& dc) const | ||
83 | { | ||
84 | CFormView::Dump(dc); | ||
85 | } | ||
86 | #endif //_DEBUG | ||
87 | |||
88 | ///////////////////////////////////////////////////////////////////////////// | ||
89 | // T42View message handlers | ||
90 | ///////////////////////////////////////////////////////////////////////////// | ||
91 | // CSplitBar | ||
92 | |||
93 | CSplitBar::CSplitBar() | ||
94 | { | ||
95 | } | ||
96 | |||
97 | CSplitBar::~CSplitBar() | ||
98 | { | ||
99 | } | ||
100 | |||
101 | |||
102 | BEGIN_MESSAGE_MAP(CSplitBar, CStatic) | ||
103 | //{{AFX_MSG_MAP(CSplitBar) | ||
104 | ON_WM_LBUTTONDOWN() | ||
105 | ON_WM_PAINT() | ||
106 | //}}AFX_MSG_MAP | ||
107 | END_MESSAGE_MAP() | ||
108 | |||
109 | ///////////////////////////////////////////////////////////////////////////// | ||
110 | // CSplitBar message handlers | ||
111 | |||
112 | void CSplitBar::OnLButtonDown(UINT nFlags, CPoint point) | ||
113 | { | ||
114 | GetParent()->PostMessage(WM_SPLITTERBDOWN); | ||
115 | } | ||
116 | |||
117 | void CSplitBar::OnPaint() | ||
118 | { | ||
119 | CPaintDC dc(this); // device context for painting | ||
120 | CRect rc; | ||
121 | GetWindowRect(rc); | ||
122 | ScreenToClient(rc); | ||
123 | dc.DrawEdge(rc,EDGE_RAISED,(m_Ort==T42View::ortVertical)?BF_LEFT|BF_RIGHT:BF_TOP|BF_BOTTOM); | ||
124 | } | ||
125 | |||
126 | void T42View::OnInitialUpdate() | ||
127 | { | ||
128 | CFormView::OnInitialUpdate(); | ||
129 | m_pFrame = (T42Frame*)GetParent(); | ||
130 | ASSERT_KINDOF(T42Frame,m_pFrame); | ||
131 | SetScaleToFitSize(CSize(10,10)); | ||
132 | |||
133 | m_localCtl.Create(WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_LEFT|ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL, | ||
134 | CRect(0,0,0,0), this, 0); | ||
135 | m_remoteCtl.Create(WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_LEFT|ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL, | ||
136 | CRect(0,0,0,0), this, 0); | ||
137 | m_localCtl.SetFocus(); | ||
138 | m_localCtl.m_pInTEC = &m_pFrame->m_localEC; | ||
139 | m_localCtl.m_pOuTEC = &m_pFrame->m_remoteEC; | ||
140 | m_remoteCtl.m_pInTEC = &m_pFrame->m_remoteEC; | ||
141 | m_remoteCtl.m_pOuTEC = &m_pFrame->m_localEC; | ||
142 | |||
143 | |||
144 | LoadLayout(); | ||
145 | |||
146 | RecalcLayout(); | ||
147 | m_bShown=TRUE; | ||
148 | } | ||
149 | |||
150 | void T42View::RecalcLayout() | ||
151 | { | ||
152 | UINT lrs = m_localSize+m_remoteSize; | ||
153 | m_splitCtl.m_Ort = m_Ort; | ||
154 | CRect crc; | ||
155 | GetClientRect(crc); | ||
156 | CRect rc; | ||
157 | UINT ls = m_localSize, rs = m_remoteSize; | ||
158 | if(m_Ort==ortHorizontal){ | ||
159 | UINT lr = crc.Height()-m_gapSize; | ||
160 | rc.top = rc.left = 0; | ||
161 | rc.right = crc.right; | ||
162 | |||
163 | ls = lr*m_localSize/lrs; | ||
164 | rc.bottom = ls; | ||
165 | m_localCtl.MoveWindow(rc); | ||
166 | |||
167 | rc.top=rc.bottom+1; | ||
168 | rc.bottom=rc.top+m_gapSize-1; | ||
169 | m_splitCtl.MoveWindow(rc); | ||
170 | |||
171 | rc.top=rc.bottom+1; | ||
172 | rc.bottom=crc.bottom; | ||
173 | rs = rc.Height(); | ||
174 | m_remoteCtl.MoveWindow(rc); | ||
175 | }else if(m_Ort==ortVertical){ | ||
176 | CRect crc; | ||
177 | GetClientRect(crc); | ||
178 | CRect rc; | ||
179 | UINT lr = crc.Width()-m_gapSize; | ||
180 | rc.top = rc.left = 0; | ||
181 | rc.bottom = crc.bottom; | ||
182 | |||
183 | ls = lr*m_localSize/lrs; | ||
184 | rc.right = ls; | ||
185 | m_localCtl.MoveWindow(rc); | ||
186 | |||
187 | rc.left=rc.right+1; | ||
188 | rc.right=rc.left+m_gapSize-1; | ||
189 | m_splitCtl.MoveWindow(rc); | ||
190 | |||
191 | rc.left=rc.right+1; | ||
192 | rc.right=crc.right; | ||
193 | rs = rc.Width(); | ||
194 | m_remoteCtl.MoveWindow(rc); | ||
195 | }else | ||
196 | ASSERT(FALSE); | ||
197 | m_localSize = ls; m_remoteSize = rs; | ||
198 | } | ||
199 | |||
200 | void T42View::OnSize(UINT nType, int cx, int cy) | ||
201 | { | ||
202 | CFormView::OnSize(nType, cx, cy); | ||
203 | if(m_bShown) | ||
204 | RecalcLayout(); | ||
205 | } | ||
206 | |||
207 | LRESULT T42View::OnSplitterBDown(WPARAM,LPARAM) | ||
208 | { | ||
209 | SetCapture(); | ||
210 | m_bTracking = TRUE; | ||
211 | CRect rc; | ||
212 | GetClientRect(rc); | ||
213 | if(m_Ort==ortHorizontal){ | ||
214 | ASSERT(rc.Height()>25); | ||
215 | rc.top+=10; | ||
216 | rc.bottom-=10; | ||
217 | }else{ | ||
218 | ASSERT(rc.Width()>25); | ||
219 | rc.left+=10; | ||
220 | rc.right-=10; | ||
221 | } | ||
222 | ClientToScreen(rc); | ||
223 | ClipCursor(&rc); | ||
224 | return 0; | ||
225 | } | ||
226 | |||
227 | void T42View::OnMouseMove(UINT nFlags, CPoint point) | ||
228 | { | ||
229 | if(m_bTracking){ | ||
230 | CRect rc; | ||
231 | GetClientRect(rc); | ||
232 | if(m_Ort==ortHorizontal){ | ||
233 | m_localSize = point.y; | ||
234 | m_remoteSize = rc.bottom-point.y; | ||
235 | }else{ | ||
236 | m_localSize = point.x; | ||
237 | m_remoteSize = rc.right-point.x; | ||
238 | } | ||
239 | RecalcLayout(); | ||
240 | } | ||
241 | |||
242 | CFormView::OnMouseMove(nFlags, point); | ||
243 | } | ||
244 | |||
245 | void T42View::OnLButtonUp(UINT nFlags, CPoint point) | ||
246 | { | ||
247 | if(m_bTracking){ | ||
248 | ClipCursor(NULL); | ||
249 | m_bTracking=FALSE; | ||
250 | ReleaseCapture(); | ||
251 | } | ||
252 | CFormView::OnLButtonUp(nFlags, point); | ||
253 | } | ||
254 | ///////////////////////////////////////////////////////////////////////////// | ||
255 | // CLocalCtl | ||
256 | |||
257 | CLocalCtl::CLocalCtl() | ||
258 | { | ||
259 | CT42App* app = (CT42App*)AfxGetApp(); | ||
260 | m_bgColor = app->m_crT42LocalBG; | ||
261 | memmove(&m_fmtUser,&app->m_fmtT42Local,sizeof(m_fmtUser)); | ||
262 | memmove(&m_fmtSystem,&app->m_fmtT42System,sizeof(m_fmtSystem)); | ||
263 | } | ||
264 | |||
265 | CLocalCtl::~CLocalCtl() | ||
266 | { | ||
267 | } | ||
268 | |||
269 | |||
270 | BEGIN_MESSAGE_MAP(CLocalCtl, CRichTalkCtl) | ||
271 | //{{AFX_MSG_MAP(CLocalCtl) | ||
272 | ON_WM_CREATE() | ||
273 | ON_WM_CHAR() | ||
274 | ON_WM_KEYDOWN() | ||
275 | //}}AFX_MSG_MAP | ||
276 | END_MESSAGE_MAP() | ||
277 | |||
278 | ///////////////////////////////////////////////////////////////////////////// | ||
279 | // CLocalCtl message handlers | ||
280 | ///////////////////////////////////////////////////////////////////////////// | ||
281 | // CRemoteCtl | ||
282 | |||
283 | CRemoteCtl::CRemoteCtl() | ||
284 | { | ||
285 | CT42App* app = (CT42App*)AfxGetApp(); | ||
286 | m_bgColor = app->m_crT42RemoteBG; | ||
287 | memmove(&m_fmtUser,&app->m_fmtT42Remote,sizeof(m_fmtUser)); | ||
288 | memmove(&m_fmtSystem,&app->m_fmtT42System,sizeof(m_fmtSystem)); | ||
289 | } | ||
290 | |||
291 | CRemoteCtl::~CRemoteCtl() | ||
292 | { | ||
293 | } | ||
294 | |||
295 | |||
296 | BEGIN_MESSAGE_MAP(CRemoteCtl, CRichTalkCtl) | ||
297 | //{{AFX_MSG_MAP(CRemoteCtl) | ||
298 | ON_WM_CREATE() | ||
299 | ON_WM_CHAR() | ||
300 | ON_WM_KEYDOWN() | ||
301 | //}}AFX_MSG_MAP | ||
302 | END_MESSAGE_MAP() | ||
303 | |||
304 | ///////////////////////////////////////////////////////////////////////////// | ||
305 | // CRemoteCtl message handlers | ||
306 | |||
307 | void CRichTalkCtl::Setup() | ||
308 | { | ||
309 | ModifyStyle(0,WS_VSCROLL); | ||
310 | SetOptions(ECOOP_SET,ECO_AUTOWORDSELECTION|ECO_AUTOVSCROLL|ECO_READONLY| | ||
311 | ECO_WANTRETURN|ECO_SAVESEL|ECO_SELECTIONBAR|ECO_NOHIDESEL); | ||
312 | SetTargetDevice(NULL,0); | ||
313 | SetSel(0,-1); | ||
314 | PARAFORMAT pf; | ||
315 | memset(&pf,0,sizeof(pf)); | ||
316 | pf.cbSize = sizeof(pf); | ||
317 | pf.dwMask = PFM_OFFSET; | ||
318 | pf.dxOffset = 20; | ||
319 | SetParaFormat(pf); | ||
320 | SetDefaultCharFormat(m_fmtUser); | ||
321 | SetSelectionCharFormat(m_fmtUser); | ||
322 | SetSel(-1,-1); | ||
323 | SetColor(); | ||
324 | } | ||
325 | |||
326 | int CRemoteCtl::OnCreate(LPCREATESTRUCT lpCreateStruct) | ||
327 | { | ||
328 | if (CRichEditCtrl::OnCreate(lpCreateStruct) == -1) | ||
329 | return -1; | ||
330 | Setup(); | ||
331 | return 0; | ||
332 | } | ||
333 | |||
334 | int CLocalCtl::OnCreate(LPCREATESTRUCT lpCreateStruct) | ||
335 | { | ||
336 | if (CRichEditCtrl::OnCreate(lpCreateStruct) == -1) | ||
337 | return -1; | ||
338 | Setup(); | ||
339 | return 0; | ||
340 | } | ||
341 | |||
342 | void CLocalCtl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) | ||
343 | { | ||
344 | if(!m_pView->m_bEnabled) | ||
345 | return; | ||
346 | if(!(nFlags&0x8000)){ | ||
347 | ASSERT(m_pView && m_pView->m_pFrame); | ||
348 | if(nChar=='\r') | ||
349 | nChar='\n'; | ||
350 | UINT c = nChar; | ||
351 | if(c=='\b') | ||
352 | c=m_pOuTEC->m_cErase; | ||
353 | m_pView->m_pFrame->PostMessage(WM_TALKCHAR,c); | ||
354 | PutCharacter(nChar); | ||
355 | } | ||
356 | } | ||
357 | |||
358 | void CRemoteCtl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) | ||
359 | { | ||
360 | if(!m_pView->m_bEnabled) | ||
361 | return; | ||
362 | if(!(nFlags&0x8000)){ | ||
363 | ASSERT(m_pView && m_pView->m_pFrame); | ||
364 | if(nChar=='\r') | ||
365 | nChar='\n'; | ||
366 | UINT c = nChar; | ||
367 | if(c=='\b') | ||
368 | c=m_pOuTEC->m_cErase; | ||
369 | m_pView->m_pFrame->PostMessage(WM_TALKCHAR,c); | ||
370 | m_pView->m_localCtl.SetFocus(); | ||
371 | m_pView->m_localCtl.PutCharacter(nChar); | ||
372 | } | ||
373 | } | ||
374 | |||
375 | void CRichTalkCtl::PutString(LPCTSTR str) | ||
376 | { | ||
377 | CString s = str; | ||
378 | CHAR span[] = { '\r','\n','\a','\b',m_pInTEC->m_cErase,0 }; | ||
379 | CString sss; | ||
380 | while(!s.IsEmpty()){ | ||
381 | sss=s.SpanExcluding(span); | ||
382 | if(!sss.IsEmpty()){ | ||
383 | BOOL bDo = !GetTextLength(); | ||
384 | SetSel(-1,-1); | ||
385 | long ss,es; | ||
386 | if(bDo) | ||
387 | GetSel(ss,es); | ||
388 | ReplaceSel(sss); | ||
389 | if(bDo){ | ||
390 | SetSel(ss,-1); | ||
391 | SetSelectionCharFormat(m_fmtUser); | ||
392 | SetSel(-1,-1); | ||
393 | } | ||
394 | s = s.Mid(sss.GetLength()); | ||
395 | } | ||
396 | if(!s.IsEmpty()){ | ||
397 | PutCharacter(s[0]); | ||
398 | s=s.Mid(1); | ||
399 | } | ||
400 | } | ||
401 | UnlockWindowUpdate(); | ||
402 | } | ||
403 | |||
404 | void CRichTalkCtl::PutCharacter(CHAR c) | ||
405 | { | ||
406 | if(c=='\r') | ||
407 | return; | ||
408 | if(c=='\a'){ | ||
409 | CT42App* app = (CT42App*)AfxGetApp(); | ||
410 | ASSERT(app); | ||
411 | app->StartSound(app->m_sndT42Bell); | ||
412 | return; | ||
413 | }else if(c=='\b' || c==m_pInTEC->m_cErase){ | ||
414 | SetSel(-1,-1); | ||
415 | CHARRANGE cr; | ||
416 | GetSel(cr); | ||
417 | if(cr.cpMin>0){ | ||
418 | cr.cpMin--; | ||
419 | SetSel(cr); | ||
420 | ReplaceSel(""); | ||
421 | }else | ||
422 | MessageBeep(0xFFFFFFFF); | ||
423 | return; | ||
424 | } | ||
425 | BOOL bDo = !GetTextLength(); | ||
426 | SetSel(-1,-1); | ||
427 | char tmp[2] = {c,0}; | ||
428 | long ss,es; | ||
429 | if(bDo) | ||
430 | GetSel(ss,es); | ||
431 | ReplaceSel(tmp); | ||
432 | if(bDo){ | ||
433 | SetSel(ss,-1); | ||
434 | SetSelectionCharFormat(m_fmtUser); | ||
435 | SetSel(-1,-1); | ||
436 | } | ||
437 | UnlockWindowUpdate(); | ||
438 | } | ||
439 | |||
440 | void CRichTalkCtl::SystemMessage(LPCTSTR str) | ||
441 | { | ||
442 | SetSel(-1,-1); | ||
443 | |||
444 | if( | ||
445 | GetTextLength() | ||
446 | && LineLength() | ||
447 | ) | ||
448 | ReplaceSel("\n"); | ||
449 | |||
450 | CString tmp = "["; | ||
451 | tmp+=str; | ||
452 | tmp+=']'; | ||
453 | long ss,es; | ||
454 | GetSel(ss,es); | ||
455 | ReplaceSel(tmp); | ||
456 | SetSel(ss,-1); | ||
457 | SetSelectionCharFormat(m_fmtSystem); | ||
458 | SetSel(-1,-1); | ||
459 | GetSel(ss,es); | ||
460 | ReplaceSel("\n"); | ||
461 | SetSel(ss,-1); | ||
462 | SetSelectionCharFormat(m_fmtUser); | ||
463 | SetSel(-1,-1); | ||
464 | UnlockWindowUpdate(); | ||
465 | } | ||
466 | |||
467 | BOOL T42View::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) | ||
468 | { | ||
469 | BOOL rv = CFormView::OnSetCursor(pWnd, nHitTest, message); | ||
470 | if(rv) | ||
471 | return rv; | ||
472 | if(pWnd==&m_splitCtl){ | ||
473 | if(m_Ort==ortVertical){ | ||
474 | SetCursor(m_hVertCursor); | ||
475 | }else{ | ||
476 | SetCursor(m_hHorzCursor); | ||
477 | } | ||
478 | return TRUE; | ||
479 | } | ||
480 | return FALSE; | ||
481 | } | ||
482 | |||
483 | void CLocalCtl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) | ||
484 | { | ||
485 | CRichTalkCtl::OnKeyDown(nChar, nRepCnt, nFlags); | ||
486 | } | ||
487 | |||
488 | void CRichTalkCtl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) | ||
489 | { | ||
490 | switch(nChar){ | ||
491 | caseVK_INSERT: | ||
492 | caseVK_DELETE: | ||
493 | caseVK_BACK: | ||
494 | caseVK_ESCAPE: | ||
495 | return; | ||
496 | } | ||
497 | CRichEditCtrl::OnKeyDown(nChar, nRepCnt, nFlags); | ||
498 | } | ||
499 | |||
500 | void CRemoteCtl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) | ||
501 | { | ||
502 | CRichTalkCtl::OnKeyDown(nChar, nRepCnt, nFlags); | ||
503 | } | ||
504 | |||
505 | void T42View::OnWindowSplitequally() | ||
506 | { | ||
507 | m_localSize = m_remoteSize = 50; | ||
508 | RecalcLayout(); | ||
509 | } | ||
510 | |||
511 | void T42View::OnUpdateWindowHorizontalsplit(CCmdUI* pCmdUI) | ||
512 | { | ||
513 | pCmdUI->SetRadio(m_Ort==ortHorizontal); | ||
514 | } | ||
515 | |||
516 | void T42View::OnUpdateWindowVerticalsplit(CCmdUI* pCmdUI) | ||
517 | { | ||
518 | pCmdUI->SetRadio(m_Ort==ortVertical); | ||
519 | } | ||
520 | |||
521 | void T42View::OnWindowHorizontalsplit() | ||
522 | { | ||
523 | m_Ort = ortHorizontal; | ||
524 | RecalcLayout(); | ||
525 | } | ||
526 | |||
527 | void T42View::OnWindowVerticalsplit() | ||
528 | { | ||
529 | m_Ort = ortVertical; | ||
530 | RecalcLayout(); | ||
531 | } | ||
532 | |||
533 | |||
534 | void T42View::SetEnable(BOOL bEnable) | ||
535 | { | ||
536 | m_bEnabled = bEnable; | ||
537 | m_localCtl.SetColor(); | ||
538 | m_remoteCtl.SetColor(); | ||
539 | } | ||
540 | |||
541 | void CRichTalkCtl::SetColor() | ||
542 | { | ||
543 | if(m_pView->m_bEnabled) | ||
544 | SetBackgroundColor(FALSE,m_bgColor); | ||
545 | else{ | ||
546 | SetBackgroundColor( | ||
547 | FALSE, | ||
548 | RGB( | ||
549 | GetRValue(m_bgColor)/2, | ||
550 | GetGValue(m_bgColor)/2, | ||
551 | GetBValue(m_bgColor)/2 | ||
552 | ) | ||
553 | ); | ||
554 | } | ||
555 | } | ||
556 | |||
557 | void T42View::OnEditCopy() | ||
558 | { | ||
559 | CWnd* pWnd = GetFocus(); | ||
560 | if(pWnd==&m_localCtl) | ||
561 | m_localCtl.Copy(); | ||
562 | else if(pWnd==&m_remoteCtl) | ||
563 | m_remoteCtl.Copy(); | ||
564 | else | ||
565 | MessageBeep(MB_OK); | ||
566 | } | ||
567 | |||
568 | void T42View::OnEditPaste() | ||
569 | { | ||
570 | ASSERT(m_pFrame); | ||
571 | if(!m_bEnabled) | ||
572 | return; | ||
573 | if(!IsClipboardFormatAvailable(CF_TEXT)) | ||
574 | return; | ||
575 | if(!OpenClipboard()) | ||
576 | return; | ||
577 | HANDLE h = GetClipboardData(CF_TEXT); | ||
578 | LPVOID gl = GlobalLock(h); | ||
579 | ASSERT(gl); | ||
580 | m_pFrame->SendMessage(WM_TALKCHAR,0,(LPARAM)gl); | ||
581 | m_localCtl.PutString((LPCTSTR)gl); | ||
582 | GlobalUnlock(h); | ||
583 | CloseClipboard(); | ||
584 | } | ||
585 | |||
586 | void T42View::OnUpdateEditPaste(CCmdUI* pCmdUI) | ||
587 | { | ||
588 | pCmdUI->Enable(m_bEnabled && IsClipboardFormatAvailable(CF_TEXT)); | ||
589 | } | ||
590 | |||
591 | void T42View::SaveLayout() | ||
592 | { | ||
593 | CWinApp* app = AfxGetApp(); | ||
594 | app->WriteProfileInt("T42View","LocalSize",m_localSize); | ||
595 | app->WriteProfileInt("T42View","RemoteSize",m_remoteSize); | ||
596 | app->WriteProfileInt("T42View","Orientation",m_Ort); | ||
597 | } | ||
598 | |||
599 | void T42View::OnCancelMode() | ||
600 | { | ||
601 | CFormView::OnCancelMode(); | ||
602 | if(m_bTracking){ | ||
603 | ClipCursor(NULL); | ||
604 | m_bTracking=FALSE; | ||
605 | ReleaseCapture(); | ||
606 | } | ||
607 | } | ||
608 | |||
609 | void T42View::LoadLayout() | ||
610 | { | ||
611 | CWinApp* app = AfxGetApp(); | ||
612 | m_localSize = app->GetProfileInt("T42View","LocalSize",m_localSize); | ||
613 | m_remoteSize = app->GetProfileInt("T42View","RemoteSize",m_remoteSize); | ||
614 | _orientation ortSave = m_Ort; | ||
615 | m_Ort = (_orientation)app->GetProfileInt("T42View","Orientation",m_Ort); | ||
616 | if(m_Ort!=ortHorizontal && m_Ort!=ortVertical) | ||
617 | m_Ort=ortSave; | ||
618 | } | ||
619 | |||
620 | void T42View::SystemMessage(LPCTSTR str) | ||
621 | { | ||
622 | CT42App* app = (CT42App*)AfxGetApp(); | ||
623 | m_localCtl.SystemMessage(str); | ||
624 | m_remoteCtl.SystemMessage(str); | ||
625 | } | ||
626 | |||
627 | |||
628 | void T42View::OnUpdateTeaSave(CCmdUI* pCmdUI) | ||
629 | { | ||
630 | pCmdUI->Enable(m_localCtl.GetTextLength() || m_remoteCtl.GetTextLength()); | ||
631 | } | ||
632 | |||
633 | void T42View::OnTeaSave() | ||
634 | { | ||
635 | CString dfn; | ||
636 | dfn.Format(IDS_FILENAME_T42,m_pFrame->m_LocalUser,m_pFrame->m_Target); | ||
637 | CString filter; | ||
638 | VERIFY(filter.LoadString(IDS_FILTER_RTF)); | ||
639 | CFileDialog fd(FALSE,".rtf",dfn, | ||
640 | OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_EXPLORER| | ||
641 | OFN_LONGNAMES|OFN_NOREADONLYRETURN|OFN_PATHMUSTEXIST, | ||
642 | filter,this | ||
643 | ); | ||
644 | if(fd.DoModal()==IDOK){ | ||
645 | try{ | ||
646 | CStdioFile f(fd.GetPathName(), | ||
647 | CFile::modeCreate|CFile::modeWrite|CFile::shareDenyWrite| | ||
648 | CFile::typeText); | ||
649 | CString rtf; | ||
650 | rtf.Format(IDS_RTF_HEAD,m_pFrame->m_LocalUser,m_pFrame->m_Target); | ||
651 | f.WriteString(rtf); | ||
652 | CMemFile mf(2048); | ||
653 | EDITSTREAM es; | ||
654 | memset(&es,0,sizeof(es)); | ||
655 | es.dwCookie = (DWORD)&mf; | ||
656 | es.pfnCallback = ESINProc; | ||
657 | m_localCtl.StreamOut(SF_RTF,es); | ||
658 | UINT tmp=0; | ||
659 | mf.Write(&tmp,1); | ||
660 | LONG bytes = mf.GetLength(); | ||
661 | LPBYTE pd = mf.Detach(); | ||
662 | LPTSTR str; | ||
663 | while(str = strstr((LPCTSTR)pd,"\\rtf1"))memmove(str,&str[5],strlen(str)-4); | ||
664 | while(str = strstr((LPCTSTR)pd,"\\pard"))memmove(str,&str[5],strlen(str)-4); | ||
665 | f.Write(pd,strlen((LPCTSTR)pd)); | ||
666 | rtf.LoadString(IDS_RTF_DELIMITER); | ||
667 | f.WriteString(rtf); | ||
668 | mf.Attach(pd,bytes,2048); | ||
669 | memset(&es,0,sizeof(es)); | ||
670 | es.dwCookie = (DWORD)&mf; | ||
671 | es.pfnCallback = ESINProc; | ||
672 | m_remoteCtl.StreamOut(SF_RTF,es); | ||
673 | mf.Write(&tmp,1); | ||
674 | bytes = mf.GetLength(); | ||
675 | pd = mf.Detach(); | ||
676 | while(str = strstr((LPCTSTR)pd,"\\rtf1"))memmove(str,&str[5],strlen(str)-4); | ||
677 | while(str = strstr((LPCTSTR)pd,"\\pard"))memmove(str,&str[5],strlen(str)-4); | ||
678 | f.Write(pd,strlen((LPCTSTR)pd)); | ||
679 | rtf.LoadString(IDS_RTF_TAIL); | ||
680 | f.WriteString(rtf); | ||
681 | delete pd; | ||
682 | f.Close(); | ||
683 | }catch(CException* e){ | ||
684 | TRACE0("Write exception\n"); | ||
685 | e->Delete(); | ||
686 | } | ||
687 | } | ||
688 | } | ||
689 | |||
690 | DWORD CALLBACK T42View::ESINProc(DWORD dwCookie,LPBYTE pbBuff,LONG cb,LONG FAR *pcb) | ||
691 | { | ||
692 | CFile* f = (CFile*)dwCookie; | ||
693 | try{ | ||
694 | f->Write(pbBuff,cb); | ||
695 | (*pcb)=cb; | ||
696 | }catch(CException* e){ | ||
697 | e->Delete(); | ||
698 | TRACE0("Save Exception\n"); | ||
699 | (*pcb)=0; | ||
700 | return 1; | ||
701 | } | ||
702 | return 0; | ||
703 | } | ||
diff --git a/T42View.h b/T42View.h new file mode 100644 index 0000000..f41fb1e --- a/dev/null +++ b/T42View.h | |||
@@ -0,0 +1,220 @@ | |||
1 | // T42View.h : header file | ||
2 | // | ||
3 | |||
4 | class T42View; | ||
5 | class T42Frame; | ||
6 | struct TalkEditChars; | ||
7 | class CRichTalkCtl : public CRichEditCtrl{ | ||
8 | public: | ||
9 | void SystemMessage(LPCTSTR str); | ||
10 | TalkEditChars* m_pInTEC; | ||
11 | TalkEditChars* m_pOuTEC; | ||
12 | T42View* m_pView; | ||
13 | COLORREF m_bgColor; | ||
14 | CHARFORMAT m_fmtSystem; | ||
15 | CHARFORMAT m_fmtUser; | ||
16 | void SetColor(); | ||
17 | void Setup(); | ||
18 | void PutString(LPCTSTR str); | ||
19 | void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); | ||
20 | void PutCharacter(CHAR c); | ||
21 | }; | ||
22 | |||
23 | ///////////////////////////////////////////////////////////////////////////// | ||
24 | // CLocalCtl window | ||
25 | |||
26 | class CLocalCtl : public CRichTalkCtl | ||
27 | { | ||
28 | // Construction | ||
29 | public: | ||
30 | CLocalCtl(); | ||
31 | |||
32 | // Attributes | ||
33 | public: | ||
34 | |||
35 | // Operations | ||
36 | public: | ||
37 | |||
38 | // Overrides | ||
39 | // ClassWizard generated virtual function overrides | ||
40 | //{{AFX_VIRTUAL(CLocalCtl) | ||
41 | //}}AFX_VIRTUAL | ||
42 | |||
43 | // Implementation | ||
44 | public: | ||
45 | virtual ~CLocalCtl(); | ||
46 | |||
47 | // Generated message map functions | ||
48 | protected: | ||
49 | //{{AFX_MSG(CLocalCtl) | ||
50 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); | ||
51 | afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); | ||
52 | afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); | ||
53 | //}}AFX_MSG | ||
54 | |||
55 | DECLARE_MESSAGE_MAP() | ||
56 | }; | ||
57 | |||
58 | ///////////////////////////////////////////////////////////////////////////// | ||
59 | |||
60 | ///////////////////////////////////////////////////////////////////////////// | ||
61 | // CRemoteCtl window | ||
62 | |||
63 | class CRemoteCtl : public CRichTalkCtl | ||
64 | { | ||
65 | // Construction | ||
66 | public: | ||
67 | CRemoteCtl(); | ||
68 | |||
69 | // Attributes | ||
70 | public: | ||
71 | |||
72 | // Operations | ||
73 | public: | ||
74 | |||
75 | // Overrides | ||
76 | // ClassWizard generated virtual function overrides | ||
77 | //{{AFX_VIRTUAL(CRemoteCtl) | ||
78 | //}}AFX_VIRTUAL | ||
79 | |||
80 | // Implementation | ||
81 | public: | ||
82 | virtual ~CRemoteCtl(); | ||
83 | |||
84 | // Generated message map functions | ||
85 | protected: | ||
86 | //{{AFX_MSG(CRemoteCtl) | ||
87 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); | ||
88 | afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); | ||
89 | afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); | ||
90 | //}}AFX_MSG | ||
91 | |||
92 | DECLARE_MESSAGE_MAP() | ||
93 | }; | ||
94 | |||
95 | ///////////////////////////////////////////////////////////////////////////// | ||
96 | |||
97 | ///////////////////////////////////////////////////////////////////////////// | ||
98 | // CSplitBar window | ||
99 | |||
100 | class CSplitBar : public CStatic | ||
101 | { | ||
102 | // Construction | ||
103 | public: | ||
104 | CSplitBar(); | ||
105 | |||
106 | // Attributes | ||
107 | public: | ||
108 | int m_Ort; | ||
109 | |||
110 | // Operations | ||
111 | public: | ||
112 | |||
113 | // Overrides | ||
114 | // ClassWizard generated virtual function overrides | ||
115 | //{{AFX_VIRTUAL(CSplitBar) | ||
116 | //}}AFX_VIRTUAL | ||
117 | |||
118 | // Implementation | ||
119 | public: | ||
120 | virtual ~CSplitBar(); | ||
121 | |||
122 | // Generated message map functions | ||
123 | protected: | ||
124 | //{{AFX_MSG(CSplitBar) | ||
125 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point); | ||
126 | afx_msg void OnPaint(); | ||
127 | //}}AFX_MSG | ||
128 | |||
129 | DECLARE_MESSAGE_MAP() | ||
130 | }; | ||
131 | |||
132 | ///////////////////////////////////////////////////////////////////////////// | ||
133 | |||
134 | ///////////////////////////////////////////////////////////////////////////// | ||
135 | // T42View form view | ||
136 | |||
137 | #ifndef __AFXEXT_H__ | ||
138 | #include <afxext.h> | ||
139 | #endif | ||
140 | |||
141 | class T42View : public CFormView | ||
142 | { | ||
143 | protected: | ||
144 | T42View(); // protected constructor used by dynamic creation | ||
145 | DECLARE_DYNCREATE(T42View) | ||
146 | |||
147 | // Form Data | ||
148 | public: | ||
149 | static DWORD CALLBACK ESINProc(DWORD dwCookie,LPBYTE pbBuff,LONG cb,LONG FAR *pcb); | ||
150 | void SystemMessage(LPCTSTR str); | ||
151 | void LoadLayout(); | ||
152 | void SaveLayout(); | ||
153 | void SetEnable(BOOL bEnable); | ||
154 | BOOL m_bEnabled; | ||
155 | HCURSOR m_hHorzCursor; | ||
156 | HCURSOR m_hVertCursor; | ||
157 | T42Frame* m_pFrame; | ||
158 | BOOL m_bTracking; | ||
159 | BOOL m_bShown; | ||
160 | enum _orientation{ | ||
161 | ortHorizontal, | ||
162 | ortVertical | ||
163 | }m_Ort; | ||
164 | void RecalcLayout(); | ||
165 | UINT m_gapSize; | ||
166 | UINT m_remoteSize; | ||
167 | UINT m_localSize; | ||
168 | CRemoteCtl m_remoteCtl; | ||
169 | CLocalCtl m_localCtl; | ||
170 | //{{AFX_DATA(T42View) | ||
171 | enum { IDD = IDD_T42VIEW }; | ||
172 | CSplitBarm_splitCtl; | ||
173 | //}}AFX_DATA | ||
174 | |||
175 | // Attributes | ||
176 | public: | ||
177 | |||
178 | // Operations | ||
179 | public: | ||
180 | |||
181 | // Overrides | ||
182 | // ClassWizard generated virtual function overrides | ||
183 | //{{AFX_VIRTUAL(T42View) | ||
184 | public: | ||
185 | virtual void OnInitialUpdate(); | ||
186 | protected: | ||
187 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support | ||
188 | //}}AFX_VIRTUAL | ||
189 | |||
190 | // Implementation | ||
191 | protected: | ||
192 | virtual ~T42View(); | ||
193 | #ifdef _DEBUG | ||
194 | virtual void AssertValid() const; | ||
195 | virtual void Dump(CDumpContext& dc) const; | ||
196 | #endif | ||
197 | |||
198 | // Generated message map functions | ||
199 | //{{AFX_MSG(T42View) | ||
200 | afx_msg void OnSize(UINT nType, int cx, int cy); | ||
201 | afx_msg LRESULT OnSplitterBDown(WPARAM,LPARAM); | ||
202 | afx_msg void OnMouseMove(UINT nFlags, CPoint point); | ||
203 | afx_msg void OnLButtonUp(UINT nFlags, CPoint point); | ||
204 | afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); | ||
205 | afx_msg void OnWindowSplitequally(); | ||
206 | afx_msg void OnUpdateWindowHorizontalsplit(CCmdUI* pCmdUI); | ||
207 | afx_msg void OnUpdateWindowVerticalsplit(CCmdUI* pCmdUI); | ||
208 | afx_msg void OnWindowHorizontalsplit(); | ||
209 | afx_msg void OnWindowVerticalsplit(); | ||
210 | afx_msg void OnEditCopy(); | ||
211 | afx_msg void OnEditPaste(); | ||
212 | afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI); | ||
213 | afx_msg void OnCancelMode(); | ||
214 | afx_msg void OnUpdateTeaSave(CCmdUI* pCmdUI); | ||
215 | afx_msg void OnTeaSave(); | ||
216 | //}}AFX_MSG | ||
217 | DECLARE_MESSAGE_MAP() | ||
218 | }; | ||
219 | |||
220 | ///////////////////////////////////////////////////////////////////////////// | ||
diff --git a/help/T42.cnt b/help/T42.cnt new file mode 100644 index 0000000..e30ddb8 --- a/dev/null +++ b/help/T42.cnt | |||
@@ -0,0 +1,16 @@ | |||
1 | :Base T42.hlp>Standard | ||
2 | :Title T42 | ||
3 | 1 T42 | ||
4 | 2 About T42=About | ||
5 | 2 What's New=News | ||
6 | 2 Using T42=Using | ||
7 | 2 Options | ||
8 | 3 T42 Options=Options | ||
9 | 3 General Options=GeneralOptions | ||
10 | 3 Fonts=FontsOptions | ||
11 | 3 Sounds=SoundsOptions | ||
12 | 3 Secretary Options=SecretaryOptions | ||
13 | 2 Windows | ||
14 | 3 Main Window=MainWindow | ||
15 | 3 Conversation Window=ConversationWindow | ||
16 | 3 Announce Dialog=AnnounceDialog | ||
diff --git a/help/T42.hpj b/help/T42.hpj new file mode 100644 index 0000000..d7ad056 --- a/dev/null +++ b/help/T42.hpj | |||
@@ -0,0 +1,31 @@ | |||
1 | ; This file is maintained by HCW. Do not modify this file directly. | ||
2 | |||
3 | [OPTIONS] | ||
4 | COMPRESS=12 Hall Zeck | ||
5 | LCID=0x409 0x0 0x0 ; English (United States) | ||
6 | REPORT=Yes | ||
7 | TITLE=T42 | ||
8 | CNT=T42.cnt | ||
9 | HLP=T42.HLP | ||
10 | |||
11 | [FILES] | ||
12 | T42.rtf | ||
13 | |||
14 | [ALIAS] | ||
15 | HIDD_ABOUTBOX=About | ||
16 | HIDD_ANNOUNCE=AnnounceDialog | ||
17 | HIDD_OPTIONS_FONTS=FontsOptions | ||
18 | HIDD_OPTIONS_GENERAL=GeneralOptions | ||
19 | HIDD_OPTIONS_SECRETARY=SecretaryOptions | ||
20 | HIDD_OPTIONS_SOUNDS=SoundsOptions | ||
21 | HIDD_REMOTE=RemoteDialog | ||
22 | HIDD_T42_DIALOG=MainWindow | ||
23 | HIDD_T42VIEW=ConversationWindow | ||
24 | HIDR_MAINFRAME=MainWindow | ||
25 | HIDR_T42FRAME=ConversationWindow | ||
26 | |||
27 | [MAP] | ||
28 | #include T42.hm | ||
29 | |||
30 | [WINDOWS] | ||
31 | Standard="",(1,1,698,940),20740,(r14876671),(r12632256),f2 | ||
diff --git a/help/T42.rtf b/help/T42.rtf new file mode 100644 index 0000000..678738a --- a/dev/null +++ b/help/T42.rtf | |||
@@ -0,0 +1,194 @@ | |||
1 | {\rtf1\ansi | ||
2 | @{\footnote | ||
3 | THIS FILE WAS AUTOMATICALLY GENERATED FROM XML DOCUMENT. | ||
4 | DO NOT MODIFY THIS FILE DIRECTLY. EDIT XML DOCUMENT INSTEAD | ||
5 | } | ||
6 | {\fonttbl{\f0\froman Times New Roman;}{\f1\fswiss Arial;}{\f3\froman Symbol;}}{\colortbl; | ||
7 | \red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0; | ||
8 | \red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255; | ||
9 | \red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128; | ||
10 | \red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;} | ||
11 | |||
12 | \pard\plain\keepn | ||
13 | #{\footnote About} | ||
14 | ${\footnote About T42} | ||
15 | { \f1\fs18\b\sb120 About {\b T42}} | ||
16 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 {\b T42} is our {\i Win32} implementation of {\b\cf6 unix}{\b\cf6 ntalk} protocol. | ||
17 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 It features:\pard | ||
18 | \par \fi0\li0 \bullet {\b Multihoming} - works properly on multihomed machines (ie. accepts connections/issues requests on all interfaces); | ||
19 | \par \fi0\li0 \bullet {\b Your personal secretary} - technically speaking, something like answering machine; | ||
20 | \par \fi0\li0 \bullet {\b Sleep function} - be notified of activities in backgrounded windows;\pard | ||
21 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Designed to be compatible with our {\i TFTP} client/server, {\uldb {\b PumpKIN}}{\v %!ExecFile("http://www.klever.net/kin/pumpkin.html")}, that allows you to exchange files with your party while having talk sessions. | ||
22 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 | ||
23 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 {\b {\i Enjoy!}} | ||
24 | { | ||
25 | \par\pard\plain\sb360\sa120 \f1\fs16 Copyright (c) 1998, 2002 {\uldb\cf0 Klever Group (http://www.klever.net/)}{\v %!ExecFile("http://www.klever.net/")} | ||
26 | \par\qj\sb120\sa120Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
27 | \par The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
28 | \par \sa360 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
29 | } | ||
30 | \par \sa0\sb120\ql \f1\fs16 Author: {\b\uldb\cf11 Michael Krelin ({\i hacker@klever.net})}{\v %!ExecFile("mailto:hacker@klever.net")} | ||
31 | \par \sa0\sb0 Fan mail send to {\i\uldb gefilte@klever.net}{\v %!ExecFile("mailto:gefilte@klever.net")} | ||
32 | \page | ||
33 | |||
34 | \pard\plain | ||
35 | #{\footnote News} | ||
36 | ${\footnote What's New} | ||
37 | \par\pard\plain\f1\fs24\qc\cf2\b 1.5 - August 19th, 2002 | ||
38 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Change of license and opening the source | ||
39 | \page | ||
40 | |||
41 | \pard\plain\keepn | ||
42 | #{\footnote Using} | ||
43 | ${\footnote Using T42} | ||
44 | { \f1\fs18\b\sb120 Using {\b T42}} | ||
45 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Once you've installed {\b T42}, run it from {\i Programs/Accessories/Klever Co.} menu. A small cup icon will appear in the notification tray area. | ||
46 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Left-click on the icon will get you to the {\uldb Main Window}{\v MainWindow}, right-click brings up the following menu:\pard | ||
47 | \par \fi0\li0 \bullet {\b Order some tea} - Initiates talk session. This will open new {\uldb Conversation Window}{\v ConversationWindow} and prompt you for request details. | ||
48 | \par \fi0\li0 \bullet {\b Away} - Toggle your away mode. It affects the way {\b T42} handles incoming calls. See {\uldb Main Window}{\v Mainwindow} for details. | ||
49 | \par \fi0\li0 \bullet {\b Show Main Window} - Toggle visibility of the {\uldb Main Window}{\v MainWindow} from which you can control some of {\b T42} options and read/maintain your recorded messages. | ||
50 | \par \fi0\li0 \bullet {\b Options} - Select this to bring up {\uldb Options dialog}{\v Options} so that you can customize {\b T42} to suit your needs. | ||
51 | \par \fi0\li0 \bullet {\b Exit} - This is not likely to happen, but if you want to exit {\b T42} and unload it from memory - that's what {\b Exit} is for.\pard | ||
52 | \page | ||
53 | |||
54 | \pard\plain\keepn | ||
55 | #{\footnote MainWindow} | ||
56 | ${\footnote Main Window} | ||
57 | { \f1\fs18\b\sb120 Main {\b T42} Window} | ||
58 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Main Window is a {\b T42} Control Center, it's exactly mouse-click away from most of {\b T42} functions. It consists of\pard | ||
59 | \par \fi0\li0 \bullet {\b On Call} and {\b On Call when away} dropdown lists let you select the action to take when incoming call occurs in 'normal' and 'away' mode. Chose one of | ||
60 | \pard | ||
61 | \par \fi0\li0 \bullet {\i Prompt} - Ask you what to do before taking any actions; | ||
62 | \par \fi0\li0 \bullet {\i Secretary} - Relay incoming calls to your {\uldb personal secretary}{\v SecretaryOptions}. Some prefer to call it answering machine. | ||
63 | \par \fi0\li0 \bullet {\i Not here} - Tell the caller you're not here ({\i not logged in}) and terminate connection. | ||
64 | \par \fi0\li0 \bullet {\i Refuse} - Tell the caller you're not accepting messages and terminate connection. | ||
65 | \par \fi0\li0 \bullet {\i Ignore} - Pretend that you didn't notice.\pard | ||
66 | \par \fi0\li0 \bullet {\b Away} button toggles your away mode. When an incoming call occurs {\b T42} takes action based upon away mode and options selected in {\b On Call} and {\b On Call when away} dropdown lists. | ||
67 | \par \fi0\li0 \bullet {\b Tea} button initiates new talk session. This will open new {\uldb Conversation Window}{\v ConversationWindow} and prompt you for {\uldb request details}{\v RemoteDialog}. | ||
68 | \par \fi0\li0 \bullet {\b Options} button brings up {\uldb Configuration Dialog}{\v Options} that lets you customize {\b T42} according to your needs. | ||
69 | \par \fi0\li0 \bullet {\b Exit} - button closes {\b T42} windows and removes {\b T42} from memory. | ||
70 | \par \fi0\li0 \bullet {\b Help} button enters the help system. If you got this far, you probably don't need further explanations. | ||
71 | \par \fi0\li0 \bullet {\b Recorded messages} list this is the list of messages recorded by your secretary. Messages are sorted by age, last ones first. Unanswered messages have a brighter cup icon unless you've explicitly marked the message as processed (see below for details). Right-click on the list entry presents you with popup menu from which you can: | ||
72 | \pard | ||
73 | \par \fi0\li0 \bullet {\i Call back} the person who left the message. This is identical to initiating new talk session and entering caller's data manually. Note: if the caller has a dynamic IP address and have already disconnected from his ISP and reconnected back this may not work. | ||
74 | \par \fi0\li0 \bullet {\i Delete} selected message(s). If you don't need recorded message anymore you can throw it away by selecting this. | ||
75 | \par \fi0\li0 \bullet {\i Save to file..} menu option lets you save message into {\i RTF} file. Then you may print message text, import it into your {\b\cf6 MS Word} documents or do with it whatever you want. | ||
76 | \par \fi0\li0 \bullet {\i Mark as new} message lets you force message state to 'unprocessed' which means that it will have brighter cup icon in front of it which is supposed to help you keep track of messages that you need to take care of. | ||
77 | \par \fi0\li0 \bullet {\i Mark as processed} message is the reverse of {\i Mark as new} command. | ||
78 | \par \fi0\li0 \bullet {\i Empty Log} simply removes all messages from the log.\pard | ||
79 | \par \fi0\li0 \bullet {\b Message preview window} - the recorded message itself is shown in this window.\pard | ||
80 | \page | ||
81 | |||
82 | \pard\plain\keepn | ||
83 | #{\footnote AnnounceDialog} | ||
84 | ${\footnote Announce Dialog} | ||
85 | { \f1\fs18\b\sb120 Announce Dialog Window} | ||
86 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 When incoming call occurs and you're set to get a prompt this dialog pops up. This dialog lets you chose what further actions you want {\b T42} to take and see the request details. The dialog looks like this: | ||
87 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 \{bmct announce.bmp\} | ||
88 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Incoming call details are in {\b bold}. The details are:\pard | ||
89 | \par \fi0\li0 \bullet {\b callee name} - this is your name, or what caller thinks it is. ({\i kamel} in this example) | ||
90 | \par \fi0\li0 \bullet {\b tty} - terminal on which remote thinks you're logged on. This is not important for incoming requests. Normally this is only used on unix machines. ({\i tty0} in this example) | ||
91 | \par \fi0\li0 \bullet {\b caller's name} - local username and hostname/IP address of caller. ({\i hacker@localhost} in this example)\pard | ||
92 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Use {\b Yes, I'd appreciate some milk} button to answer the call and establish talk connection with caller, {\b Not now, have a cup of tea with secretary} to relay the call to your secretary and {\b No, thanks, I'm out to coffee house} to ignore call. | ||
93 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 If you don't answer in 30 seconds the call is relayed to the secretary. | ||
94 | \page | ||
95 | |||
96 | \pard\plain\keepn | ||
97 | #{\footnote Options} | ||
98 | ${\footnote Options} | ||
99 | { \f1\fs18\b\sb120 Options} | ||
100 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Options is a tabbed dialog box where you're supposed to change {\b T42} settings. It consists of\pard | ||
101 | \par \fi0\li0 \bullet {\uldb General tab}{\v GeneralOptions} - tune general {\b T42} options. Not much to set there so far. | ||
102 | \par \fi0\li0 \bullet {\uldb Format tab}{\v FontsOptions} - set up text formats (fonts, colors, etc.) for various windows. | ||
103 | \par \fi0\li0 \bullet {\uldb Sounds tab}{\v SoundsOptions} - customize {\b T42} bells and whistles in this dialog. | ||
104 | \par \fi0\li0 \bullet {\uldb Secretary tab}{\v SecretaryOptions} - teach your secretary manners here.\pard | ||
105 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Note: you might need to restart {\b T42} for some options to take effect. | ||
106 | \page | ||
107 | |||
108 | \pard\plain\keepn | ||
109 | #{\footnote GeneralOptions} | ||
110 | ${\footnote General Options} | ||
111 | { \f1\fs18\b\sb120 General Options} | ||
112 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Currently you can only set up talk port here. Talk port is the UDP> port {\b\cf6 talk daemon} listens for incoming connections at. You can enter either number of port or service name (as specified in your {\b services} file) here. Do not change this if you don't know what you're doing and don't understand the instructions above. | ||
113 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Note: you have to restart {\b T42} for this option to take effect. | ||
114 | \page | ||
115 | |||
116 | \pard\plain\keepn | ||
117 | #{\footnote FontsOptions} | ||
118 | ${\footnote Fonts Options} | ||
119 | { \f1\fs18\b\sb120 Fonts} | ||
120 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Set up various fonts for {\b T42} to use according to your own preferences. There are three formats for you to set:\pard | ||
121 | \par \fi0\li0 \bullet {\b Local} - this is what your typing appears as. | ||
122 | \par \fi0\li0 \bullet {\b Remote} - this is what your party's typing should look like. | ||
123 | \par \fi0\li0 \bullet {\b System} - this is what system messages, like disconnection cause, etc. in talk windows look like.\pard | ||
124 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 For each format you can set up {\b Font face}, {\b Font size}, {\b bold}, {\i italic}, {\ul underline}, {\strike strikeout} and {\b character set} to use. For some formats you can also set {\b foreground} and {\b background} colors. | ||
125 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Note: these settings only affect new windows. | ||
126 | \page | ||
127 | |||
128 | \pard\plain\keepn | ||
129 | #{\footnote SoundsOptions} | ||
130 | ${\footnote Sounds Options} | ||
131 | { \f1\fs18\b\sb120 Sounds} | ||
132 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 This is where you customize {\b T42} bells and whistles, specifically:\pard | ||
133 | \par \fi0\li0 \bullet {\b Bell in {\b T42} window} - the sound to produce when you or your party sends ASCII BELL characters ({\b Ctrl-G}). | ||
134 | \par \fi0\li0 \bullet {\b Prompt sound alert} the sound used to notify you of incoming call. You may also set {\b loop} for this sound to make it continuous for the {\uldb Announce Window}{\v AnnounceDialog} lifetime. | ||
135 | \par \fi0\li0 \bullet {\b Wake-up sound alert} the sound used to let you know that {\b T42} leaves {\b sleep mode} (see {\uldb Conversation Window}{\v ConversationWindow} for details).\pard | ||
136 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 For each sound you can either specify {\b .WAV} file (use browse button to choose it) or internal sound from drop-down list. You can also use play button to check what it sounds like. | ||
137 | \page | ||
138 | |||
139 | \pard\plain\keepn | ||
140 | #{\footnote SecretaryOptions} | ||
141 | ${\footnote Secretary Options} | ||
142 | { \f1\fs18\b\sb120 Secretary} | ||
143 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 This is the place to teach your secretary how to behave. The things you can ask for are:\pard | ||
144 | \par \fi0\li0 \bullet {\b Greeting message} - this is the message your secretary greets caller with. When greeting is transferred your secretary will automatically substitute time limit (see below) instead of {\b %t} and characters limit (see below) instead of {\b %c}. | ||
145 | \par \fi0\li0 \bullet After greeting the caller your secretary will record the message until the caller will exceed either {\b time limit} or {\b character} limit. You may choose to disable either or both limits. | ||
146 | \par \fi0\li0 \bullet You may also limit your secretary's ability to handle multiple calls to provide each caller with better service. Normally the optimal limit depends on your system resources and your callers' activities.\pard | ||
147 | \page | ||
148 | |||
149 | \pard\plain\keepn | ||
150 | #{\footnote RemoteDialog} | ||
151 | ${\footnote Remote Dialog} | ||
152 | { \f1\fs18\b\sb120 Remote Dialog} | ||
153 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Whenever you want to issue talk request you're presented with a dialog in which you can enter your request details, it looks like this: | ||
154 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 \{bmct invite.bmp\} | ||
155 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 The call details are:\pard | ||
156 | \par \fi0\li0 \bullet {\i Callee address} - The address is in the form {\b user@host}, {\i kamel@192.168.168.192} in this example. | ||
157 | \par \fi0\li0 \bullet {\i tty} - terminal line your party is logged on. It's only relevant when the callee is on unix system. If you don't know what to put in there - just leave it blank. | ||
158 | \par \fi0\li0 \bullet {\i Your username} - this is how your call will appear to caller. Just don't leave it empty.\pard | ||
159 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Note: your party address is {\b not} your party's email address, even if it looks similar. {\b host} part is either hostname your party logged in or {\b IP address} of the host. If your party has {\b dynamically assigned} IP address, one way to determine it is too look up in the headers of e-mail sent {\b after} your party's established internet connection last time (i.e. very recent one) and find something like | ||
160 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 Received: from 209.203.65.22 (ppp22.kross.klever.net [209.203.65.22]) by mail.elsinore.klever.net (8.8.7/8.8.7) with SMTP id RAA15788 | ||
161 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 In this case the IP address would be {\b 209.203.65.22} and the host name {\b ppp22.kross.klever.net} | ||
162 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 So, you're advised to talk to {\b whoever@209.203.65.22} or {\b whoever@ppp22.kross.klever.net}. You don't need to worry if your party has a static IP address. | ||
163 | \page | ||
164 | |||
165 | \pard\plain\keepn | ||
166 | #{\footnote ConversationWindow} | ||
167 | ${\footnote Conversation Window} | ||
168 | { \f1\fs18\b\sb120 Conversation Window} | ||
169 | \par\sa120\sb120\qj\pard \f1\fs18\sb120 This is the window where actual conversation takes place. It is split into two panes for you and for your party. It is split either horizontal or vertical. In the former case you type in the upper half and see what your party does in the lower. In case of vertical orientation your part is the leftmost one. All control actions are done via menu bar. Here goes an explanation for each command:\pard | ||
170 | \par \fi0\li0 \bullet {\b Tea}\pard | ||
171 | \par \fi0\li0 \bullet {\i Remote user} - initiate talk session for this window. You will be prompted for {\uldb your party's whereabouts}{\v RemoteDialog}. | ||
172 | \par \fi0\li0 \bullet {\i Close connection} - terminate talk session. This puts window into inactive state until you initiate new session. | ||
173 | \par \fi0\li0 \bullet {\i Re-connect} - re-initiate talk session to the same party, for instance if you've lost connection. | ||
174 | \par \fi0\li0 \bullet {\i Save} - if there was something important said you can save the whole conversation into RTF formatted file for future reference. | ||
175 | \par \fi0\li0 \bullet {\i Exit} - will close conversation window and terminate the connection.\pard | ||
176 | \par \fi0\li0 \bullet {\b Edit}\pard | ||
177 | \par \fi0\li0 \bullet {\i Copy} - copy currently selected text into windows clipboard. | ||
178 | \par \fi0\li0 \bullet {\i Paste} - paste window selection into your current conversation.\pard | ||
179 | \par \fi0\li0 \bullet {\b Sleep}\pard | ||
180 | \par \fi0\li0 \bullet {\i Sleep} - put your session to sleep. When your party shows some kind of activity {\b Wake-up action} will be taken (see below). | ||
181 | \par \fi0\li0 \bullet {\i Sleep on minimize} - check this if you want to activate sleep mode whenever you minimize conversation window. | ||
182 | \par \fi0\li0 \bullet {\i Minimize on sleep} - check this if you want to minimize window whenever you put it into sleep mode. | ||
183 | \par \fi0\li0 \bullet {\i Wake-up action} - Actions to take whenever remote user shows activity in sleep mode. Possible actions are: | ||
184 | \pard | ||
185 | \par \fi0\li0 \bullet Make sound - check this if you want {\b T42} to produce sound (as specified in {\uldb Sounds Options}{\v SoundsOptions}) whenever it leaves sleep mode. | ||
186 | \par \fi0\li0 \bullet Pop-up - check this if you want {\b T42} to bring conversation window to foreground and restore if it is minimized whenever it leaves sleep mode.\pard\pard | ||
187 | \par \fi0\li0 \bullet {\b Window}\pard | ||
188 | \par \fi0\li0 \bullet {\i Split equally} split local and remote panes in equal propotions. | ||
189 | \par \fi0\li0 \bullet {\i Save layout} - save window position, size and split proportions for future sessions. | ||
190 | \par \fi0\li0 \bullet {\i Autosave layout} - automatically save layout whenever you close conversation window. | ||
191 | \par \fi0\li0 \bullet {\i Horizontal split}/{\i Vertical split} - chose your orientation. | ||
192 | \par \fi0\li0 \bullet {\i Hide on minimize} - set {\b T42} to hide window into notification tray icon whenever you minimize it.\pard\pard | ||
193 | \page | ||
194 | } \ No newline at end of file | ||
diff --git a/help/T42.xml b/help/T42.xml new file mode 100644 index 0000000..d59c255 --- a/dev/null +++ b/help/T42.xml | |||
@@ -0,0 +1,183 @@ | |||
1 | <?xml version="1.0"?> | ||
2 | <winhelp> | ||
3 | <topic id="About" title="About T42"> | ||
4 | <heading scroll="no">About <kin>T42</kin></heading> | ||
5 | <p><kin>T42</kin> is our <term>Win32</term> implementation of <product>unix</product> <product>ntalk</product> protocol.</p> | ||
6 | <p>It features:</p> | ||
7 | <ul> | ||
8 | <li><b>Multihoming</b> - works properly on multihomed machines (ie. accepts connections/issues requests on all interfaces);</li> | ||
9 | <li><b>Your personal secretary</b> - technically speaking, something like answering machine;</li> | ||
10 | <li><b>Sleep function</b> - be notified of activities in backgrounded windows;</li> | ||
11 | </ul> | ||
12 | <p>Designed to be compatible with our <term>TFTP</term> client/server, <kin href="http://www.klever.net/kin/pumpkin.html">PumpKIN</kin>, that allows you to exchange files with your party while having talk sessions.</p> | ||
13 | <p/> | ||
14 | <p><b><i>Enjoy!</i></b></p> | ||
15 | <license years="1998, 2002"/> | ||
16 | <credits/> | ||
17 | </topic> | ||
18 | <topic id="News" title="What's New"> | ||
19 | <newsfor version="1.5" date="August 19th, 2002"> | ||
20 | <ni>Change of license and opening the source</ni> | ||
21 | </newsfor> | ||
22 | </topic> | ||
23 | <topic id="Using" title="Using T42"> | ||
24 | <heading scroll="no">Using <kin>T42</kin></heading> | ||
25 | <p>Once you've installed <kin>T42</kin>, run it from <i>Programs/Accessories/Klever Co.</i> menu. A small cup icon will appear in the notification tray area.</p> | ||
26 | <p>Left-click on the icon will get you to the <a href="#MainWindow">Main Window</a>, right-click brings up the following menu:</p> | ||
27 | <ul> | ||
28 | <li><b>Order some tea</b> - Initiates talk session. This will open new <a href="#ConversationWindow">Conversation Window</a> and prompt you for request details.</li> | ||
29 | <li><b>Away</b> - Toggle your away mode. It affects the way <kin>T42</kin> handles incoming calls. See <a href="#Mainwindow">Main Window</a> for details.</li> | ||
30 | <li><b>Show Main Window</b> - Toggle visibility of the <a href="#MainWindow">Main Window</a> from which you can control some of <kin>T42</kin> options and read/maintain your recorded messages.</li> | ||
31 | <li><b>Options</b> - Select this to bring up <a href="#Options">Options dialog</a> so that you can customize <kin>T42</kin> to suit your needs.</li> | ||
32 | <li><b>Exit</b> - This is not likely to happen, but if you want to exit <kin>T42</kin> and unload it from memory - that's what <b>Exit</b> is for.</li> | ||
33 | </ul> | ||
34 | </topic> | ||
35 | <topic id="MainWindow" title="Main Window"> | ||
36 | <heading scroll="no">Main <kin>T42</kin> Window</heading> | ||
37 | <p>Main Window is a <kin>T42</kin> Control Center, it's exactly mouse-click away from most of <kin>T42</kin> functions. It consists of</p> | ||
38 | <ul> | ||
39 | <li><b>On Call</b> and <b>On Call when away</b> dropdown lists let you select the action to take when incoming call occurs in 'normal' and 'away' mode. Chose one of | ||
40 | <ul> | ||
41 | <li><i>Prompt</i> - Ask you what to do before taking any actions;</li> | ||
42 | <li><i>Secretary</i> - Relay incoming calls to your <a href="#SecretaryOptions">personal secretary</a>. Some prefer to call it answering machine.</li> | ||
43 | <li><i>Not here</i> - Tell the caller you're not here (<i>not logged in</i>) and terminate connection.</li> | ||
44 | <li><i>Refuse</i> - Tell the caller you're not accepting messages and terminate connection.</li> | ||
45 | <li><i>Ignore</i> - Pretend that you didn't notice.</li> | ||
46 | </ul> | ||
47 | </li> | ||
48 | <li><b>Away</b> button toggles your away mode. When an incoming call occurs <kin>T42</kin> takes action based upon away mode and options selected in <b>On Call</b> and <b>On Call when away</b> dropdown lists.</li> | ||
49 | <li><b>Tea</b> button initiates new talk session. This will open new <a href="#ConversationWindow">Conversation Window</a> and prompt you for <a href="#RemoteDialog">request details</a>.</li> | ||
50 | <li><b>Options</b> button brings up <a href="#Options">Configuration Dialog</a> that lets you customize <kin>T42</kin> according to your needs.</li> | ||
51 | <li><b>Exit</b> - button closes <kin>T42</kin> windows and removes <kin>T42</kin> from memory.</li> | ||
52 | <li><b>Help</b> button enters the help system. If you got this far, you probably don't need further explanations.</li> | ||
53 | <li><b>Recorded messages</b> list this is the list of messages recorded by your secretary. Messages are sorted by age, last ones first. Unanswered messages have a brighter cup icon unless you've explicitly marked the message as processed (see below for details). Right-click on the list entry presents you with popup menu from which you can: | ||
54 | <ul> | ||
55 | <li><i>Call back</i> the person who left the message. This is identical to initiating new talk session and entering caller's data manually. Note: if the caller has a dynamic IP address and have already disconnected from his ISP and reconnected back this may not work.</li> | ||
56 | <li><i>Delete</i> selected message(s). If you don't need recorded message anymore you can throw it away by selecting this.</li> | ||
57 | <li><i>Save to file..</i> menu option lets you save message into <term>RTF</term> file. Then you may print message text, import it into your <product>MS Word</product> documents or do with it whatever you want.</li> | ||
58 | <li><i>Mark as new</i> message lets you force message state to 'unprocessed' which means that it will have brighter cup icon in front of it which is supposed to help you keep track of messages that you need to take care of.</li> | ||
59 | <li><i>Mark as processed</i> message is the reverse of <i>Mark as new</i> command.</li> | ||
60 | <li><i>Empty Log</i> simply removes all messages from the log.</li> | ||
61 | </ul> | ||
62 | </li> | ||
63 | <li><b>Message preview window</b> - the recorded message itself is shown in this window.</li> | ||
64 | </ul> | ||
65 | </topic> | ||
66 | <topic id="AnnounceDialog" title="Announce Dialog"> | ||
67 | <heading scroll="no">Announce Dialog Window</heading> | ||
68 | <p>When incoming call occurs and you're set to get a prompt this dialog pops up. This dialog lets you chose what further actions you want <kin>T42</kin> to take and see the request details. The dialog looks like this:</p> | ||
69 | <p><image source="announce.bmp"/></p> | ||
70 | <p>Incoming call details are in <b>bold</b>. The details are:</p> | ||
71 | <ul> | ||
72 | <li><b>callee name</b> - this is your name, or what caller thinks it is. (<i>kamel</i> in this example)</li> | ||
73 | <li><b>tty</b> - terminal on which remote thinks you're logged on. This is not important for incoming requests. Normally this is only used on unix machines. (<i>tty0</i> in this example)</li> | ||
74 | <li><b>caller's name</b> - local username and hostname/IP address of caller. (<i>hacker@localhost</i> in this example)</li> | ||
75 | </ul> | ||
76 | <p>Use <b>Yes, I'd appreciate some milk</b> button to answer the call and establish talk connection with caller, <b>Not now, have a cup of tea with secretary</b> to relay the call to your secretary and <b>No, thanks, I'm out to coffee house</b> to ignore call.</p> | ||
77 | <p>If you don't answer in 30 seconds the call is relayed to the secretary.</p> | ||
78 | </topic> | ||
79 | <topic id="Options" title="Options"> | ||
80 | <heading scroll="no">Options</heading> | ||
81 | <p>Options is a tabbed dialog box where you're supposed to change <kin>T42</kin> settings. It consists of</p> | ||
82 | <ul> | ||
83 | <li><a href="#GeneralOptions">General tab</a> - tune general <kin>T42</kin> options. Not much to set there so far.</li> | ||
84 | <li><a href="#FontsOptions">Format tab</a> - set up text formats (fonts, colors, etc.) for various windows.</li> | ||
85 | <li><a href="#SoundsOptions">Sounds tab</a> - customize <kin>T42</kin> bells and whistles in this dialog.</li> | ||
86 | <li><a href="#SecretaryOptions">Secretary tab</a> - teach your secretary manners here.</li> | ||
87 | </ul> | ||
88 | <p>Note: you might need to restart <kin>T42</kin> for some options to take effect.</p> | ||
89 | </topic> | ||
90 | <topic id="GeneralOptions" title="General Options"> | ||
91 | <heading scroll="no">General Options</heading> | ||
92 | <p>Currently you can only set up talk port here. Talk port is the UDP> port <product>talk daemon</product> listens for incoming connections at. You can enter either number of port or service name (as specified in your <b>services</b> file) here. Do not change this if you don't know what you're doing and don't understand the instructions above.</p> | ||
93 | <p>Note: you have to restart <kin>T42</kin> for this option to take effect.</p> | ||
94 | </topic> | ||
95 | <topic id="FontsOptions" title="Fonts Options"> | ||
96 | <heading scroll="no">Fonts</heading> | ||
97 | <p>Set up various fonts for <kin>T42</kin> to use according to your own preferences. There are three formats for you to set:</p> | ||
98 | <ul> | ||
99 | <li><b>Local</b> - this is what your typing appears as.</li> | ||
100 | <li><b>Remote</b> - this is what your party's typing should look like.</li> | ||
101 | <li><b>System</b> - this is what system messages, like disconnection cause, etc. in talk windows look like.</li> | ||
102 | </ul> | ||
103 | <p>For each format you can set up <b>Font face</b>, <b>Font size</b>, <b>bold</b>, <i>italic</i>, <u>underline</u>, <strike>strikeout</strike> and <b>character set</b> to use. For some formats you can also set <b>foreground</b> and <b>background</b> colors.</p> | ||
104 | <p>Note: these settings only affect new windows.</p> | ||
105 | </topic> | ||
106 | <topic id="SoundsOptions" title="Sounds Options"> | ||
107 | <heading scroll="no">Sounds</heading> | ||
108 | <p>This is where you customize <kin>T42</kin> bells and whistles, specifically:</p> | ||
109 | <ul> | ||
110 | <li><b>Bell in <kin>T42</kin> window</b> - the sound to produce when you or your party sends ASCII BELL characters (<b>Ctrl-G</b>).</li> | ||
111 | <li><b>Prompt sound alert</b> the sound used to notify you of incoming call. You may also set <b>loop</b> for this sound to make it continuous for the <a href="#AnnounceDialog">Announce Window</a> lifetime.</li> | ||
112 | <li><b>Wake-up sound alert</b> the sound used to let you know that <kin>T42</kin> leaves <b>sleep mode</b> (see <a href="#ConversationWindow">Conversation Window</a> for details).</li> | ||
113 | </ul> | ||
114 | <p>For each sound you can either specify <b>.WAV</b> file (use browse button to choose it) or internal sound from drop-down list. You can also use play button to check what it sounds like.</p> | ||
115 | </topic> | ||
116 | <topic id="SecretaryOptions" title="Secretary Options"> | ||
117 | <heading scroll="no">Secretary</heading> | ||
118 | <p>This is the place to teach your secretary how to behave. The things you can ask for are:</p> | ||
119 | <ul> | ||
120 | <li><b>Greeting message</b> - this is the message your secretary greets caller with. When greeting is transferred your secretary will automatically substitute time limit (see below) instead of <b>%t</b> and characters limit (see below) instead of <b>%c</b>.</li> | ||
121 | <li>After greeting the caller your secretary will record the message until the caller will exceed either <b>time limit</b> or <b>character</b> limit. You may choose to disable either or both limits.</li> | ||
122 | <li>You may also limit your secretary's ability to handle multiple calls to provide each caller with better service. Normally the optimal limit depends on your system resources and your callers' activities.</li> | ||
123 | </ul> | ||
124 | </topic> | ||
125 | <topic id="RemoteDialog" title="Remote Dialog"> | ||
126 | <heading scroll="no">Remote Dialog</heading> | ||
127 | <p>Whenever you want to issue talk request you're presented with a dialog in which you can enter your request details, it looks like this:</p> | ||
128 | <p><image source="invite.bmp"/></p> | ||
129 | <p>The call details are:</p> | ||
130 | <ul> | ||
131 | <li><i>Callee address</i> - The address is in the form <b>user@host</b>, <i>kamel@192.168.168.192</i> in this example.</li> | ||
132 | <li><i>tty</i> - terminal line your party is logged on. It's only relevant when the callee is on unix system. If you don't know what to put in there - just leave it blank.</li> | ||
133 | <li><i>Your username</i> - this is how your call will appear to caller. Just don't leave it empty.</li> | ||
134 | </ul> | ||
135 | <p>Note: your party address is <b>not</b> your party's email address, even if it looks similar. <b>host</b> part is either hostname your party logged in or <b>IP address</b> of the host. If your party has <b>dynamically assigned</b> IP address, one way to determine it is too look up in the headers of e-mail sent <b>after</b> your party's established internet connection last time (i.e. very recent one) and find something like</p> | ||
136 | <p>Received: from 209.203.65.22 (ppp22.kross.klever.net [209.203.65.22]) by mail.elsinore.klever.net (8.8.7/8.8.7) with SMTP id RAA15788</p> | ||
137 | <p>In this case the IP address would be <b>209.203.65.22</b> and the host name <b>ppp22.kross.klever.net</b></p> | ||
138 | <p>So, you're advised to talk to <b>whoever@209.203.65.22</b> or <b>whoever@ppp22.kross.klever.net</b>. You don't need to worry if your party has a static IP address.</p> | ||
139 | </topic> | ||
140 | <topic id="ConversationWindow" title="Conversation Window"> | ||
141 | <heading scroll="no">Conversation Window</heading> | ||
142 | <p>This is the window where actual conversation takes place. It is split into two panes for you and for your party. It is split either horizontal or vertical. In the former case you type in the upper half and see what your party does in the lower. In case of vertical orientation your part is the leftmost one. All control actions are done via menu bar. Here goes an explanation for each command:</p> | ||
143 | <ul> | ||
144 | <li><b>Tea</b> | ||
145 | <ul> | ||
146 | <li><i>Remote user</i> - initiate talk session for this window. You will be prompted for <a href="#RemoteDialog">your party's whereabouts</a>.</li> | ||
147 | <li><i>Close connection</i> - terminate talk session. This puts window into inactive state until you initiate new session.</li> | ||
148 | <li><i>Re-connect</i> - re-initiate talk session to the same party, for instance if you've lost connection.</li> | ||
149 | <li><i>Save</i> - if there was something important said you can save the whole conversation into RTF formatted file for future reference.</li> | ||
150 | <li><i>Exit</i> - will close conversation window and terminate the connection.</li> | ||
151 | </ul> | ||
152 | </li> | ||
153 | <li><b>Edit</b> | ||
154 | <ul> | ||
155 | <li><i>Copy</i> - copy currently selected text into windows clipboard.</li> | ||
156 | <li><i>Paste</i> - paste window selection into your current conversation.</li> | ||
157 | </ul> | ||
158 | </li> | ||
159 | <li><b>Sleep</b> | ||
160 | <ul> | ||
161 | <li><i>Sleep</i> - put your session to sleep. When your party shows some kind of activity <b>Wake-up action</b> will be taken (see below).</li> | ||
162 | <li><i>Sleep on minimize</i> - check this if you want to activate sleep mode whenever you minimize conversation window.</li> | ||
163 | <li><i>Minimize on sleep</i> - check this if you want to minimize window whenever you put it into sleep mode.</li> | ||
164 | <li><i>Wake-up action</i> - Actions to take whenever remote user shows activity in sleep mode. Possible actions are: | ||
165 | <ul> | ||
166 | <li>Make sound - check this if you want <kin>T42</kin> to produce sound (as specified in <a href="#SoundsOptions">Sounds Options</a>) whenever it leaves sleep mode.</li> | ||
167 | <li>Pop-up - check this if you want <kin>T42</kin> to bring conversation window to foreground and restore if it is minimized whenever it leaves sleep mode.</li> | ||
168 | </ul> | ||
169 | </li> | ||
170 | </ul> | ||
171 | </li> | ||
172 | <li><b>Window</b> | ||
173 | <ul> | ||
174 | <li><i>Split equally</i> split local and remote panes in equal propotions.</li> | ||
175 | <li><i>Save layout</i> - save window position, size and split proportions for future sessions.</li> | ||
176 | <li><i>Autosave layout</i> - automatically save layout whenever you close conversation window.</li> | ||
177 | <li><i>Horizontal split</i>/<i>Vertical split</i> - chose your orientation.</li> | ||
178 | <li><i>Hide on minimize</i> - set <kin>T42</kin> to hide window into notification tray icon whenever you minimize it.</li> | ||
179 | </ul> | ||
180 | </li> | ||
181 | </ul> | ||
182 | </topic> | ||
183 | </winhelp> | ||
diff --git a/help/announce.bmp b/help/announce.bmp new file mode 100644 index 0000000..5c40627 --- a/dev/null +++ b/help/announce.bmp | |||
Binary files differ | |||
diff --git a/help/invite.bmp b/help/invite.bmp new file mode 100644 index 0000000..7dac6bb --- a/dev/null +++ b/help/invite.bmp | |||
Binary files differ | |||
diff --git a/install/custom.rch b/install/custom.rch new file mode 100644 index 0000000..8916c47 --- a/dev/null +++ b/install/custom.rch | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifdefSTATI_K | ||
2 | T42.ex_ rcdata discardable "../releast/T42.ex_" | ||
3 | #else | ||
4 | T42.ex_ rcdata discardable "../release/T42.ex_" | ||
5 | #endif | ||
6 | T42.cn_ rcdata discardable "../release/T42.cn_" | ||
7 | T42.hl_ rcdata discardable "../release/T42.hl_" | ||
8 | #ifdef K_ANNED | ||
9 | mfc42.dl_ rcdata discardable "../redist/mfc42.dl_" | ||
10 | #endif | ||
diff --git a/install/install.cpp b/install/install.cpp new file mode 100644 index 0000000..89eb3fc --- a/dev/null +++ b/install/install.cpp | |||
@@ -0,0 +1,68 @@ | |||
1 | #include "resource.h" | ||
2 | #include "../shared-code/install.h" | ||
3 | |||
4 | #defineKINAME "T42 1.5" | ||
5 | #define SKINAME "T42" | ||
6 | |||
7 | BOOL Install(void) | ||
8 | { | ||
9 | STRING dPath = strFETCH_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group, Inc.",SKINAME "Path"); | ||
10 | STRING kPath = strFETCH_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group, Inc.","KINPath"); | ||
11 | LPCSTR qPath = ((LPCSTR)dPath)?(LPCSTR)dPath:(((LPCSTR)kPath)?(LPSTR)kPath:"C:\\Program Files\\Klever\\Nothings"); | ||
12 | STRING path = REQUESTPATH(" " KINAME,"\nEnter destination path:",qPath); | ||
13 | if(!path) | ||
14 | return NULL; | ||
15 | |||
16 | #ifdefK_ANNED | ||
17 | STRING sysDir(_MAX_PATH); | ||
18 | GetSystemDirectory(sysDir,_MAX_PATH); | ||
19 | INSTALLFILE("mfc42.dl_",sysDir,"mfc42.dll"); | ||
20 | #endif | ||
21 | |||
22 | MAKE_PATH(path); | ||
23 | STRING shortPath = GET_SHORT_PATH(path); | ||
24 | if(!shortPath){ | ||
25 | MessageBox(NULL,"Failed to install " KINAME " in specified directory",NULL,MB_ICONERROR|MB_OK); | ||
26 | return FALSE; | ||
27 | } | ||
28 | |||
29 | if(!( | ||
30 | INSTALLFILE(SKINAME ".ex_",path,SKINAME ".exe") && | ||
31 | INSTALLFILE(SKINAME ".hl_",path,SKINAME ".hlp") && | ||
32 | INSTALLFILE(SKINAME ".cn_",path,SKINAME ".cnt") | ||
33 | )){ | ||
34 | MessageBox(NULL,"Failed to install " KINAME " in specified directory",NULL,MB_ICONERROR|MB_OK); | ||
35 | return FALSE; | ||
36 | } | ||
37 | ADDMENU("Accessories\\Klever Co.",SKINAME,path, SKINAME ".exe"); | ||
38 | |||
39 | strSET_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group, Inc.",SKINAME "Path",path); | ||
40 | strSET_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group, Inc.","KINPath",path); | ||
41 | |||
42 | FILE* inf=CREATE_INF_FILE(path,SKINAME ".INF"); | ||
43 | if(!inf){ | ||
44 | MessageBox(NULL,"Failed to install " KINAME,NULL,MB_ICONERROR|MB_OK); | ||
45 | return FALSE; | ||
46 | } | ||
47 | INF_FILE_HEADER(inf); | ||
48 | INF_FILE_SECTION(inf,"Uninstall"); | ||
49 | fprintf(inf,"AddReg=kFiles\nDelReg=kReg\nUpdateInis=kMenu\n"); | ||
50 | INF_FILE_SECTION(inf,"kFiles"); | ||
51 | INF_REMOVE_ROOT(inf,SKINAME "Files",shortPath); | ||
52 | INF_REMOVE_FILE(inf,SKINAME "Files",SKINAME ".exe"); | ||
53 | INF_REMOVE_HELP_FILE(inf,SKINAME "Files",SKINAME); | ||
54 | INF_REMOVE_FILE(inf,SKINAME "Files",SKINAME ".inf"); | ||
55 | INF_REMOVE_FILE(inf,SKINAME "Files",SKINAME ".Calls"); | ||
56 | INF_FILE_SECTION(inf,"kReg"); | ||
57 | INF_UNINSTALL_REG(inf,SKINAME); | ||
58 | INF_FILE_SECTION(inf,"kMenu"); | ||
59 | INF_MENU_GROUP(inf,1,"Accessories\\Klever Co."); | ||
60 | INF_MENU_ITEM(inf,1,SKINAME); | ||
61 | fclose(inf); | ||
62 | |||
63 | REG_UNINSTALL_COMMAND(SKINAME,"Klever " KINAME,shortPath,SKINAME ".INF","Uninstall"); | ||
64 | |||
65 | MessageBox(NULL,KINAME " installed successfully, you may now run it from Programs/Accessories/Klever Co. menu or remove it using Control Panel Add/Remove Programs applet."," Rejoice!",MB_ICONINFORMATION|MB_OK); | ||
66 | |||
67 | return TRUE; | ||
68 | } | ||
diff --git a/install/install.rc b/install/install.rc new file mode 100644 index 0000000..a613be0 --- a/dev/null +++ b/install/install.rc | |||
@@ -0,0 +1,182 @@ | |||
1 | //Microsoft Developer Studio generated resource script. | ||
2 | // | ||
3 | #include "resource.h" | ||
4 | |||
5 | #define APSTUDIO_READONLY_SYMBOLS | ||
6 | ///////////////////////////////////////////////////////////////////////////// | ||
7 | // | ||
8 | // Generated from the TEXTINCLUDE 2 resource. | ||
9 | // | ||
10 | #include "afxres.h" | ||
11 | |||
12 | ///////////////////////////////////////////////////////////////////////////// | ||
13 | #undef APSTUDIO_READONLY_SYMBOLS | ||
14 | |||
15 | ///////////////////////////////////////////////////////////////////////////// | ||
16 | // English (U.S.) resources | ||
17 | |||
18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) | ||
19 | #ifdef _WIN32 | ||
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US | ||
21 | #pragma code_page(1252) | ||
22 | #endif //_WIN32 | ||
23 | |||
24 | ///////////////////////////////////////////////////////////////////////////// | ||
25 | // | ||
26 | // Dialog | ||
27 | // | ||
28 | |||
29 | #if defined(APSTUDIO_INVOKED) || defined(FALSE) | ||
30 | #if defined(APSTUDIO_INVOKED) | ||
31 | IDD_INSTALLING$(FALSE) DIALOGEX 0, 0, 200, 74 | ||
32 | #else | ||
33 | IDD_INSTALLING DIALOGEX 0, 0, 200, 74 | ||
34 | #endif | ||
35 | STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | ||
36 | FONT 8, "MS Sans Serif", 0, 0, 0x1 | ||
37 | BEGIN | ||
38 | PUSHBUTTON "Cancel",IDCANCEL,143,53,50,14,BS_CENTER | BS_VCENTER | | ||
39 | BS_NOTIFY | BS_FLAT,WS_EX_DLGMODALFRAME | ||
40 | CONTROL "Animate1",IDC_DISKS,"SysAnimate32",ACS_TRANSPARENT | | ||
41 | ACS_AUTOPLAY | WS_TABSTOP,161,7,32,32 | ||
42 | LTEXT "",IDC_STATE,7,7,150,32,SS_NOPREFIX | SS_NOTIFY | ||
43 | CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",0x0,7,45, | ||
44 | 186,7,WS_EX_DLGMODALFRAME | ||
45 | END | ||
46 | #endif | ||
47 | |||
48 | IDD_PATH DIALOGEX 0, 0, 255, 73 | ||
49 | STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_POPUP | | ||
50 | WS_VISIBLE | WS_CAPTION | ||
51 | EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE | ||
52 | FONT 8, "MS Sans Serif", 0, 0, 0x1 | ||
53 | BEGIN | ||
54 | LTEXT "",IDC_PROMPT,7,7,241,30 | ||
55 | EDITTEXT IDC_PATH,7,37,195,12,ES_AUTOHSCROLL | ||
56 | PUSHBUTTON "B&rowse..",IDC_BROWSE,208,37,40,12 | ||
57 | DEFPUSHBUTTON "OK",IDOK,69,52,50,14 | ||
58 | PUSHBUTTON "Cancel",IDCANCEL,135,52,50,14 | ||
59 | END | ||
60 | |||
61 | |||
62 | ///////////////////////////////////////////////////////////////////////////// | ||
63 | // | ||
64 | // DESIGNINFO | ||
65 | // | ||
66 | |||
67 | #ifdef APSTUDIO_INVOKED | ||
68 | GUIDELINES DESIGNINFO DISCARDABLE | ||
69 | BEGIN | ||
70 | "IDD_INSTALLING$(FALSE)", DIALOG | ||
71 | BEGIN | ||
72 | LEFTMARGIN, 7 | ||
73 | RIGHTMARGIN, 193 | ||
74 | TOPMARGIN, 7 | ||
75 | BOTTOMMARGIN, 67 | ||
76 | HORZGUIDE, 39 | ||
77 | END | ||
78 | |||
79 | IDD_PATH, DIALOG | ||
80 | BEGIN | ||
81 | LEFTMARGIN, 7 | ||
82 | RIGHTMARGIN, 248 | ||
83 | VERTGUIDE, 202 | ||
84 | VERTGUIDE, 208 | ||
85 | TOPMARGIN, 7 | ||
86 | BOTTOMMARGIN, 66 | ||
87 | HORZGUIDE, 37 | ||
88 | END | ||
89 | END | ||
90 | #endif // APSTUDIO_INVOKED | ||
91 | |||
92 | |||
93 | #ifdef APSTUDIO_INVOKED | ||
94 | ///////////////////////////////////////////////////////////////////////////// | ||
95 | // | ||
96 | // TEXTINCLUDE | ||
97 | // | ||
98 | |||
99 | 1 TEXTINCLUDE DISCARDABLE | ||
100 | BEGIN | ||
101 | "resource.h\0" | ||
102 | END | ||
103 | |||
104 | 2 TEXTINCLUDE DISCARDABLE | ||
105 | BEGIN | ||
106 | "#include ""afxres.h""\r\n" | ||
107 | "\0" | ||
108 | END | ||
109 | |||
110 | 3 TEXTINCLUDE DISCARDABLE | ||
111 | BEGIN | ||
112 | "#include ""custom.rch""\0" | ||
113 | END | ||
114 | |||
115 | #endif // APSTUDIO_INVOKED | ||
116 | |||
117 | |||
118 | ///////////////////////////////////////////////////////////////////////////// | ||
119 | // | ||
120 | // Icon | ||
121 | // | ||
122 | |||
123 | // Icon with lowest ID value placed first to ensure application icon | ||
124 | // remains consistent on all systems. | ||
125 | IDI_ICON ICON DISCARDABLE "../shared-data/install-icon.ico" | ||
126 | |||
127 | #ifndef _MAC | ||
128 | ///////////////////////////////////////////////////////////////////////////// | ||
129 | // | ||
130 | // Version | ||
131 | // | ||
132 | |||
133 | VS_VERSION_INFO VERSIONINFO | ||
134 | FILEVERSION 1,5,0,0 | ||
135 | PRODUCTVERSION 1,5,0,0 | ||
136 | FILEFLAGSMASK 0x3fL | ||
137 | #ifdef _DEBUG | ||
138 | FILEFLAGS 0x1L | ||
139 | #else | ||
140 | FILEFLAGS 0x0L | ||
141 | #endif | ||
142 | FILEOS 0x40004L | ||
143 | FILETYPE 0x1L | ||
144 | FILESUBTYPE 0x0L | ||
145 | BEGIN | ||
146 | BLOCK "StringFileInfo" | ||
147 | BEGIN | ||
148 | BLOCK "040904b0" | ||
149 | BEGIN | ||
150 | VALUE "CompanyName", "Klever Group (http://www.klever.net/)\0" | ||
151 | VALUE "FileDescription", "INSTALL: T42, unix talk/ntalk implementation\0" | ||
152 | VALUE "FileVersion", "1, 5, 0, 0\0" | ||
153 | VALUE "InternalName", "INSTALL\0" | ||
154 | VALUE "LegalCopyright", "Copyright © 1998, 2002 Klever Group (http://www.klever.net/)\0" | ||
155 | VALUE "LegalTrademarks", "Klever Group (http://www.klever.net/)\0" | ||
156 | VALUE "OriginalFilename", "INSTALL.EXE\0" | ||
157 | VALUE "ProductName", "T42\0" | ||
158 | VALUE "ProductVersion", "1, 5, 0, 0\0" | ||
159 | END | ||
160 | END | ||
161 | BLOCK "VarFileInfo" | ||
162 | BEGIN | ||
163 | VALUE "Translation", 0x409, 1200 | ||
164 | END | ||
165 | END | ||
166 | |||
167 | #endif // !_MAC | ||
168 | |||
169 | #endif // English (U.S.) resources | ||
170 | ///////////////////////////////////////////////////////////////////////////// | ||
171 | |||
172 | |||
173 | |||
174 | #ifndef APSTUDIO_INVOKED | ||
175 | ///////////////////////////////////////////////////////////////////////////// | ||
176 | // | ||
177 | // Generated from the TEXTINCLUDE 3 resource. | ||
178 | // | ||
179 | #include "custom.rch" | ||
180 | ///////////////////////////////////////////////////////////////////////////// | ||
181 | #endif // not APSTUDIO_INVOKED | ||
182 | |||
diff --git a/install/resource.h b/install/resource.h new file mode 100644 index 0000000..ebf7991 --- a/dev/null +++ b/install/resource.h | |||
@@ -0,0 +1,24 @@ | |||
1 | //{{NO_DEPENDENCIES}} | ||
2 | // Microsoft Developer Studio generated include file. | ||
3 | // Used by Install.rc | ||
4 | // | ||
5 | #define IDD_INSTALLING 101 | ||
6 | #define IDD_PATH 102 | ||
7 | #define IDI_ICON 105 | ||
8 | #define IDC_DISKS 1000 | ||
9 | #define IDC_STATE 1001 | ||
10 | #define IDC_PROGRESS 1002 | ||
11 | #define IDC_PROMPT 1003 | ||
12 | #define IDC_PATH 1004 | ||
13 | #define IDC_BROWSE 1005 | ||
14 | |||
15 | // Next default values for new objects | ||
16 | // | ||
17 | #ifdef APSTUDIO_INVOKED | ||
18 | #ifndef APSTUDIO_READONLY_SYMBOLS | ||
19 | #define _APS_NEXT_RESOURCE_VALUE 107 | ||
20 | #define _APS_NEXT_COMMAND_VALUE 40001 | ||
21 | #define _APS_NEXT_CONTROL_VALUE 1006 | ||
22 | #define _APS_NEXT_SYMED_VALUE 101 | ||
23 | #endif | ||
24 | #endif | ||
diff --git a/makehelp.bat b/makehelp.bat new file mode 100644 index 0000000..961dba0 --- a/dev/null +++ b/makehelp.bat | |||
@@ -0,0 +1,34 @@ | |||
1 | @echo off | ||
2 | REM -- First make map file from Microsoft Visual C++ generated resource.h | ||
3 | echo // MAKEHELP.BAT generated Help Map file. Used by T42.HPJ. >"help\T42.hm" | ||
4 | echo. >>"help\T42.hm" | ||
5 | echo // Commands (ID_* and IDM_*) >>"help\T42.hm" | ||
6 | makehm ID_,HID_,0x10000 IDM_,HIDM_,0x10000 resource.h >>"help\T42.hm" | ||
7 | echo. >>"help\T42.hm" | ||
8 | echo // Prompts (IDP_*) >>"help\T42.hm" | ||
9 | makehm IDP_,HIDP_,0x30000 resource.h >>"help\T42.hm" | ||
10 | echo. >>"help\T42.hm" | ||
11 | echo // Resources (IDR_*) >>"help\T42.hm" | ||
12 | makehm IDR_,HIDR_,0x20000 resource.h >>"help\T42.hm" | ||
13 | echo. >>"help\T42.hm" | ||
14 | echo // Dialogs (IDD_*) >>"help\T42.hm" | ||
15 | makehm IDD_,HIDD_,0x20000 resource.h >>"help\T42.hm" | ||
16 | echo. >>"help\T42.hm" | ||
17 | echo // Frame Controls (IDW_*) >>"help\T42.hm" | ||
18 | makehm IDW_,HIDW_,0x50000 resource.h >>"help\T42.hm" | ||
19 | REM -- Make help for Project T42 | ||
20 | |||
21 | echo Building RTF file | ||
22 | xsltproc -o help/T42.rtf shared-code/kinhelp.xsl help/T42.xml | ||
23 | echo Building Win32 Help files | ||
24 | start /wait hcrtf -x "help\T42.hpj" | ||
25 | echo. | ||
26 | if exist Debug\nul copy "help\T42.hlp" Debug | ||
27 | if exist Debug\nul copy "help\T42.cnt" Debug | ||
28 | if exist Release\nul copy "help\T42.hlp" Release | ||
29 | if exist Release\nul copy "help\T42.cnt" Release | ||
30 | if exist Releast\nul copy "help\T42.hlp" Releast | ||
31 | if exist Releast\nul copy "help\T42.cnt" Releast | ||
32 | echo. | ||
33 | |||
34 | |||
diff --git a/res/IDR_FLIP.ico b/res/IDR_FLIP.ico new file mode 100644 index 0000000..96f5037 --- a/dev/null +++ b/res/IDR_FLIP.ico | |||
Binary files differ | |||
diff --git a/res/IDR_FULL.ico b/res/IDR_FULL.ico new file mode 100644 index 0000000..bab7f6b --- a/dev/null +++ b/res/IDR_FULL.ico | |||
Binary files differ | |||
diff --git a/res/IDR_T42F.ico b/res/IDR_T42F.ico new file mode 100644 index 0000000..9ac57dd --- a/dev/null +++ b/res/IDR_T42F.ico | |||
Binary files differ | |||
diff --git a/res/T42-beep.wav b/res/T42-beep.wav new file mode 100644 index 0000000..40d0baa --- a/dev/null +++ b/res/T42-beep.wav | |||
Binary files differ | |||
diff --git a/res/T42-boiling.wav b/res/T42-boiling.wav new file mode 100644 index 0000000..857c5b2 --- a/dev/null +++ b/res/T42-boiling.wav | |||
Binary files differ | |||
diff --git a/res/T42-whistle.wav b/res/T42-whistle.wav new file mode 100644 index 0000000..1ad9e77 --- a/dev/null +++ b/res/T42-whistle.wav | |||
Binary files differ | |||
diff --git a/res/T42.ico b/res/T42.ico new file mode 100644 index 0000000..1f3b80c --- a/dev/null +++ b/res/T42.ico | |||
Binary files differ | |||
diff --git a/res/T42.rc2 b/res/T42.rc2 new file mode 100644 index 0000000..415b466 --- a/dev/null +++ b/res/T42.rc2 | |||
@@ -0,0 +1,13 @@ | |||
1 | // | ||
2 | // T42.RC2 - resources Microsoft Visual C++ does not edit directly | ||
3 | // | ||
4 | |||
5 | #ifdef APSTUDIO_INVOKED | ||
6 | #error this file is not editable by Microsoft Visual C++ | ||
7 | #endif //APSTUDIO_INVOKED | ||
8 | |||
9 | |||
10 | ///////////////////////////////////////////////////////////////////////////// | ||
11 | // Add manually edited resources here... | ||
12 | |||
13 | ///////////////////////////////////////////////////////////////////////////// | ||
diff --git a/res/T42calln.ico b/res/T42calln.ico new file mode 100644 index 0000000..e88ee61 --- a/dev/null +++ b/res/T42calln.ico | |||
Binary files differ | |||
diff --git a/res/T42callp.ico b/res/T42callp.ico new file mode 100644 index 0000000..5679c09 --- a/dev/null +++ b/res/T42callp.ico | |||
Binary files differ | |||
diff --git a/res/fullcup.ico b/res/fullcup.ico new file mode 100644 index 0000000..2e41084 --- a/dev/null +++ b/res/fullcup.ico | |||
Binary files differ | |||
diff --git a/resource.h b/resource.h new file mode 100644 index 0000000..5292c49 --- a/dev/null +++ b/resource.h | |||
@@ -0,0 +1,200 @@ | |||
1 | //{{NO_DEPENDENCIES}} | ||
2 | // Microsoft Developer Studio generated include file. | ||
3 | // Used by T42.rc | ||
4 | // | ||
5 | #define IDM_ABOUTBOX 0x0010 | ||
6 | #define IDD_ABOUTBOX 100 | ||
7 | #define IDS_ABOUTBOX 101 | ||
8 | #define IDD_T42VIEW 101 | ||
9 | #define IDD_T42_DIALOG 102 | ||
10 | #define IDS_ERR_MALFORMEDREMOTE 102 | ||
11 | #define IDP_SOCKETS_INIT_FAILED 103 | ||
12 | #define ID_INDICATOR_DATE 104 | ||
13 | #define IDS_STATUS_RESOLVING 105 | ||
14 | #define IDC_TRAYICON 105 | ||
15 | #define IDS_ERR_REMOTERESOLVEFAILED 106 | ||
16 | #define IDD_OPTIONS_SOUNDS 106 | ||
17 | #define IDS_ERR_CTLCREATEFAILED 107 | ||
18 | #define IDS_ERR_CTLBINDFAILED 108 | ||
19 | #define IDS_ERR_CTLGETFAILED 109 | ||
20 | #define IDS_ERR_TCPCREATEFAILED 110 | ||
21 | #define IDS_ERR_TCPBINDFAILED 111 | ||
22 | #define IDS_ERR_TCPGETFAILED 112 | ||
23 | #define IDS_STATUS_LOOKUPINVITE 113 | ||
24 | #define IDS_ERR_TCPASELFAILED 114 | ||
25 | #define IDS_STATUS_WAITINGTOCONNECT 115 | ||
26 | #define IDS_ERR_TCPCONNECTFAILED 116 | ||
27 | #define IDS_ERR_TCPLISTENFAILED 117 | ||
28 | #define IDS_ERR_LTNASELFAILED 118 | ||
29 | #define IDS_ERR_CTLLOOKUPFAILED 119 | ||
30 | #define IDS_ERR_ANNOUNCEFAILURE 120 | ||
31 | #define IDS_CTL_NOTHERE 121 | ||
32 | #define IDS_CTL_FAILED 122 | ||
33 | #define IDS_CTL_MACHUNKNOWN 123 | ||
34 | #define IDS_CTL_PERMISSIONDENIED 124 | ||
35 | #define IDS_CTL_BADREQUEST 125 | ||
36 | #define IDS_CTL_BADVERSION 126 | ||
37 | #define IDS_CTL_BADADDR 127 | ||
38 | #define IDR_MAINFRAME 128 | ||
39 | #define IDS_CTL_BADCTL 128 | ||
40 | #define IDR_T42FRAME 129 | ||
41 | #define IDS_CTL_UNKNOWNERROR 130 | ||
42 | #define IDI_FULLCUP 130 | ||
43 | #define IDS_ERR_ANNOUNCEFAILED 131 | ||
44 | #define IDR_FULLT42 131 | ||
45 | #define IDD_REMOTE 132 | ||
46 | #define IDS_ERR_LEAVINVITEFAILED 132 | ||
47 | #define IDS_ERR_TCPACCEPTFAILED 133 | ||
48 | #define IDS_STATUS_ANNOUNCING 134 | ||
49 | #define IDD_ANNOUNCE 135 | ||
50 | #define IDS_ERR_CTLLDELETEFAILED 135 | ||
51 | #define IDS_ERR_CTLRDELETEFAILED 136 | ||
52 | #define IDD_OPTIONS_FONTS 136 | ||
53 | #define IDS_ERR_TCPERROR 137 | ||
54 | #define IDB_BACK 137 | ||
55 | #define IDD_OPTIONS_SECRETARY 137 | ||
56 | #define IDS_STATUS_ESTABLISHED 138 | ||
57 | #define IDD_OPTIONS_GENERAL 138 | ||
58 | #define IDS_STATUS_CONNECTIONCLOSED 139 | ||
59 | #define IDM_POPUPS 139 | ||
60 | #define IDW_BEEP_DROP 140 | ||
61 | #define IDS_TITLE_TEAWITH 140 | ||
62 | #define IDW_ANNOUNCE_BOILING 141 | ||
63 | #define IDS_TITLE_TEAFORTWO 141 | ||
64 | #define IDW_WAKE_WHISTLE 142 | ||
65 | #define IDS_TITLE_OPTIONS 142 | ||
66 | #define IDS_SND_TEADROP 143 | ||
67 | #define IDS_SND_BOILINGTEAPOT 144 | ||
68 | #define IDI_BROWSE 145 | ||
69 | #define IDS_SND_TEAPOTWHISTLE 145 | ||
70 | #define IDS_TITLE_WAV 146 | ||
71 | #define IDI_T42CALLNEW 146 | ||
72 | #define IDS_FILTER_WAV 147 | ||
73 | #define IDI_T42CALLPROCESSED 147 | ||
74 | #define IDS_FMT_T42LOCAL 148 | ||
75 | #define IDR_FLIPPEDCUP 148 | ||
76 | #define IDS_FMT_T42REMOTE 149 | ||
77 | #define IDS_FMT_T42SYSTEM 150 | ||
78 | #define IDI_PREPLAY 150 | ||
79 | #define IDS_CHARSET_AUTO 151 | ||
80 | #define IDS_DEFAULTGREETING 152 | ||
81 | #define IDS_DEFAULTPARTING 153 | ||
82 | #define IDS_FILENAME_T42 153 | ||
83 | #define IDS_FORMAT_TIME 154 | ||
84 | #define IDS_RTF_HEAD 154 | ||
85 | #define IDS_FILE_T42CALLS 155 | ||
86 | #define IDS_FORMAT_CALLTIME 156 | ||
87 | #define IDS_FILTER_RTF 157 | ||
88 | #define IDS_FORMAT_CALLDURATION 158 | ||
89 | #define IDS_FORMAT_CALLTIMELONG 159 | ||
90 | #define IDS_FORMAT_T42CALLHEADER 160 | ||
91 | #define IDS_WSA_ENETDOWN 161 | ||
92 | #define IDS_WSA_ECONNRESET 162 | ||
93 | #define IDS_WSA_ECONNABORTED 163 | ||
94 | #define IDS_WSA_ECONNREFUSED 164 | ||
95 | #define IDS_WSA_ENETUNREACH 165 | ||
96 | #define IDS_WSA_ETIMEDOUT 166 | ||
97 | #define IDS_CONNECTIONCLOSED 167 | ||
98 | #define IDS_WSA_NODATA 168 | ||
99 | #define IDS_ERR_CONNECTIONCLOSED 169 | ||
100 | #define IDS_WSA_HOSTNOTFOUND 170 | ||
101 | #define IDS_KLEVERNET_URL 171 | ||
102 | #define IDS_RTF_DELIMITER 172 | ||
103 | #define IDS_RTF_TAIL 173 | ||
104 | #define IDS_FAILVALIDATE_NTALKPORT 174 | ||
105 | #define IDS_CALLOG_OPEN_FAILED 175 | ||
106 | #define IDS_CALLOG_CLOSE_FAILED 176 | ||
107 | #define IDS_DAEMON_FAIL 177 | ||
108 | #define IDS_REGISTRYKEY 178 | ||
109 | #define IDS_DEFAULTCALLER 179 | ||
110 | #define IDC_CALLEE 1000 | ||
111 | #define IDC_TALK 1001 | ||
112 | #define IDC_OPTIONS 1002 | ||
113 | #define IDC_SPLIT 1005 | ||
114 | #define IDC_CALLER 1006 | ||
115 | #define IDC_TTY 1008 | ||
116 | #define IDC_SECRETARY 1009 | ||
117 | #define IDC_PREVIEW 1011 | ||
118 | #define IDC_CALLS 1012 | ||
119 | #define IDC_ONCALL 1015 | ||
120 | #define IDC_T42BELL_BROWSE 1016 | ||
121 | #define IDC_ONCALLAWAY 1016 | ||
122 | #define IDC_T42BELL 1017 | ||
123 | #define IDC_T42PROMPT 1018 | ||
124 | #define IDC_T42PROMPT_BROWSE 1019 | ||
125 | #define IDC_T42PROMPT_LOOP 1020 | ||
126 | #define IDC_T42WAKE 1021 | ||
127 | #define IDC_T42WAKE_BROWSE 1022 | ||
128 | #define IDC_SAMPLE 1023 | ||
129 | #define IDC_T42BELL_PLAY 1023 | ||
130 | #define IDC_FORMATNAME 1024 | ||
131 | #define IDC_T42PROMPT_PLAY 1024 | ||
132 | #define IDC_FACES 1025 | ||
133 | #define IDC_T42WAKE_PLAY 1025 | ||
134 | #define IDC_FONTSIZE 1026 | ||
135 | #define IDC_FORECOLOR 1027 | ||
136 | #define IDC_BACKCOLOR 1028 | ||
137 | #define IDC_BOLD 1029 | ||
138 | #define IDC_ITALIC 1030 | ||
139 | #define IDC_CHARSET 1031 | ||
140 | #define IDC_UNDERLINE 1032 | ||
141 | #define IDC_STRIKEOUT 1033 | ||
142 | #define IDC_TIP 1034 | ||
143 | #define IDC_GREETING 1035 | ||
144 | #define IDC_DOBYTELIMIT 1038 | ||
145 | #define IDC_BYTELIMIT 1039 | ||
146 | #define IDC_DOTIMELIMIT 1040 | ||
147 | #define IDC_TIMELIMIT 1041 | ||
148 | #define IDC_PARTING 1042 | ||
149 | #define IDC_WINLIMIT 1042 | ||
150 | #define IDC_AWAY 1044 | ||
151 | #define IDC_KLEVERNET 1045 | ||
152 | #define IDC_NOTHERE 1046 | ||
153 | #define IDC_REFUSE 1047 | ||
154 | #define IDC_DOWINLIMIT 1051 | ||
155 | #define IDC_TIMESPIN 1052 | ||
156 | #define IDC_WINSPIN 1053 | ||
157 | #define IDC_NTALKPORT 1053 | ||
158 | #define IDC_CHARSPIN 1054 | ||
159 | #define IDC_NTALKPORTSPIN 1054 | ||
160 | #define ID_TALK_ABORT 32771 | ||
161 | #define ID_TALK_CLOSE 32772 | ||
162 | #define ID_WINDOW_CENTERSPLITTER 32773 | ||
163 | #define ID_WINDOW_SPLITEQUALLY 32774 | ||
164 | #define ID_WINDOW_SAVELAYOUT 32775 | ||
165 | #define ID_WINDOW_AUTOSAVELAYOUT 32776 | ||
166 | #define ID_TALK_REMOTEUSER 32777 | ||
167 | #define ID_WINDOW_HORIZONTALSPLIT 32778 | ||
168 | #define ID_WINDOW_VERTICALSPLIT 32779 | ||
169 | #define ID_TRAY_T42 32780 | ||
170 | #define ID_TRAY_OPTIONS 32781 | ||
171 | #define ID_TRAY_SHOWMAINWINDOW 32782 | ||
172 | #define ID_TRAY_EXIT 32783 | ||
173 | #define ID_TALK_RECONNECT 32784 | ||
174 | #define ID_WINDOW_HIDEINTRAYONMINIMIZE 32785 | ||
175 | #define ID_SLEEP_SLEEP 32786 | ||
176 | #define ID_SLEEP_MAKESOUND 32788 | ||
177 | #define ID_SLEEP_POPUP 32789 | ||
178 | #define ID_SLEEP_WAKEUPACTION_MAKESOUND 32790 | ||
179 | #define ID_SLEEP_WAKEUPACTION_POPUP 32791 | ||
180 | #define ID_SLEEP_SLEEPONMINIMIZE 32792 | ||
181 | #define ID_SLEEP_MINIMIZEONSLEEP 32793 | ||
182 | #define ID_CALLLOG_CALLBACK 32794 | ||
183 | #define ID_CALLLOG_DELETE 32795 | ||
184 | #define ID_CALLLOG_SAVETOFILE 32796 | ||
185 | #define ID_CALLLOG_EMPTYLOG 32797 | ||
186 | #define ID_CALLLOG_MARKASNEW 32798 | ||
187 | #define ID_CALLLOG_MARKASPROCESSED 32799 | ||
188 | #define ID_TRAY_AWAY 32800 | ||
189 | #define ID_TEA_SAVE 32801 | ||
190 | |||
191 | // Next default values for new objects | ||
192 | // | ||
193 | #ifdef APSTUDIO_INVOKED | ||
194 | #ifndef APSTUDIO_READONLY_SYMBOLS | ||
195 | #define _APS_NEXT_RESOURCE_VALUE 151 | ||
196 | #define _APS_NEXT_COMMAND_VALUE 32802 | ||
197 | #define _APS_NEXT_CONTROL_VALUE 1055 | ||
198 | #define _APS_NEXT_SYMED_VALUE 106 | ||
199 | #endif | ||
200 | #endif | ||
diff --git a/shared-code/BTreendex.h b/shared-code/BTreendex.h new file mode 100644 index 0000000..88109ab --- a/dev/null +++ b/shared-code/BTreendex.h | |||
@@ -0,0 +1,595 @@ | |||
1 | #ifndef__BTREENDEX_H | ||
2 | #define__BTREENDEX_H | ||
3 | |||
4 | #include "Dynamide.h" | ||
5 | |||
6 | namespace Klever { | ||
7 | |||
8 | template<class key,class value,int treeOrder,int cluster> | ||
9 | class CBTreendex : public CObject{ | ||
10 | public: | ||
11 | typedef LONG CBTPageRef; | ||
12 | struct CBTRecordRef { | ||
13 | CBTPageRef m_Page; | ||
14 | INT m_Offset; | ||
15 | CBTRecordRef(CBTPageRef page=-1,INT offset=-1) : m_Page(page), m_Offset(offset) {} | ||
16 | }; | ||
17 | class CBTRecord : public CObject { | ||
18 | public: | ||
19 | CBTPageRef m_ptrLeft; | ||
20 | CBTPageRef m_ptrRight; | ||
21 | key m_Key; | ||
22 | value m_Value; | ||
23 | CBTRecord() : m_ptrLeft(-1), m_ptrRight(-1) {} | ||
24 | CBTRecord(key& _key,value& _value,CBTPageRef left=-1,CBTPageRef right=-1) : m_Key(_key), m_Value(_value), m_ptrLeft(left), m_ptrRight(right) {} | ||
25 | CBTRecord(CBTRecord& r) : m_Key(r.m_Key), m_Value(r.m_Value), m_ptrLeft(r.m_ptrLeft), m_ptrRight(r.m_ptrRight) {} | ||
26 | |||
27 | CBTRecord& operator=(CBTRecord& r) {m_Key=r.m_Key, m_Value=r.m_Value, m_ptrLeft=r.m_ptrLeft, m_ptrRight=r.m_ptrRight;return *this;} | ||
28 | |||
29 | void Serialize(CArchive& ar) { | ||
30 | if(ar.IsStoring()){ | ||
31 | ar << m_ptrLeft; | ||
32 | ar << m_ptrRight; | ||
33 | }else{ | ||
34 | ar >> m_ptrLeft; | ||
35 | ar >> m_ptrRight; | ||
36 | } | ||
37 | SerializeElements(ar,&m_Key,1); | ||
38 | SerializeElements(ar,&m_Value,1); | ||
39 | } | ||
40 | }; | ||
41 | class CBTPage : public CArray<CBTRecord,CBTRecord&> { | ||
42 | public: | ||
43 | void Serialize(CArchive& ar) { | ||
44 | int nCount = -1; | ||
45 | if(ar.IsStoring()){ | ||
46 | nCount = GetSize(); | ||
47 | ar << nCount; | ||
48 | }else{ | ||
49 | nCount = 0; | ||
50 | ar >> nCount; | ||
51 | RemoveAll(); | ||
52 | SetSize(nCount); | ||
53 | } | ||
54 | for(int tmp=0;tmp<nCount;tmp++) | ||
55 | ElementAt(tmp).Serialize(ar); | ||
56 | } | ||
57 | }; | ||
58 | typedef CDynamide<256,cluster> CBTDyna; | ||
59 | typedef CBTDyna::CDynaFile CBTDynaFile; | ||
60 | typedef CArray<CBTRecordRef,CBTRecordRef&> CBTRStack; | ||
61 | |||
62 | CBTDyna m_BT; | ||
63 | struct_btCrap { | ||
64 | BOOL m_bRootSet; | ||
65 | CBTPageRef m_Root; | ||
66 | } *m_BTCrap; | ||
67 | BOOL m_bRO; | ||
68 | CBTRStack m_btStack; | ||
69 | CBTPage m_stackTop; | ||
70 | |||
71 | CBTreendex() {} | ||
72 | ~CBTreendex() { Close(); } | ||
73 | BOOL Attach(CFile* file,BOOL bAutodelete) { | ||
74 | m_bRO = FALSE; | ||
75 | if(!m_BT.Attach(file,bAutodelete)) | ||
76 | return FALSE; | ||
77 | return Attach(); | ||
78 | } | ||
79 | BOOL Open(LPCTSTR file,BOOL bReadOnly) { | ||
80 | if(!m_BT.Open(file,bReadOnly)) | ||
81 | return FALSE; | ||
82 | m_bRO = bReadOnly; | ||
83 | return Attach(); | ||
84 | } | ||
85 | BOOL Create(LPCTSTR file) { | ||
86 | try{ | ||
87 | CFile* f = new CFile(file,CFile::modeCreate|CFile::modeReadWrite|CFile::shareDenyRead|CFile::shareDenyWrite|CFile::typeBinary); | ||
88 | ASSERT(f); | ||
89 | return Attach(f,TRUE); | ||
90 | }catch(CException* e){ | ||
91 | e->Delete(); | ||
92 | return FALSE; | ||
93 | } | ||
94 | } | ||
95 | BOOL Attach() { | ||
96 | ASSERT(m_BT.IsOpened()); | ||
97 | m_BTCrap = (_btCrap*)m_BT.m_FB.crap; | ||
98 | if(!m_BTCrap->m_bRootSet){ | ||
99 | m_BTCrap->m_Root = AllocatePage(); | ||
100 | if(m_BTCrap->m_Root<0) | ||
101 | return FALSE; | ||
102 | m_BTCrap->m_bRootSet = TRUE; | ||
103 | m_BT.Write1stBlock(); | ||
104 | } | ||
105 | return TRUE; | ||
106 | } | ||
107 | BOOL Close() { | ||
108 | m_BT.Close(); | ||
109 | return TRUE; | ||
110 | } | ||
111 | BOOL IsOpened() { | ||
112 | return m_BT.IsOpened(); | ||
113 | } | ||
114 | |||
115 | BOOL Lookup(key& _key,value& value) { | ||
116 | if(!IsOpened()) | ||
117 | return FALSE; | ||
118 | ASSERT(m_BTCrap->m_bRootSet); | ||
119 | if(!SeekToPage(_key)) | ||
120 | return FALSE; | ||
121 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
122 | if(rr.m_Offset<0) | ||
123 | return FALSE; | ||
124 | ASSERT(rr.m_Offset<m_stackTop.GetSize()); | ||
125 | if(_key != m_stackTop[rr.m_Offset].m_Key) | ||
126 | return FALSE; | ||
127 | value = m_stackTop[rr.m_Offset].m_Value; | ||
128 | return TRUE; | ||
129 | } | ||
130 | BOOL Add(key& _key,value& _value) { | ||
131 | if(!IsOpened()) | ||
132 | return FALSE; | ||
133 | ASSERT(m_BTCrap->m_bRootSet); | ||
134 | if(!SeekToPage(_key)) | ||
135 | return FALSE; | ||
136 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
137 | CBTRecord nuRecord(_key,_value); | ||
138 | if(rr.m_Offset<0){ | ||
139 | if(m_stackTop.GetSize()) | ||
140 | nuRecord.m_ptrLeft = m_stackTop[m_stackTop.GetUpperBound()].m_ptrRight; | ||
141 | }else if(rr.m_Offset==0){ | ||
142 | nuRecord.m_ptrRight = m_stackTop[0].m_ptrLeft; | ||
143 | }else{ | ||
144 | nuRecord.m_ptrLeft = m_stackTop[rr.m_Offset-1].m_ptrRight; | ||
145 | nuRecord.m_ptrRight = m_stackTop[rr.m_Offset].m_ptrLeft; | ||
146 | } | ||
147 | // ASSERT(rr.m_Offset==0 || (m_stackTop[rr.m_Offset-1].m_Key<_key && m_stackTop[rr.m_Offset-1].m_ptrRight<0)); | ||
148 | // ASSERT(rr.m_Offset<0 || m_stackTop[rr.m_Offset].m_Key>=_key && m_stackTop[rr.m_Offset].m_ptrLeft<0); | ||
149 | if(rr.m_Offset>=0 && m_stackTop[rr.m_Offset].m_Key==_key){ | ||
150 | // Exact match found - just replace. | ||
151 | m_stackTop[rr.m_Offset].m_Value = _value; | ||
152 | if(!SavePage(rr.m_Page,m_stackTop)) | ||
153 | return FALSE; | ||
154 | return TRUE; | ||
155 | } | ||
156 | // Split the page and propagate the split if needed.. | ||
157 | // Insert new element at rr.m_Offset.. | ||
158 | BOOL nuisnew = TRUE; | ||
159 | for(int sp=m_btStack.GetUpperBound();sp>=0;sp--){ | ||
160 | CBTPageRef opr = m_btStack[sp].m_Page; | ||
161 | int iAt = m_btStack[sp].m_Offset; | ||
162 | CBTPage op; | ||
163 | VERIFY(LoadPage(opr,op)); | ||
164 | if(iAt<0) | ||
165 | iAt = op.GetSize(); | ||
166 | else{ | ||
167 | if(op[iAt].m_Key<nuRecord.m_Key) | ||
168 | iAt++; | ||
169 | ASSERT(iAt==op.GetSize() || op[iAt].m_Key > nuRecord.m_Key); | ||
170 | } | ||
171 | op.InsertAt(iAt,nuRecord); | ||
172 | if(iAt>0) | ||
173 | op[iAt-1].m_ptrRight=nuRecord.m_ptrLeft; | ||
174 | if(iAt<op.GetUpperBound()) | ||
175 | op[iAt+1].m_ptrLeft=nuRecord.m_ptrRight; | ||
176 | if(op.GetSize()<=treeOrder*2){ | ||
177 | // This isn't causing overflow | ||
178 | VERIFY(SavePage(opr,op)); | ||
179 | return TRUE; | ||
180 | } | ||
181 | TRACE0("Split\n"); | ||
182 | ASSERT(op.GetSize()==(treeOrder*2+1)); | ||
183 | CBTPageRef npr = AllocatePage(); | ||
184 | ASSERT(npr>=0); | ||
185 | CBTPage np; | ||
186 | ASSERT(LoadPage(npr,np)); | ||
187 | ASSERT(!np.GetSize()); | ||
188 | nuRecord = op[treeOrder]; | ||
189 | if(iAt==treeOrder){ | ||
190 | // We're inserting central element! - drop out the stack top if this is still new one | ||
191 | for(int tmp=0;tmp<treeOrder;tmp++) | ||
192 | np.InsertAt(tmp,op[tmp]); | ||
193 | op.RemoveAt(0,treeOrder+1); | ||
194 | nuRecord.m_ptrLeft = npr; | ||
195 | nuRecord.m_ptrRight = opr; | ||
196 | if(nuisnew) | ||
197 | m_btStack.RemoveAt(m_btStack.GetUpperBound()); | ||
198 | }else{ | ||
199 | if(iAt<treeOrder){ | ||
200 | // We're inserting in the left subtree. | ||
201 | // Make newpage the right one and forget it. | ||
202 | for(int tmp=0;tmp<treeOrder;tmp++) | ||
203 | np.InsertAt(tmp,op[tmp+treeOrder+1]); | ||
204 | op.RemoveAt(treeOrder,treeOrder+1); | ||
205 | nuRecord.m_ptrLeft = opr; | ||
206 | nuRecord.m_ptrRight = npr; | ||
207 | }else{ | ||
208 | // We're inserting in the right subtree. | ||
209 | // Make newpage the left one, forget it, but also adjust offset in the stack | ||
210 | for(int tmp=0;tmp<treeOrder;tmp++) | ||
211 | np.InsertAt(tmp,op[tmp]); | ||
212 | op.RemoveAt(0,treeOrder+1); | ||
213 | nuRecord.m_ptrLeft = npr; | ||
214 | nuRecord.m_ptrRight = opr; | ||
215 | m_btStack[sp].m_Offset-=treeOrder+1; | ||
216 | } | ||
217 | // Note that we're not inserting new element anymore. | ||
218 | nuisnew = FALSE; | ||
219 | } | ||
220 | // Do, excessive sanity checks and save pages | ||
221 | ASSERT(op.GetSize()); | ||
222 | ASSERT(np.GetSize()); | ||
223 | VERIFY(SavePage(opr,op)); | ||
224 | VERIFY(SavePage(npr,np)); | ||
225 | } | ||
226 | // Here we have root page overflow, which means that we're simply putting new | ||
227 | // record in this brand new root page and also inserting this page on the bottom of the stack | ||
228 | CBTPageRef nuroot = AllocatePage(); | ||
229 | ASSERT(nuroot>=0); | ||
230 | CBTPage nurpa; | ||
231 | ASSERT(LoadPage(nuroot,nurpa)); | ||
232 | ASSERT(!nurpa.GetSize()); | ||
233 | nurpa.Add(nuRecord); | ||
234 | VERIFY(SavePage(nuroot,nurpa)); | ||
235 | m_btStack.InsertAt(0,CBTRecordRef(nuroot,0)); | ||
236 | m_BTCrap->m_Root = nuroot; | ||
237 | m_BT.Write1stBlock(); | ||
238 | return TRUE; | ||
239 | } | ||
240 | BOOL Delete(key& _key) { | ||
241 | if(!IsOpened()) | ||
242 | return FALSE; | ||
243 | ASSERT(m_BTCrap->m_bRootSet); | ||
244 | value _value; | ||
245 | if(!Lookup(_key,_value)) | ||
246 | return FALSE; | ||
247 | // Found key, check if it's a leaf | ||
248 | { | ||
249 | CBTRecordRef* rr = &m_btStack[m_btStack.GetUpperBound()]; | ||
250 | int rrIdx = m_btStack.GetUpperBound(); | ||
251 | if(m_stackTop[rr->m_Offset].m_ptrLeft>=0){ | ||
252 | ASSERT(m_stackTop[rr->m_Offset].m_ptrRight>=0); | ||
253 | // It isn't - scan for the _next_ key and do dirty deeds | ||
254 | m_btStack.Add(CBTRecordRef(m_stackTop[rr->m_Offset].m_ptrRight,0)); | ||
255 | for(;;){ | ||
256 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
257 | if(!LoadPage(rr.m_Page,m_stackTop)) | ||
258 | return FALSE; | ||
259 | if(m_stackTop[0].m_ptrLeft<0) | ||
260 | break; | ||
261 | m_btStack.Add(CBTRecordRef(m_stackTop[0].m_ptrLeft,0)); | ||
262 | } | ||
263 | // We have a leaf node here, replace victim with the first element and kill it. | ||
264 | CBTPage uppage; | ||
265 | rr = &m_btStack[rrIdx]; | ||
266 | if(!LoadPage(rr->m_Page,uppage)) | ||
267 | return FALSE; | ||
268 | uppage[rr->m_Offset].m_Key=m_stackTop[0].m_Key; uppage[rr->m_Offset].m_Value=m_stackTop[0].m_Value; | ||
269 | m_stackTop.RemoveAt(0); | ||
270 | if(!(SavePage(rr->m_Page,uppage) && SavePage(m_btStack[m_btStack.GetUpperBound()].m_Page,m_stackTop))) | ||
271 | return FALSE; | ||
272 | }else{ | ||
273 | ASSERT(m_stackTop[rr->m_Offset].m_ptrRight<0); | ||
274 | m_stackTop.RemoveAt(rr->m_Offset); | ||
275 | if(!SavePage(rr->m_Page,m_stackTop)) | ||
276 | return FALSE; | ||
277 | } | ||
278 | } | ||
279 | // We have a page to check for underflow at the top of the stack now. | ||
280 | for(;;){ | ||
281 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
282 | if(!LoadPage(rr.m_Page,m_stackTop)) | ||
283 | return FALSE; | ||
284 | if(m_stackTop.GetSize()>=treeOrder || m_btStack.GetSize()==1) | ||
285 | return TRUE; | ||
286 | CBTRecordRef& rr1 = m_btStack[m_btStack.GetUpperBound()-1]; | ||
287 | CBTPage daddy; | ||
288 | if(!LoadPage(rr1.m_Page,daddy)) | ||
289 | return FALSE; | ||
290 | CBTPageRef nPage = daddy[rr1.m_Offset].m_ptrRight; | ||
291 | BOOL bRight=TRUE; | ||
292 | if(nPage<0 || nPage==rr.m_Page){ | ||
293 | nPage = daddy[rr1.m_Offset].m_ptrLeft; | ||
294 | bRight = FALSE; | ||
295 | } | ||
296 | ASSERT(nPage>=0 && nPage!=rr.m_Page); | ||
297 | CBTPage neighbor; | ||
298 | if(!LoadPage(nPage,neighbor)) | ||
299 | return FALSE; | ||
300 | // Here we have possibly two cases: | ||
301 | // 1. Neighboring page can share some data with use, then do share and leave | ||
302 | // 2. Neighboring page is of treeorder in size, then merge and propagate | ||
303 | if(neighbor.GetSize()>treeOrder){ | ||
304 | TRACE0("Redistributing..\n"); | ||
305 | // Borrow some data from there. | ||
306 | int toBorrow = neighbor.GetSize()-treeOrder; | ||
307 | toBorrow=toBorrow/2+1; | ||
308 | ASSERT(toBorrow); | ||
309 | if(bRight) | ||
310 | m_stackTop.Add(CBTRecord(daddy[rr1.m_Offset].m_Key,daddy[rr1.m_Offset].m_Value,m_stackTop[m_stackTop.GetUpperBound()].m_ptrRight,neighbor[0].m_ptrLeft)); | ||
311 | else | ||
312 | m_stackTop.InsertAt(0,CBTRecord(daddy[rr1.m_Offset].m_Key,daddy[rr1.m_Offset].m_Value,neighbor[neighbor.GetUpperBound()].m_ptrRight,m_stackTop[0].m_ptrLeft)); | ||
313 | for(toBorrow--;toBorrow;toBorrow--){ | ||
314 | if(bRight){ | ||
315 | m_stackTop.Add(neighbor[0]); | ||
316 | neighbor.RemoveAt(0); | ||
317 | }else{ | ||
318 | m_stackTop.InsertAt(0,neighbor[neighbor.GetUpperBound()]); | ||
319 | neighbor.RemoveAt(neighbor.GetUpperBound()); | ||
320 | } | ||
321 | } | ||
322 | daddy[rr1.m_Offset].m_Key = neighbor[bRight?0:neighbor.GetUpperBound()].m_Key; daddy[rr1.m_Offset].m_Value = neighbor[bRight?0:neighbor.GetUpperBound()].m_Value; | ||
323 | neighbor.RemoveAt(bRight?0:neighbor.GetUpperBound()); | ||
324 | if(!(SavePage(rr1.m_Page,daddy) && SavePage(nPage,neighbor) && SavePage(rr.m_Page,m_stackTop))) | ||
325 | return FALSE; | ||
326 | rr.m_Offset = -1;// *** Point to the next?? | ||
327 | return TRUE; | ||
328 | } | ||
329 | TRACE0("Merging..\n"); | ||
330 | // We need to merge pages here.. | ||
331 | // We will merge them at stacktop, then we'll discard neighbor guy.. | ||
332 | if(bRight) | ||
333 | m_stackTop.Add(CBTRecord(daddy[rr1.m_Offset].m_Key,daddy[rr1.m_Offset].m_Value,m_stackTop[m_stackTop.GetUpperBound()].m_ptrRight,neighbor[0].m_ptrLeft)); | ||
334 | else | ||
335 | m_stackTop.InsertAt(0,CBTRecord(daddy[rr1.m_Offset].m_Key,daddy[rr1.m_Offset].m_Value,neighbor[neighbor.GetUpperBound()].m_ptrRight,m_stackTop[0].m_ptrLeft)); | ||
336 | if(bRight){ | ||
337 | while(neighbor.GetSize()){ | ||
338 | m_stackTop.Add(neighbor[0]); | ||
339 | neighbor.RemoveAt(0); | ||
340 | } | ||
341 | }else{ | ||
342 | while(neighbor.GetSize()){ | ||
343 | m_stackTop.InsertAt(0,neighbor[neighbor.GetUpperBound()]); | ||
344 | neighbor.RemoveAt(neighbor.GetUpperBound()); | ||
345 | } | ||
346 | } | ||
347 | if(rr1.m_Offset>0) | ||
348 | daddy[rr1.m_Offset-1].m_ptrRight=rr.m_Page; | ||
349 | if(rr1.m_Offset<daddy.GetUpperBound()) | ||
350 | daddy[rr1.m_Offset+1].m_ptrLeft=rr.m_Page; | ||
351 | daddy.RemoveAt(rr1.m_Offset); | ||
352 | if(!(SavePage(rr1.m_Page,daddy) && SavePage(rr.m_Page,m_stackTop))) | ||
353 | return FALSE; | ||
354 | VERIFY(DeallocatePage(nPage)); | ||
355 | m_btStack.RemoveAt(m_btStack.GetUpperBound()); | ||
356 | } | ||
357 | return FALSE; | ||
358 | } | ||
359 | BOOL GoFirst() { | ||
360 | if(!IsOpened()) | ||
361 | return FALSE; | ||
362 | ASSERT(m_BTCrap->m_bRootSet); | ||
363 | m_btStack.RemoveAll(); | ||
364 | m_btStack.Add(CBTRecordRef(m_BTCrap->m_Root,-1)); | ||
365 | for(;;){ | ||
366 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
367 | if(!LoadPage(rr.m_Page,m_stackTop)) | ||
368 | return FALSE; | ||
369 | if(!m_stackTop.GetSize()){ | ||
370 | ASSERT(m_btStack.GetSize()==1); | ||
371 | return FALSE; | ||
372 | } | ||
373 | rr.m_Offset = 0; | ||
374 | if(m_stackTop[rr.m_Offset].m_ptrLeft<0) | ||
375 | return TRUE; | ||
376 | m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrLeft,-1)); | ||
377 | } | ||
378 | } | ||
379 | BOOL GoLast() { | ||
380 | if(!IsOpened()) | ||
381 | return FALSE; | ||
382 | ASSERT(m_BTCrap->m_bRootSet); | ||
383 | m_btStack.RemoveAll(); | ||
384 | m_btStack.Add(CBTRecordRef(m_BTCrap->m_Root,-1)); | ||
385 | for(;;){ | ||
386 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
387 | if(!LoadPage(rr.m_Page,m_stackTop)) | ||
388 | return FALSE; | ||
389 | if(!m_stackTop.GetSize()){ | ||
390 | ASSERT(m_btStack.GetSize()==1); | ||
391 | return FALSE; | ||
392 | } | ||
393 | rr.m_Offset = m_stackTop.GetUpperBound(); | ||
394 | if(m_stackTop[rr.m_Offset].m_ptrRight<0) | ||
395 | return TRUE; | ||
396 | m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset++].m_ptrRight,-1)); | ||
397 | } | ||
398 | } | ||
399 | BOOL GoNext() { | ||
400 | if(!IsOpened()) | ||
401 | return FALSE; | ||
402 | if(!(m_btStack.GetSize() && m_btStack[m_btStack.GetUpperBound()].m_Offset>=0)) | ||
403 | return FALSE; | ||
404 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
405 | if(!LoadPage(rr.m_Page,m_stackTop)) | ||
406 | return FALSE; | ||
407 | ASSERT(rr.m_Offset<m_stackTop.GetSize()); | ||
408 | if(m_stackTop[rr.m_Offset].m_ptrRight>=0){ | ||
409 | // Advance pointer in this page and dive into subtree | ||
410 | // going left and left until we have nowhere to go. | ||
411 | // TRACE1("Dive into page %lu",m_stackTop[rr.m_Offset].m_ptrRight); | ||
412 | m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset++].m_ptrRight,0)); | ||
413 | for(;;){ | ||
414 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
415 | ASSERT(rr.m_Offset==0); | ||
416 | if(!LoadPage(rr.m_Page,m_stackTop)) | ||
417 | return FALSE; | ||
418 | if(m_stackTop[rr.m_Offset].m_ptrLeft<0) | ||
419 | break; | ||
420 | // TRACE1(", %lu",m_stackTop[rr.m_Offset].m_ptrLeft); | ||
421 | m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrLeft,0)); | ||
422 | } | ||
423 | // TRACE0("\n"); | ||
424 | return TRUE; | ||
425 | }else if(rr.m_Offset<m_stackTop.GetUpperBound()){ | ||
426 | rr.m_Offset++; | ||
427 | return TRUE; | ||
428 | } | ||
429 | // We're at the end of page go up until we're done or we have data. | ||
430 | m_btStack.RemoveAt(m_btStack.GetUpperBound()); | ||
431 | // TRACE0("Go up"); | ||
432 | while(m_btStack.GetSize()){ | ||
433 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
434 | if(!LoadPage(rr.m_Page,m_stackTop)) | ||
435 | return FALSE; | ||
436 | if(rr.m_Offset<m_stackTop.GetSize()){ | ||
437 | // TRACE0("\n"); | ||
438 | return TRUE; | ||
439 | } | ||
440 | // TRACE0(", up"); | ||
441 | m_btStack.RemoveAt(m_btStack.GetUpperBound()); | ||
442 | } | ||
443 | // TRACE0("\nBtree is done\n"); | ||
444 | return FALSE; | ||
445 | } | ||
446 | BOOL GoPrev() { | ||
447 | if(!IsOpened()) | ||
448 | return FALSE; | ||
449 | if(!(m_btStack.GetSize() && m_btStack[m_btStack.GetUpperBound()].m_Offset>=0)) | ||
450 | return FALSE; | ||
451 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
452 | if(!LoadPage(rr.m_Page,m_stackTop)) | ||
453 | return FALSE; | ||
454 | ASSERT(rr.m_Offset<m_stackTop.GetSize()); | ||
455 | if(m_stackTop[rr.m_Offset].m_ptrLeft>=0){ | ||
456 | // Dive in and go right and right from the rightmost until | ||
457 | // we have nowhere to go. | ||
458 | m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrLeft,-1)); | ||
459 | for(;;){ | ||
460 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
461 | if(!LoadPage(rr.m_Page,m_stackTop)) | ||
462 | return FALSE; | ||
463 | rr.m_Offset = m_stackTop.GetUpperBound(); | ||
464 | if(m_stackTop[rr.m_Offset].m_ptrRight<0) | ||
465 | return TRUE; | ||
466 | m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset++].m_ptrRight,-1)); | ||
467 | } | ||
468 | return TRUE; | ||
469 | }else if(rr.m_Offset>0){ | ||
470 | rr.m_Offset--; | ||
471 | return TRUE; | ||
472 | } | ||
473 | // We're at the leftmost element in page - go up and left until we're | ||
474 | // done or we have data. | ||
475 | m_btStack.RemoveAt(m_btStack.GetUpperBound()); | ||
476 | while(m_btStack.GetSize()){ | ||
477 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
478 | if(!LoadPage(rr.m_Page,m_stackTop)) | ||
479 | return FALSE; | ||
480 | rr.m_Offset--; | ||
481 | if(rr.m_Offset>=0) | ||
482 | return TRUE; | ||
483 | m_btStack.RemoveAt(m_btStack.GetUpperBound()); | ||
484 | } | ||
485 | // No more data - we were at the first element in tree. | ||
486 | return FALSE; | ||
487 | } | ||
488 | BOOL GetThis(key& _key,value& _value) { | ||
489 | if(!IsOpened()) | ||
490 | return FALSE; | ||
491 | // *** MORE CHECKING | ||
492 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
493 | if(!LoadPage(rr.m_Page,m_stackTop)) | ||
494 | return FALSE; | ||
495 | _key = m_stackTop[rr.m_Offset].m_Key; | ||
496 | _value = m_stackTop[rr.m_Offset].m_Value; | ||
497 | return TRUE; | ||
498 | } | ||
499 | |||
500 | BOOL SeekToPage(const key& _key) { | ||
501 | ASSERT(IsOpened()); | ||
502 | ASSERT(m_BTCrap->m_bRootSet); | ||
503 | m_btStack.RemoveAll(); | ||
504 | m_btStack.Add(CBTRecordRef(m_BTCrap->m_Root,-1)); | ||
505 | for(;;){ | ||
506 | CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()]; | ||
507 | if(!LoadPage(rr.m_Page,m_stackTop)) | ||
508 | return FALSE; | ||
509 | ASSERT(m_stackTop.GetSize() || !m_btStack.GetUpperBound()); | ||
510 | if(!m_stackTop.GetSize()){ | ||
511 | rr.m_Offset=-1; | ||
512 | return TRUE; | ||
513 | } | ||
514 | for(rr.m_Offset=0;rr.m_Offset<m_stackTop.GetSize();rr.m_Offset++){ | ||
515 | if(_key == m_stackTop[rr.m_Offset].m_Key) | ||
516 | return TRUE; | ||
517 | if(_key < m_stackTop[rr.m_Offset].m_Key){ | ||
518 | ASSERT(rr.m_Offset==0 || m_stackTop[rr.m_Offset].m_ptrLeft==m_stackTop[rr.m_Offset-1].m_ptrRight); | ||
519 | if(m_stackTop[rr.m_Offset].m_ptrLeft<0) | ||
520 | return TRUE; | ||
521 | m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrLeft,-1)); | ||
522 | break; | ||
523 | } | ||
524 | if(rr.m_Offset==m_stackTop.GetUpperBound()){ | ||
525 | if(m_stackTop[rr.m_Offset].m_ptrRight<0){ | ||
526 | rr.m_Offset=-1; | ||
527 | return TRUE; | ||
528 | } | ||
529 | m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrRight,-1)); | ||
530 | break; | ||
531 | } | ||
532 | } | ||
533 | } | ||
534 | } | ||
535 | |||
536 | BOOL LoadPage(CBTPageRef ref,CBTPage& page) { | ||
537 | CFile* pageFile = m_BT.OpenFile(ref); | ||
538 | if(!pageFile) | ||
539 | return FALSE; | ||
540 | BOOL rv = TRUE; | ||
541 | try{ | ||
542 | CArchive ar(pageFile,CArchive::load); | ||
543 | page.Serialize(ar); | ||
544 | if(m_bRO) | ||
545 | page.FreeExtra();// ** ??? | ||
546 | ar.Close(); | ||
547 | }catch(CException* e){ | ||
548 | e->Delete(); | ||
549 | rv = FALSE; | ||
550 | } | ||
551 | delete pageFile; | ||
552 | return rv; | ||
553 | } | ||
554 | BOOL SavePage(CBTPageRef ref,CBTPage& page) { | ||
555 | CFile* pageFile = m_BT.OpenFile(ref); | ||
556 | if(!pageFile) | ||
557 | return FALSE; | ||
558 | BOOL rv = TRUE; | ||
559 | try{ | ||
560 | CArchive ar(pageFile,CArchive::store); | ||
561 | page.Serialize(ar); | ||
562 | ar.Close(); | ||
563 | }catch(CException* e){ | ||
564 | e->Delete(); | ||
565 | rv = FALSE; | ||
566 | } | ||
567 | delete pageFile; | ||
568 | return rv; | ||
569 | } | ||
570 | CBTPageRef AllocatePage() { | ||
571 | CBTDynaFile* pageFile = m_BT.CreateFile(); | ||
572 | if(!pageFile) | ||
573 | return -1; | ||
574 | CBTPage nothing; | ||
575 | CBTPageRef rv = pageFile->GetFile(); | ||
576 | try{ | ||
577 | CArchive ar(pageFile,CArchive::store); | ||
578 | nothing.Serialize(ar); | ||
579 | ar.Close(); | ||
580 | }catch(CException* e){ | ||
581 | e->Delete(); | ||
582 | rv = -1; | ||
583 | } | ||
584 | delete pageFile; | ||
585 | return rv; | ||
586 | } | ||
587 | BOOL DeallocatePage(CBTPageRef ref) { | ||
588 | return m_BT.DeleteFile(ref); | ||
589 | } | ||
590 | |||
591 | }; | ||
592 | |||
593 | }; | ||
594 | |||
595 | #endif// __BTREENDEX_H | ||
diff --git a/shared-code/BellsNWhistles.h b/shared-code/BellsNWhistles.h new file mode 100644 index 0000000..1de77ae --- a/dev/null +++ b/shared-code/BellsNWhistles.h | |||
@@ -0,0 +1,146 @@ | |||
1 | #ifndef__BELLSNWHISTLES_H | ||
2 | #define __BELLSNWHISTLES_H | ||
3 | |||
4 | class CBellsNWhistles{ | ||
5 | public: | ||
6 | class CBang { | ||
7 | public: | ||
8 | CString m_codeName; | ||
9 | enum_bangType { | ||
10 | bangNone, bangSpeaker, bangSystem, bangResource, | ||
11 | bangWaveform | ||
12 | }m_type; | ||
13 | BOOL m_bLoop; | ||
14 | union{ | ||
15 | UINT system; | ||
16 | LPCTSTR resource; | ||
17 | LPCTSTR wave; | ||
18 | |||
19 | LPCTSTR str; | ||
20 | UINT id; | ||
21 | }; | ||
22 | CString m_strWave; | ||
23 | CBang() : m_type(bangNone), m_bLoop(FALSE) {} | ||
24 | }; | ||
25 | typedef CTypedPtrMap<CMapStringToPtr,CString,CBang*> CBangs; | ||
26 | structCBelling { | ||
27 | LPCSTR snd; | ||
28 | HMODULE hm; | ||
29 | DWORD flags; | ||
30 | CBelling(LPCSTR snd,HMODULE hm,DWORD flags) : snd(snd), hm(hm), | ||
31 | flags(flags) {} | ||
32 | CBelling(CBelling& s) : snd(s.snd), hm(s.hm), flags(s.flags) {} | ||
33 | CBelling& operator=(CBelling& s) { | ||
34 | snd=s.snd; hm=s.hm; flags=s.flags; | ||
35 | return *this; | ||
36 | } | ||
37 | }; | ||
38 | typedef CBelling* Whistling; | ||
39 | |||
40 | CBangs m_bangs; | ||
41 | |||
42 | ~CBellsNWhistles() { | ||
43 | POSITION p = m_bangs.GetStartPosition(); | ||
44 | while(p){ | ||
45 | CString s; CBang* b; | ||
46 | m_bangs.GetNextAssoc(p,s,b); | ||
47 | delete b; | ||
48 | } | ||
49 | m_bangs.RemoveAll(); | ||
50 | } | ||
51 | |||
52 | BOOL AssignSound(LPCTSTR codeName,LPCTSTR id,CBang::_bangType type=CBang::bangWaveform) { | ||
53 | CString cn = codeName; | ||
54 | cn.MakeLower(); | ||
55 | CBang* b; | ||
56 | if(!m_bangs.Lookup(cn,b)) { | ||
57 | b = new CBang; | ||
58 | b->m_codeName=cn; | ||
59 | m_bangs[cn]=b; | ||
60 | } | ||
61 | b->m_type=type; | ||
62 | b->str = id; | ||
63 | if(type==CBang::bangWaveform){ | ||
64 | b->m_strWave=id; b->str = b->m_strWave; | ||
65 | } | ||
66 | return TRUE; | ||
67 | } | ||
68 | BOOL AssignSound(LPCTSTR codeName,UINT nID,CBang::_bangType type=CBang::bangResource) { | ||
69 | CString cn = codeName; | ||
70 | cn.MakeLower(); | ||
71 | CBang* b; | ||
72 | if(!m_bangs.Lookup(cn,b)) { | ||
73 | b = new CBang; | ||
74 | b->m_codeName=cn; | ||
75 | m_bangs[cn]=b; | ||
76 | } | ||
77 | b->m_type=type; | ||
78 | b->id = nID; | ||
79 | ASSERT(type!=CBang::bangWaveform); | ||
80 | return TRUE; | ||
81 | } | ||
82 | BOOL UnassignSound(LPCTSTR codeName) { | ||
83 | CString cn = codeName; | ||
84 | cn.MakeLower(); | ||
85 | CBang* b; | ||
86 | if(m_bangs.Lookup(cn,b)) { | ||
87 | m_bangs.RemoveKey(cn); | ||
88 | delete b; | ||
89 | return TRUE; | ||
90 | } | ||
91 | return FALSE; | ||
92 | } | ||
93 | |||
94 | Whistling StartSound(LPCTSTR codeName) { | ||
95 | Whistling* rv = NULL; | ||
96 | CString cn = codeName; | ||
97 | CBang* b; | ||
98 | if(!m_bangs.Lookup(cn,b)){ | ||
99 | ::PlaySound(cn,AfxGetInstanceHandle(),SND_ASYNC|SND_NODEFAULT|SND_NOWAIT|SND_FILENAME); | ||
100 | return NULL; | ||
101 | } | ||
102 | UINT flags = SND_ASYNC|SND_NODEFAULT|SND_NOWAIT; | ||
103 | LPCSTR snd = NULL; | ||
104 | switch(b->m_type){ | ||
105 | case CBang::bangNone: return NULL; | ||
106 | case CBang::bangSpeaker: MessageBeep(0xFFFFFFFF); return NULL; | ||
107 | case CBang::bangSystem: MessageBeep(b->system); return NULL; | ||
108 | case CBang::bangResource: | ||
109 | snd = b->resource; | ||
110 | flags|=SND_RESOURCE; break; | ||
111 | case CBang::bangWaveform: | ||
112 | snd = b->wave; | ||
113 | flags|=SND_FILENAME; break; | ||
114 | #ifdef _DEBUG | ||
115 | default: | ||
116 | ASSERT(FALSE); return NULL; | ||
117 | #endif | ||
118 | } | ||
119 | if(b->m_bLoop) | ||
120 | flags|=SND_LOOP; | ||
121 | HMODULE hm = AfxGetInstanceHandle(); | ||
122 | if(!::PlaySound(snd,hm,flags)) | ||
123 | return NULL; | ||
124 | return b->m_bLoop?new CBelling(snd,hm,flags):NULL; | ||
125 | } | ||
126 | BOOL StopSound(Whistling whistle) { | ||
127 | if(!whistle) | ||
128 | return FALSE; | ||
129 | ::PlaySound(whistle->snd,whistle->hm,whistle->flags|SND_PURGE); | ||
130 | delete whistle; | ||
131 | return TRUE; | ||
132 | } | ||
133 | UINT FillInCombo(CComboBox* combo) { | ||
134 | POSITION p = m_bangs.GetStartPosition(); | ||
135 | UINT rv = 0; | ||
136 | while(p) { | ||
137 | CString s; | ||
138 | CBang* b; | ||
139 | m_bangs.GetNextAssoc(p,s,b); | ||
140 | combo->AddString(s); | ||
141 | } | ||
142 | return rv; | ||
143 | } | ||
144 | }; | ||
145 | |||
146 | #endif// _BELLSNWHISTLES_H \ No newline at end of file | ||
diff --git a/shared-code/BitSet.h b/shared-code/BitSet.h new file mode 100644 index 0000000..cf36e3b --- a/dev/null +++ b/shared-code/BitSet.h | |||
@@ -0,0 +1,105 @@ | |||
1 | #ifndef__BITSET_H | ||
2 | #define __BITSET_H | ||
3 | |||
4 | namespace Klever { | ||
5 | |||
6 | class CBitSet: public CObject { | ||
7 | public: | ||
8 | CWordArray m_Bits; | ||
9 | ULONG m_BitsInSet; | ||
10 | enum{ | ||
11 | bitsPerWord = sizeof(WORD)*8 | ||
12 | }; | ||
13 | |||
14 | CBitSet(ULONG size = 0) : m_BitsInSet(0) { SetSize(size); } | ||
15 | CBitSet(CBitSet& o) : m_BitsInSet(0) { CopyFrom(o); } | ||
16 | |||
17 | void SetSize(ULONG size,BOOL bFillOnes=FALSE) { | ||
18 | UINT os = m_Bits.GetSize(); | ||
19 | UINT ns = (size+bitsPerWord-1)/bitsPerWord; | ||
20 | if(os==ns){ | ||
21 | if(os){ | ||
22 | if(bFillOnes) | ||
23 | m_Bits[m_BitsInSet/bitsPerWord]|=(~(WORD)0)<<(m_BitsInSet%bitsPerWord); | ||
24 | else | ||
25 | m_Bits[m_BitsInSet/bitsPerWord]&=~((~(WORD)0)<<(m_BitsInSet%bitsPerWord)); | ||
26 | } | ||
27 | m_BitsInSet=size; | ||
28 | }else{ | ||
29 | // *?* ASSERT((!os) || (((os-1)*bitsPerWord)<=m_BitsInSet && m_BitsInSet<(os*bitsPerWord))); | ||
30 | if(os<ns){ | ||
31 | m_Bits.SetSize(ns); | ||
32 | if(bFillOnes) | ||
33 | m_Bits[m_BitsInSet/bitsPerWord]|=(~(WORD)0)<<(m_BitsInSet%bitsPerWord); | ||
34 | else | ||
35 | m_Bits[m_BitsInSet/bitsPerWord]&=~((~(WORD)0)<<(m_BitsInSet%bitsPerWord)); | ||
36 | WORD* ws = m_Bits.GetData(); | ||
37 | ASSERT(ws); | ||
38 | memset(&ws[os],bFillOnes?0xFF:0,(ns-os)*sizeof(WORD)); | ||
39 | m_BitsInSet=size; | ||
40 | }else{ | ||
41 | m_Bits.SetSize(ns); | ||
42 | m_BitsInSet=size; | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | BOOL BitSet(UINT bit,BOOL bGrow=TRUE) { return SetBit(bit,TRUE,bGrow); } | ||
47 | BOOL BitClear(UINT bit,BOOL bGrow=TRUE) { return SetBit(bit,FALSE,bGrow); } | ||
48 | BOOL SetBit(UINT bit,BOOL state,BOOL bGrow=TRUE) { | ||
49 | if(m_BitsInSet<=bit){ | ||
50 | if(!bGrow) | ||
51 | return FALSE; | ||
52 | SetSize(bit+1); | ||
53 | } | ||
54 | WORD mask = ((WORD)1)<<(bit%bitsPerWord); | ||
55 | if(state) | ||
56 | m_Bits[bit/bitsPerWord]|=mask; | ||
57 | else | ||
58 | m_Bits[bit/bitsPerWord]&=~mask; | ||
59 | return TRUE; | ||
60 | } | ||
61 | BOOL IsSet(UINT bit) { | ||
62 | if(m_BitsInSet<=bit) | ||
63 | return FALSE; | ||
64 | return (m_Bits[bit/bitsPerWord]&(((WORD)1)<<(bit%bitsPerWord)))!=0; | ||
65 | } | ||
66 | void Invert() { | ||
67 | for(int i=m_Bits.GetUpperBound();i>=0;i--) | ||
68 | m_Bits[i]=~m_Bits[i]; | ||
69 | } | ||
70 | CBitSet& operator&=(CBitSet& o) { | ||
71 | if(o.m_BitsInSet<m_BitsInSet) | ||
72 | SetSize(o.m_BitsInSet); | ||
73 | for(int i=m_Bits.GetUpperBound();i>=0;i--) | ||
74 | m_Bits[i]&=o.m_Bits[i]; | ||
75 | return *this; | ||
76 | } | ||
77 | CBitSet& operator|=(CBitSet& o) { | ||
78 | if(o.m_BitsInSet>m_BitsInSet) | ||
79 | SetSize(o.m_BitsInSet); | ||
80 | for(int i=o.m_Bits.GetUpperBound();i>=0;i--) | ||
81 | m_Bits[i]|=o.m_Bits[i]; | ||
82 | return *this; | ||
83 | } | ||
84 | CBitSet& operator=(CBitSet& o) { | ||
85 | CopyFrom(o); | ||
86 | return *this; | ||
87 | } | ||
88 | void CopyFrom(CBitSet& o) { | ||
89 | m_BitsInSet=o.m_BitsInSet; | ||
90 | m_Bits.Copy(o.m_Bits); | ||
91 | } | ||
92 | void Serialize(CArchive& ar) { | ||
93 | if(ar.IsStoring()){ | ||
94 | ar << m_BitsInSet; | ||
95 | m_Bits.Serialize(ar); | ||
96 | }else{ | ||
97 | ar >> m_BitsInSet; | ||
98 | m_Bits.Serialize(ar); | ||
99 | } | ||
100 | } | ||
101 | }; | ||
102 | |||
103 | }; | ||
104 | |||
105 | #endif // __BITSET_H | ||
diff --git a/shared-code/Dynamide.h b/shared-code/Dynamide.h new file mode 100644 index 0000000..32c93f7 --- a/dev/null +++ b/shared-code/Dynamide.h | |||
@@ -0,0 +1,443 @@ | |||
1 | #ifndef __DYNAMIDE_H | ||
2 | #define __DYNAMIDE_H | ||
3 | |||
4 | #include "LRUCache.h" | ||
5 | |||
6 | namespace Klever { | ||
7 | |||
8 | template<int fbSize,int bSize> | ||
9 | class CDynamide : public CObject { | ||
10 | structfirstBlock { | ||
11 | LONGfreeFile; | ||
12 | BYTEcrap[fbSize-sizeof(LONG)]; | ||
13 | }; | ||
14 | structtheBlock { | ||
15 | LONGnext; | ||
16 | BYTEdata[bSize-sizeof(LONG)]; | ||
17 | }; | ||
18 | public: | ||
19 | static firstBlock FirstBlock; | ||
20 | static theBlock TheBlock; | ||
21 | private: | ||
22 | classCDynaCache : public CLRUCache<DWORD,DWORD,theBlock> { | ||
23 | public: | ||
24 | CFile* m_File; | ||
25 | BOOL m_bAutodelete; | ||
26 | CDynaCache(CFile* file,BOOL bAutodelete=TRUE) : CLRUCache<DWORD,DWORD,theBlock>(64) { | ||
27 | m_File=file; | ||
28 | m_bAutodelete=bAutodelete; | ||
29 | } | ||
30 | virtual ~CDynaCache() { | ||
31 | Flush(); | ||
32 | if(m_bAutodelete){ | ||
33 | m_File->Close(); | ||
34 | delete m_File; | ||
35 | } | ||
36 | } | ||
37 | virtual BOOL _ReadIn(DWORD idx,theBlock* data) { | ||
38 | LONG p = sizeof(firstBlock)+idx*sizeof(theBlock); | ||
39 | LONG s = m_File->Seek(p,CFile::begin); | ||
40 | if(p==s){ | ||
41 | UINT rb = m_File->Read(data,sizeof(*data)); | ||
42 | if(rb==sizeof(*data)) | ||
43 | return TRUE; | ||
44 | if(rb) | ||
45 | return FALSE; | ||
46 | memset(data,0,sizeof(*data)); | ||
47 | data->next=-1; | ||
48 | try{ | ||
49 | m_File->Write(data,sizeof(*data)); | ||
50 | }catch(CException* e){ | ||
51 | e->Delete(); | ||
52 | return FALSE; | ||
53 | } | ||
54 | }else{ | ||
55 | LONG togo = p-s; | ||
56 | ASSERT(togo>0); | ||
57 | ASSERT(!(togo%sizeof(theBlock))); | ||
58 | memset(data,0,sizeof(*data)); | ||
59 | data->next=-1; | ||
60 | while(togo>=0){ | ||
61 | try{ | ||
62 | m_File->Write(data,sizeof(*data)); | ||
63 | }catch(CException* e){ | ||
64 | e->Delete(); | ||
65 | return FALSE; | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | return TRUE; | ||
70 | } | ||
71 | virtual BOOL _WriteOut(DWORD idx,theBlock* data) { | ||
72 | LONG p = sizeof(firstBlock)+idx*sizeof(theBlock); | ||
73 | LONG s = m_File->Seek(p,CFile::begin); | ||
74 | if(p!=s) | ||
75 | return FALSE; | ||
76 | try{ | ||
77 | m_File->Write(data,sizeof(*data)); | ||
78 | }catch(CException* e){ | ||
79 | e->Delete(); | ||
80 | return FALSE; | ||
81 | } | ||
82 | return TRUE; | ||
83 | } | ||
84 | DWORD AllocateNode() { | ||
85 | LONG l = m_File->GetLength(); | ||
86 | ASSERT(!((l-sizeof(firstBlock))%sizeof(theBlock))); | ||
87 | m_File->SetLength(l+sizeof(theBlock)); | ||
88 | return (l-sizeof(firstBlock))/sizeof(theBlock); | ||
89 | } | ||
90 | BOOL Read1stBlock(firstBlock* fb) { | ||
91 | m_File->SeekToBegin(); | ||
92 | UINT rb = m_File->Read(fb,sizeof(*fb)); | ||
93 | if(rb==sizeof(*fb)) | ||
94 | return TRUE; | ||
95 | if(rb) | ||
96 | return FALSE; | ||
97 | memset(fb,0,sizeof(*fb)); | ||
98 | fb->freeFile = -1; | ||
99 | try{ | ||
100 | m_File->Write(fb,sizeof(*fb)); | ||
101 | }catch(CException* e){ | ||
102 | e->Delete(); | ||
103 | return FALSE; | ||
104 | } | ||
105 | return TRUE; | ||
106 | } | ||
107 | BOOL Write1stBlock(firstBlock* fb) { | ||
108 | m_File->SeekToBegin(); | ||
109 | try{ | ||
110 | m_File->Write(fb,sizeof(*fb)); | ||
111 | }catch(CException* e){ | ||
112 | e->Delete(); | ||
113 | return FALSE; | ||
114 | } | ||
115 | return TRUE; | ||
116 | } | ||
117 | }; | ||
118 | public: | ||
119 | class CDynaFile : public CFile{ | ||
120 | public: | ||
121 | CDynamide<fbSize,bSize>* m_Daddy; | ||
122 | CArray<LONG,LONG> m_Blocks; | ||
123 | LONG m_Position; | ||
124 | |||
125 | CDynaFile(CDynamide<fbSize,bSize>* daddy) : m_Daddy(NULL) { AttachToDaddy(daddy); } | ||
126 | virtual ~CDynaFile() { Close(); DetachFromDaddy(); } | ||
127 | |||
128 | void AttachToDaddy(CDynamide<fbSize,bSize>* daddy) { | ||
129 | ASSERT(!m_Daddy); | ||
130 | ASSERT(daddy); | ||
131 | m_Daddy=daddy; | ||
132 | m_Daddy->AttachDynaFile(this); | ||
133 | } | ||
134 | void DetachFromDaddy() { | ||
135 | ASSERT(m_Daddy); | ||
136 | ASSERT(!IsOpened()); | ||
137 | m_Daddy->DetachDynaFile(this); | ||
138 | m_Daddy=NULL; | ||
139 | } | ||
140 | |||
141 | BOOL Create() { | ||
142 | if(IsOpened()) | ||
143 | return FALSE; | ||
144 | m_Blocks.SetAtGrow(0,m_Daddy->Allocate()); | ||
145 | ASSERT(m_Blocks[0]>=0); | ||
146 | m_Position=0; | ||
147 | return TRUE; | ||
148 | } | ||
149 | BOOL Open(LONG fb) { | ||
150 | if(IsOpened()) | ||
151 | return FALSE; | ||
152 | ASSERT(fb>=0); | ||
153 | theBlock* b; | ||
154 | do{ | ||
155 | m_Blocks.Add(fb); | ||
156 | b = m_Daddy->m_File->GetCached(fb); | ||
157 | ASSERT(b); | ||
158 | fb=b->next; | ||
159 | if(m_Blocks[m_Blocks.GetUpperBound()]==fb) | ||
160 | return FALSE; | ||
161 | }while(fb>=0); | ||
162 | m_Position=0; | ||
163 | return TRUE; | ||
164 | } | ||
165 | |||
166 | LONG GetFile() { | ||
167 | if(!IsOpened()) | ||
168 | return -1; | ||
169 | return m_Blocks[0]; | ||
170 | } | ||
171 | virtual DWORD GetPosition() const { | ||
172 | if(!IsOpened()) | ||
173 | return 0; | ||
174 | if(m_Position<0) | ||
175 | return 0; | ||
176 | if(m_Position>GetLength()) | ||
177 | return GetLength(); | ||
178 | return m_Position; | ||
179 | } | ||
180 | virtual CString GetFileName() { | ||
181 | CString rv; | ||
182 | if(IsOpened()) | ||
183 | rv.Format("0x%08lX",m_Blocks[0]); | ||
184 | else | ||
185 | rv.Format("None"); | ||
186 | return rv; | ||
187 | } | ||
188 | virtual CString GetFileTitle() { return GetFileName(); } | ||
189 | virtual CString GetFilePath() { return GetFileName(); } | ||
190 | virtual void SetFilePath(LPCTSTR lpszNewName) { ASSERT(FALSE); } | ||
191 | |||
192 | virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError = NULL) { ASSERT(FALSE); return FALSE; } | ||
193 | virtual CFile* Duplicate() { ASSERT(FALSE); return NULL; } | ||
194 | |||
195 | virtual LONG Seek(LONG lOff, UINT nFrom) { | ||
196 | if(!IsOpened()) | ||
197 | return -1; | ||
198 | switch(nFrom){ | ||
199 | case CFile::begin: | ||
200 | m_Position=lOff; | ||
201 | break; | ||
202 | case CFile::current: | ||
203 | m_Position+=lOff; | ||
204 | break; | ||
205 | case CFile::end: | ||
206 | m_Position=GetLength()+lOff; | ||
207 | break; | ||
208 | default: | ||
209 | ASSERT(FALSE); | ||
210 | return -1; | ||
211 | } | ||
212 | if(m_Position<0) | ||
213 | m_Position=0; | ||
214 | if(m_Position>GetLength()) | ||
215 | m_Position=GetLength(); | ||
216 | return m_Position; | ||
217 | } | ||
218 | virtual void SetLength(DWORD dwNewLen) { | ||
219 | if(!IsOpened()) | ||
220 | return; | ||
221 | if(dwNewLen<GetLength()){ | ||
222 | dwNewLen=dwNewLen+sizeof(TheBlock.data); | ||
223 | dwNewLen-=dwNewLen%sizeof(TheBlock.data); | ||
224 | while(dwNewLen<GetLength() && m_Blocks.GetSize()>1){ | ||
225 | LONG mb = m_Blocks[m_Blocks.GetUpperBound()]; | ||
226 | LONG mb1 = m_Blocks[m_Blocks.GetUpperBound()-1]; | ||
227 | theBlock* b = m_Daddy->m_File->GetCached(mb1); | ||
228 | ASSERT(b); | ||
229 | ASSERT(b->next==mb); | ||
230 | b->next=-1; | ||
231 | m_Daddy->m_File->MakeDirty(mb1); | ||
232 | m_Daddy->Deallocate(mb); | ||
233 | m_Blocks.SetSize(m_Blocks.GetSize()-1); | ||
234 | } | ||
235 | }else{ | ||
236 | while(dwNewLen>GetLength()){ | ||
237 | LONG mb = m_Blocks[m_Blocks.GetUpperBound()]; | ||
238 | LONG newBlock = m_Daddy->Allocate(); | ||
239 | ASSERT(newBlock>=0); | ||
240 | theBlock* b = m_Daddy->m_File->GetCached(mb); | ||
241 | ASSERT(b); | ||
242 | ASSERT(b->next<0); | ||
243 | b->next=newBlock; | ||
244 | m_Daddy->m_File->MakeDirty(mb); | ||
245 | m_Blocks.Add(newBlock); | ||
246 | } | ||
247 | } | ||
248 | } | ||
249 | virtual DWORD GetLength() const { | ||
250 | return ((long)m_Blocks.GetSize())*((long)sizeof(TheBlock.data)); | ||
251 | } | ||
252 | |||
253 | virtual UINT Read(void* lpBuf, UINT nCount) { | ||
254 | UINT rv = 0; | ||
255 | ASSERT(m_Position>=0 && m_Position<=GetLength()); | ||
256 | LPBYTE data = (LPBYTE)lpBuf; | ||
257 | while(nCount && m_Position<GetLength()){ | ||
258 | UINT bn = m_Position/sizeof(TheBlock.data); | ||
259 | UINT bo = m_Position%sizeof(TheBlock.data); | ||
260 | theBlock* b = m_Daddy->m_File->GetCached(m_Blocks[bn]); | ||
261 | ASSERT(b); | ||
262 | UINT bc = min(nCount,sizeof(TheBlock.data)-bo); | ||
263 | memmove(data,&b->data[bo],bc); | ||
264 | nCount-=bc; | ||
265 | data=&data[bc]; | ||
266 | rv+=bc; | ||
267 | m_Position+=bc; | ||
268 | } | ||
269 | return rv; | ||
270 | } | ||
271 | virtual void Write(const void* lpBuf, UINT nCount) { | ||
272 | ASSERT(m_Position>=0 && m_Position<=GetLength()); | ||
273 | LPBYTE data = (LPBYTE)lpBuf; | ||
274 | while(nCount){ | ||
275 | UINT bn = m_Position/sizeof(TheBlock.data); | ||
276 | UINT bo = m_Position%sizeof(TheBlock.data); | ||
277 | while(bn>=m_Blocks.GetSize()){ | ||
278 | LONG mb = m_Blocks[m_Blocks.GetUpperBound()]; | ||
279 | LONG newBlock = m_Daddy->Allocate(); | ||
280 | ASSERT(newBlock>=0); | ||
281 | theBlock* b = m_Daddy->m_File->GetCached(mb); | ||
282 | ASSERT(b); | ||
283 | ASSERT(b->next<0); | ||
284 | b->next=newBlock; | ||
285 | m_Daddy->m_File->MakeDirty(mb); | ||
286 | m_Blocks.Add(newBlock); | ||
287 | } | ||
288 | theBlock* b = m_Daddy->m_File->GetCached(m_Blocks[bn]); | ||
289 | ASSERT(b); | ||
290 | UINT bc = min(nCount,sizeof(TheBlock.data)-bo); | ||
291 | memmove(&b->data[bo],data,bc); | ||
292 | m_Daddy->m_File->MakeDirty(m_Blocks[bn]); | ||
293 | nCount-=bc; | ||
294 | data=&data[bc]; | ||
295 | m_Position+=bc; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | virtual void LockRange(DWORD dwPos, DWORD dwCount) { ASSERT(FALSE); } | ||
300 | virtual void UnlockRange(DWORD dwPos, DWORD dwCount) { ASSERT(FALSE); } | ||
301 | |||
302 | virtual void Abort() { ASSERT(FALSE); } | ||
303 | virtual void Flush() { | ||
304 | m_Daddy->m_File->Flush(); | ||
305 | } | ||
306 | virtual void Close() { | ||
307 | m_Blocks.RemoveAll(); | ||
308 | } | ||
309 | |||
310 | BOOL IsOpened() const { return m_Blocks.GetSize()!=0; } | ||
311 | }; | ||
312 | |||
313 | CDynaCache* m_File; | ||
314 | firstBlock m_FB; | ||
315 | |||
316 | CDynamide() : m_File(NULL) {} | ||
317 | ~CDynamide() { Close(); } | ||
318 | |||
319 | BOOL AttachDynaFile(CDynaFile* f) { | ||
320 | //ASSERT(!m_Files.Find(f)); | ||
321 | //m_Files.AddHead(f); | ||
322 | return TRUE; | ||
323 | } | ||
324 | BOOL DetachDynaFile(CDynaFile* f) { | ||
325 | //POSITION p = m_Files.Find(f); | ||
326 | //ASSERT(p); | ||
327 | //m_Files.RemoveAt(p); | ||
328 | return TRUE; | ||
329 | } | ||
330 | |||
331 | BOOL Open(LPCTSTR file,BOOL bRO=FALSE) { | ||
332 | Close(); | ||
333 | try{ | ||
334 | CFile* f = new CFile(file,CFile::typeBinary|(bRO?CFile::modeRead|CFile::shareDenyWrite:CFile::modeReadWrite|CFile::shareDenyRead)); | ||
335 | return Attach(f,TRUE); | ||
336 | }catch(CException* e){ | ||
337 | e->Delete(); | ||
338 | return FALSE; | ||
339 | } | ||
340 | } | ||
341 | BOOL Create(LPCTSTR file) { | ||
342 | Close(); | ||
343 | try{ | ||
344 | CFile* f = new CFile(file,CFile::typeBinary|CFile::modeCreate|CFile::modeReadWrite|CFile::shareDenyRead); | ||
345 | return Attach(f,TRUE); | ||
346 | }catch(CException* e){ | ||
347 | e->Delete(); | ||
348 | return FALSE; | ||
349 | } | ||
350 | } | ||
351 | BOOL Attach(CFile* file,BOOL bAutodelete=TRUE) { | ||
352 | if(IsOpened()) | ||
353 | return FALSE; | ||
354 | m_File = new CDynaCache(file,bAutodelete); | ||
355 | if(!m_File->Read1stBlock(&m_FB)){ | ||
356 | memset(&m_FB,0,sizeof(m_FB)); | ||
357 | m_FB.freeFile=-1; | ||
358 | VERIFY(m_File->Write1stBlock(&m_FB)); | ||
359 | } | ||
360 | return IsOpened(); | ||
361 | } | ||
362 | // CFile* Detach(); | ||
363 | BOOL Close() { | ||
364 | if(!IsOpened()) | ||
365 | return FALSE; | ||
366 | m_File->Write1stBlock(&m_FB); | ||
367 | delete m_File; | ||
368 | m_File=NULL; | ||
369 | return TRUE; | ||
370 | } | ||
371 | BOOL IsOpened() { | ||
372 | return m_File != NULL; | ||
373 | } | ||
374 | BOOL Write1stBlock(void) { | ||
375 | if(!IsOpened()) | ||
376 | return FALSE; | ||
377 | VERIFY(m_File->Write1stBlock(&m_FB)); | ||
378 | return TRUE; | ||
379 | } | ||
380 | |||
381 | CDynaFile* CreateFile() { | ||
382 | CDynaFile* rv = new CDynaFile(this); | ||
383 | if(rv->Create()) | ||
384 | return rv; | ||
385 | delete rv; | ||
386 | return NULL; | ||
387 | } | ||
388 | CDynaFile* OpenFile(LONG fb) { | ||
389 | CDynaFile* rv = new CDynaFile(this); | ||
390 | if(rv->Open(fb)) | ||
391 | return rv; | ||
392 | delete rv; | ||
393 | return NULL; | ||
394 | } | ||
395 | BOOL DeleteFile(LONG fb) { | ||
396 | while(fb>=0){ | ||
397 | theBlock* b = m_File->GetCached(fb); | ||
398 | LONG nb = b->next; | ||
399 | Deallocate(fb); | ||
400 | fb=nb; | ||
401 | } | ||
402 | return TRUE; | ||
403 | } | ||
404 | |||
405 | LONG Allocate() { | ||
406 | if(!IsOpened()) | ||
407 | return -1; | ||
408 | if(m_FB.freeFile<0){ | ||
409 | LONG rv = m_File->AllocateNode(); | ||
410 | theBlock *b = m_File->GetCached(rv); | ||
411 | b->next=-1; | ||
412 | m_File->MakeDirty(rv); | ||
413 | return rv; | ||
414 | } | ||
415 | LONG rv = m_FB.freeFile; | ||
416 | theBlock *b = m_File->GetCached(rv); | ||
417 | m_FB.freeFile=b->next; | ||
418 | b->next=-1; | ||
419 | m_File->MakeDirty(rv); | ||
420 | m_File->Write1stBlock(&m_FB); | ||
421 | return rv; | ||
422 | } | ||
423 | BOOL Deallocate(LONG bk) { | ||
424 | if(!IsOpened()) | ||
425 | return FALSE; | ||
426 | theBlock* b = m_File->GetCached(bk); | ||
427 | ASSERT(b); | ||
428 | if(m_FB.freeFile<0){ | ||
429 | b->next=-1; | ||
430 | m_FB.freeFile=bk; | ||
431 | }else{ | ||
432 | b->next=m_FB.freeFile; | ||
433 | m_FB.freeFile=bk; | ||
434 | } | ||
435 | m_File->MakeDirty(bk); | ||
436 | m_File->Write1stBlock(&m_FB); | ||
437 | return TRUE; | ||
438 | } | ||
439 | }; | ||
440 | |||
441 | }; | ||
442 | |||
443 | #endif // __DYNAMIDE_H | ||
diff --git a/shared-code/FindIFace.h b/shared-code/FindIFace.h new file mode 100644 index 0000000..8dec8c4 --- a/dev/null +++ b/shared-code/FindIFace.h | |||
@@ -0,0 +1,125 @@ | |||
1 | #ifndef__FINDIFACE_H | ||
2 | #define__FINDIFACE_H | ||
3 | |||
4 | #include "SNMPeer.h" | ||
5 | #include "SNMPExtDLL.h" | ||
6 | #include "SNMPOIDs.h" | ||
7 | |||
8 | namespace Klever { | ||
9 | |||
10 | inline BOOL FindIFace(in_addr& target,in_addr& source) | ||
11 | { | ||
12 | DEFINE_OID(ipRouteDest, OIDipRouteDest); | ||
13 | DEFINE_OID(ipRouteMask, OIDipRouteMask); | ||
14 | DEFINE_OID(ipRouteIfIndex,OIDipRouteIfIndex); | ||
15 | DEFINE_OID(ipRouteMetric1,OIDipRouteMetric1); | ||
16 | DEFINE_OID(ipAdEntIfIndex,OIDipAdEntIfIndex); | ||
17 | DEFINE_OID(ipAdEntAddr, OIDipAdEntAddr); | ||
18 | struct _route{ | ||
19 | int iface; | ||
20 | int metric; | ||
21 | DWORD nm; | ||
22 | }routes[16]; | ||
23 | int nRoutes = 0; | ||
24 | CSNMPVarBindList vbl; | ||
25 | vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipRouteDest,sizeof(ipRouteDest)))); | ||
26 | vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipRouteMask,sizeof(ipRouteMask)))); | ||
27 | vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipRouteIfIndex,sizeof(ipRouteIfIndex)))); | ||
28 | vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipRouteMetric1,sizeof(ipRouteMetric1)))); | ||
29 | CSNMPExtDLL snmp("INETMIB1"); | ||
30 | while(nRoutes<(sizeof(routes)/sizeof(routes[0]))){ | ||
31 | if( | ||
32 | snmp.Request(CASNAny::typeASNGetNextRequest,vbl,vbl) | ||
33 | && vbl.GetCount() == 4 | ||
34 | ){ | ||
35 | POSITION p = vbl.GetHeadPosition(); | ||
36 | _route r = {-1,-1}; | ||
37 | in_addr d, m; | ||
38 | BOOL bD = FALSE, bM = FALSE; | ||
39 | while(p){ | ||
40 | CSNMPVarBind& vb = vbl.GetNext(p); | ||
41 | if( | ||
42 | vb.IsName(ipRouteDest,sizeof(ipRouteDest)) | ||
43 | && vb.value.type==CASNAny::typeASNIP | ||
44 | ){ | ||
45 | d.s_addr=vb.value.value.ip.s_addr; bD = TRUE; | ||
46 | }else if( | ||
47 | vb.IsName(ipRouteMask,sizeof(ipRouteMask)) | ||
48 | && vb.value.type==CASNAny::typeASNIP | ||
49 | ){ | ||
50 | m.s_addr=vb.value.value.ip.s_addr; bM = TRUE; | ||
51 | }else if( | ||
52 | vb.IsName(ipRouteIfIndex,sizeof(ipRouteIfIndex)) | ||
53 | && vb.value.type==CASNAny::typeASNInteger | ||
54 | ){ | ||
55 | r.iface=vb.value.value.number; | ||
56 | }else if( | ||
57 | vb.IsName(ipRouteMetric1,sizeof(ipRouteMetric1)) | ||
58 | && vb.value.type==CASNAny::typeASNInteger | ||
59 | ){ | ||
60 | r.metric=vb.value.value.number; | ||
61 | }else | ||
62 | break; | ||
63 | } | ||
64 | if(r.iface<0 || r.metric<0 || (!bD) || (!bM)) | ||
65 | break; | ||
66 | if((target.s_addr&m.s_addr)==(d.s_addr&m.s_addr)){ | ||
67 | r.nm=htonl(m.s_addr); | ||
68 | memmove(&routes[nRoutes++],&r,sizeof(routes[0])); | ||
69 | } | ||
70 | }else | ||
71 | break; | ||
72 | } | ||
73 | if(!nRoutes) | ||
74 | return FALSE; | ||
75 | int rn = 0; | ||
76 | if(nRoutes>1){ | ||
77 | for(int tmp=1;tmp<nRoutes;tmp++) | ||
78 | if( | ||
79 | routes[tmp].metric<routes[rn].metric | ||
80 | || routes[tmp].nm>routes[rn].nm | ||
81 | ) | ||
82 | rn = tmp; | ||
83 | } | ||
84 | int iface = routes[rn].iface; | ||
85 | vbl.RemoveAll(); | ||
86 | vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipAdEntAddr,sizeof(ipAdEntAddr)))); | ||
87 | vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipAdEntIfIndex,sizeof(ipAdEntIfIndex)))); | ||
88 | for(;;){ | ||
89 | if( | ||
90 | snmp.Request(CASNAny::typeASNGetNextRequest,vbl,vbl) | ||
91 | && vbl.GetCount()==2 | ||
92 | ){ | ||
93 | in_addr a; a.s_addr = INADDR_NONE; | ||
94 | int ifn = -1; | ||
95 | POSITION p = vbl.GetHeadPosition(); | ||
96 | while(p){ | ||
97 | CSNMPVarBind& vb = vbl.GetNext(p); | ||
98 | if( | ||
99 | vb.IsName(ipAdEntAddr,sizeof(ipAdEntAddr)) | ||
100 | && vb.value.type==CASNAny::typeASNIP | ||
101 | ){ | ||
102 | a.s_addr=vb.value.value.ip.s_addr; | ||
103 | }else if( | ||
104 | vb.IsName(ipAdEntIfIndex,sizeof(ipAdEntIfIndex)) | ||
105 | && vb.value.type==CASNAny::typeASNInteger | ||
106 | ){ | ||
107 | ifn = vb.value.value.number; | ||
108 | }else | ||
109 | break; | ||
110 | } | ||
111 | if(ifn<0) | ||
112 | break; | ||
113 | if(ifn==iface){ | ||
114 | source.s_addr=a.s_addr; | ||
115 | return TRUE; | ||
116 | } | ||
117 | }else | ||
118 | break; | ||
119 | } | ||
120 | return FALSE; | ||
121 | } | ||
122 | |||
123 | }; | ||
124 | |||
125 | #endif// __FINDIFACE_H | ||
diff --git a/shared-code/LRUCache.h b/shared-code/LRUCache.h new file mode 100644 index 0000000..569e829 --- a/dev/null +++ b/shared-code/LRUCache.h | |||
@@ -0,0 +1,113 @@ | |||
1 | #ifndef__LRUCACHE_H | ||
2 | #define__LRUCACHE_H | ||
3 | |||
4 | namespace Klever { | ||
5 | |||
6 | template<class IDX,class ARGIDX,class DATA> | ||
7 | class CLRUCache : public CObject { | ||
8 | public: | ||
9 | struct CacheEntry{ | ||
10 | enum cacheState{ | ||
11 | cacheClean, cacheDirty, cacheEmpty | ||
12 | }; | ||
13 | cacheStatem_State; | ||
14 | UINT m_hits; | ||
15 | |||
16 | IDX m_idx; | ||
17 | DATA* m_pData; | ||
18 | |||
19 | CacheEntry() { m_State=cacheEmpty; VERIFY(m_pData=new DATA); m_hits=0; } | ||
20 | virtual ~CacheEntry() { delete m_pData; } | ||
21 | }; | ||
22 | typedef CMap<IDX,ARGIDX,CacheEntry*,CacheEntry*> CCacheMap; | ||
23 | typedef CList<CacheEntry*,CacheEntry*> CCacheList; | ||
24 | |||
25 | CCacheList m_Cache; | ||
26 | CCacheMap m_Map; | ||
27 | |||
28 | CLRUCache(UINT cacheSize){ | ||
29 | for(int tmp=0;tmp<cacheSize;tmp++){ | ||
30 | CacheEntry* p = new CacheEntry; | ||
31 | m_Cache.AddTail(p); | ||
32 | } | ||
33 | } | ||
34 | virtual ~CLRUCache(){ | ||
35 | Flush(); | ||
36 | POSITION p = m_Cache.GetHeadPosition(); | ||
37 | while(p){ | ||
38 | CacheEntry* c = m_Cache.GetNext(p); | ||
39 | delete c; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | DATA* GetCached(ARGIDX idx,BOOL bLoad=TRUE) { | ||
44 | CacheEntry* rv; | ||
45 | if(m_Map.Lookup(idx,rv)){ | ||
46 | rv->m_hits++; | ||
47 | PopUp(rv); | ||
48 | return rv->m_pData; | ||
49 | } | ||
50 | if(!bLoad) | ||
51 | return NULL; | ||
52 | rv = m_Cache.GetTail(); | ||
53 | ASSERT(rv); | ||
54 | switch(rv->m_State){ | ||
55 | case CacheEntry::cacheDirty: | ||
56 | FlushEntry(rv); | ||
57 | case CacheEntry::cacheClean: | ||
58 | m_Map.RemoveKey(rv->m_idx); | ||
59 | rv->m_State=CacheEntry::cacheEmpty; | ||
60 | case CacheEntry::cacheEmpty: | ||
61 | break; | ||
62 | default: | ||
63 | ASSERT(FALSE); | ||
64 | } | ||
65 | if(!_ReadIn(idx,rv->m_pData)) | ||
66 | return NULL; | ||
67 | rv->m_hits=1; | ||
68 | rv->m_State=CacheEntry::cacheClean; | ||
69 | rv->m_idx=idx; | ||
70 | m_Map[idx]=rv; | ||
71 | PopUp(rv); | ||
72 | return rv->m_pData; | ||
73 | } | ||
74 | BOOL MakeDirty(ARGIDX idx) { | ||
75 | CacheEntry* pEntry; | ||
76 | if(m_Map.Lookup(idx,pEntry)){ | ||
77 | ASSERT(pEntry->m_State==CacheEntry::cacheClean || pEntry->m_State==CacheEntry::cacheDirty); | ||
78 | pEntry->m_State=CacheEntry::cacheDirty; | ||
79 | return TRUE; | ||
80 | } | ||
81 | return FALSE; | ||
82 | } | ||
83 | BOOL Flush() { | ||
84 | POSITION p = m_Cache.GetHeadPosition(); | ||
85 | while(p){ | ||
86 | CacheEntry* pEntry = m_Cache.GetNext(p); | ||
87 | ASSERT(pEntry); | ||
88 | FlushEntry(pEntry); | ||
89 | } | ||
90 | return TRUE; | ||
91 | } | ||
92 | BOOL FlushEntry(CacheEntry* pEntry) { | ||
93 | if(pEntry->m_State==CacheEntry::cacheDirty){ | ||
94 | BOOL rv = _WriteOut(pEntry->m_idx,pEntry->m_pData); | ||
95 | if(rv) | ||
96 | pEntry->m_State=CacheEntry::cacheClean; | ||
97 | } | ||
98 | return FALSE; | ||
99 | } | ||
100 | void PopUp(CacheEntry* pEntry) { | ||
101 | POSITION p = m_Cache.Find(pEntry); | ||
102 | ASSERT(p); | ||
103 | m_Cache.RemoveAt(p); | ||
104 | VERIFY(m_Cache.AddHead(pEntry)); | ||
105 | } | ||
106 | |||
107 | virtualBOOL _ReadIn(ARGIDX idx,DATA* data) = 0; | ||
108 | virtual BOOL _WriteOut(ARGIDX idx,DATA* data) = 0; | ||
109 | }; | ||
110 | |||
111 | }; | ||
112 | |||
113 | #endif// __LRUCACHE_H | ||
diff --git a/shared-code/RegEx.cpp b/shared-code/RegEx.cpp new file mode 100644 index 0000000..b7bab62 --- a/dev/null +++ b/shared-code/RegEx.cpp | |||
@@ -0,0 +1,1697 @@ | |||
1 | #include "../stdafx.h" | ||
2 | #include "RegEx.h" | ||
3 | |||
4 | #defineisWordableChar(c) (isalnum(c) || (c)=='_') | ||
5 | |||
6 | BOOL CRegEx::Compile(LPCTSTR regex,int flags) | ||
7 | { | ||
8 | ASSERT(!((flags®Extended) && (flags®Literal))); | ||
9 | m_Matches.RemoveAll(); | ||
10 | m_Strip.RemoveAll(); | ||
11 | m_Strip.SetSize(0,15); | ||
12 | m_Pattern=regex; | ||
13 | m_ParsePointer=0; | ||
14 | m_Error=0; | ||
15 | m_Sets.RemoveAll(); | ||
16 | m_Flags=flags; | ||
17 | m_iFlags=0; | ||
18 | m_BOLs=m_EOLs=0; | ||
19 | m_Subexps = 0; | ||
20 | m_Categories=1;// 0 is 'everything else' | ||
21 | m_bBackRefs=FALSE; | ||
22 | memset(m_Category,0,sizeof(m_Category)); | ||
23 | |||
24 | // Go ahead. | ||
25 | m_Error || m_Strip.Add(CSop(CSop::opEnd)); | ||
26 | if(flags®Extended){ | ||
27 | ParseERE(); | ||
28 | }else if(flags®Literal){ | ||
29 | ParseLiteral(); | ||
30 | }else{ | ||
31 | ParseBRE(); | ||
32 | } | ||
33 | m_Error || m_Strip.Add(CSop(CSop::opEnd)); | ||
34 | Categorize(); | ||
35 | m_Strip.FreeExtra(); | ||
36 | FigureMust(); | ||
37 | m_Pluses=CountPluses(); | ||
38 | if(m_iFlags&iflagsBad){ | ||
39 | m_Error || (m_Error=regeAssert); | ||
40 | // ??? point to nuls? ;-) | ||
41 | } | ||
42 | // We may wish to free some memory here if we're erroneous (ie. m_Error..) | ||
43 | m_ParseParens.RemoveAll(); | ||
44 | #ifdef _DEBUG | ||
45 | if(m_Error){ | ||
46 | CString tmp; | ||
47 | tmp.Format("RE: ParseError: %d\n",m_Error); | ||
48 | TRACE0(tmp); | ||
49 | } | ||
50 | //DumpStrip(afxDump); | ||
51 | #endif | ||
52 | return (m_bCompiled=(!m_Error)); | ||
53 | } | ||
54 | |||
55 | BOOL CRegEx::Match(LPCTSTR src,int flags) | ||
56 | { | ||
57 | if(!m_bCompiled) | ||
58 | return FALSE; | ||
59 | if(m_iFlags&iflagsBad) | ||
60 | return FALSE; | ||
61 | m_Input=src; | ||
62 | m_mFlags=flags; | ||
63 | m_mPointer=m_Input; | ||
64 | m_mBegin=m_Input; | ||
65 | m_mEnd=&m_mBegin[m_Input.GetLength()]; | ||
66 | ASSERT(m_mPointer<=m_mEnd); | ||
67 | m_Matches.RemoveAll(); | ||
68 | if(!m_Must.IsEmpty()){ | ||
69 | if(m_Input.Find(m_Must)<0) | ||
70 | return FALSE; | ||
71 | } | ||
72 | // Go ahead.. | ||
73 | int stripLen = m_Strip.GetSize(); | ||
74 | m_mLastPos.SetSize(0); | ||
75 | for(int tmp=0;tmp<stripLen;tmp++) | ||
76 | m_Strip[tmp].m_MatchData=0; | ||
77 | LPCTSTR beginp = m_mBegin; | ||
78 | LPCTSTR endp; | ||
79 | for(;;){ | ||
80 | endp = MatchFast(beginp); | ||
81 | if(!endp) | ||
82 | return FALSE; | ||
83 | if((m_mFlags®NoSubExpressions) && !m_bBackRefs) | ||
84 | break; | ||
85 | ASSERT(m_cOldP); | ||
86 | for(;;){ | ||
87 | endp = MatchSlow(m_cOldP,m_mEnd,1,stripLen-1); | ||
88 | if(endp) | ||
89 | break; | ||
90 | ASSERT(m_cOldP<m_mEnd); | ||
91 | m_cOldP++; | ||
92 | } | ||
93 | if((m_mFlags®OneMatch) && !m_bBackRefs) | ||
94 | break; | ||
95 | // Oh, his, we want the subexpression.. | ||
96 | m_Matches.SetSize(m_Subexps+1); | ||
97 | LPCTSTR dp; | ||
98 | if(!m_bBackRefs && !(m_mFlags®BackRefs)){ | ||
99 | dp = MatchDissect(m_cOldP,endp,1,stripLen-1); | ||
100 | }else{ | ||
101 | if(m_Pluses>0 && !m_mLastPos.GetSize()) | ||
102 | m_mLastPos.SetSize(m_Pluses); | ||
103 | dp = MatchBackRef(m_cOldP,endp,1,stripLen-1,0); | ||
104 | } | ||
105 | if(dp) | ||
106 | break; | ||
107 | // Uh.. oh.. we couldn't find a subexpression-level match | ||
108 | ASSERT(m_bBackRefs); | ||
109 | ASSERT(m_Pluses==0 || m_mLastPos.GetSize()); | ||
110 | for(;;){ | ||
111 | if(dp || endp <= m_cOldP) | ||
112 | break;// defeat.. ? | ||
113 | endp = MatchSlow(m_cOldP,endp-1,1,stripLen-1); | ||
114 | if(!endp) | ||
115 | break;// defeat.. ? | ||
116 | // Try it on a shorter possibility.. | ||
117 | #ifdef _DEBUG | ||
118 | for(tmp=1;tmp<=m_Subexps;tmp++) | ||
119 | ASSERT(m_Matches[tmp].m_Begin<0 && m_Matches[tmp].m_End<0); | ||
120 | #endif | ||
121 | dp = MatchBackRef(m_cOldP,endp,1,stripLen-1,0); | ||
122 | } | ||
123 | ASSERT((!dp) || dp==endp); | ||
124 | if(dp)// Found a shorter one.. | ||
125 | break; | ||
126 | // Despite initial appearances, there is no match here | ||
127 | beginp = m_cOldP+1; | ||
128 | ASSERT(beginp<=m_mEnd); | ||
129 | } | ||
130 | // Fill in the detail if so requested.. | ||
131 | if(!(m_mFlags®NoSubExpressions)){ | ||
132 | if(!m_Matches.GetSize()) | ||
133 | m_Matches.SetSize(1); | ||
134 | m_Matches[0].m_Begin=m_cOldP-m_mBegin; | ||
135 | m_Matches[0].m_End=endp-m_mBegin; | ||
136 | } | ||
137 | m_mLastPos.RemoveAll(); | ||
138 | return TRUE; | ||
139 | } | ||
140 | |||
141 | CString CRegEx::Replace(LPCTSTR src,LPCTSTR rep,int flags) | ||
142 | { | ||
143 | // *** | ||
144 | return CString(); | ||
145 | } | ||
146 | |||
147 | void CRegEx::ParseERE(int stop) | ||
148 | { | ||
149 | UCHAR c; | ||
150 | BOOL first=TRUE; | ||
151 | int prevF, prevB; | ||
152 | for(;;){ | ||
153 | int co = m_Strip.GetSize(); | ||
154 | while(m_ParsePointer < m_Pattern.GetLength() && ((c=m_Pattern[m_ParsePointer])!='|') && c!=stop) | ||
155 | ParseEREexp(); | ||
156 | if(m_Strip.GetSize()==co){ | ||
157 | m_Error || (m_Error=regeEmpty); | ||
158 | // ??? point to nuls? | ||
159 | } | ||
160 | if(m_ParsePointer>=m_Pattern.GetLength() || m_Pattern[m_ParsePointer]!='|') | ||
161 | break; | ||
162 | else | ||
163 | m_ParsePointer++; | ||
164 | if(first){ | ||
165 | StripInsert(co,CSop(CSop::opChoice0,m_Strip.GetSize()-co+1)); | ||
166 | prevF = prevB = co; | ||
167 | first=FALSE; | ||
168 | } | ||
169 | m_Error || m_Strip.Add(CSop(CSop::opOr0,m_Strip.GetSize()-prevB)); | ||
170 | prevB = m_Strip.GetSize()-1; | ||
171 | m_Error || (m_Strip[prevF].m_Operand=m_Strip.GetSize()-prevF); | ||
172 | prevF = m_Strip.GetSize(); | ||
173 | m_Error || m_Strip.Add(CSop(CSop::opOr1,0));// offset isn't really right.. very so.. | ||
174 | } | ||
175 | if(!first){ | ||
176 | m_Error || (m_Strip[prevF].m_Operand=m_Strip.GetSize()-prevF); | ||
177 | m_Error || m_Strip.Add(CSop(CSop::opChoice1,m_Strip.GetSize()-prevB)); | ||
178 | } | ||
179 | ASSERT(m_ParsePointer >= m_Pattern.GetLength() || m_Pattern[m_ParsePointer]==stop); | ||
180 | } | ||
181 | |||
182 | void CRegEx::ParseEREexp() | ||
183 | { | ||
184 | ASSERT(m_ParsePointer < m_Pattern.GetLength()); | ||
185 | UCHAR c = m_Pattern[m_ParsePointer++]; | ||
186 | int pos = m_Strip.GetSize(); | ||
187 | int subno; | ||
188 | int count, count2; | ||
189 | BOOL wascaret=FALSE; | ||
190 | switch(c){ | ||
191 | case '(': | ||
192 | if(!(m_ParsePointer<m_Pattern.GetLength())){ | ||
193 | TRACE0("RE: '(' at the end of the pattern\n"); | ||
194 | if(!m_Error) | ||
195 | m_Error = regeParen; | ||
196 | // ??? point to nuls? | ||
197 | } | ||
198 | m_Subexps++; | ||
199 | subno=m_Subexps; | ||
200 | m_ParseParens.SetAtGrow(m_Subexps,CParenthesis(m_Strip.GetSize())); | ||
201 | m_Error || m_Strip.Add(CSop(CSop::opLeftParen,subno)); | ||
202 | if(m_ParsePointer>=m_Pattern.GetLength() || m_Pattern[m_ParsePointer]!=')') | ||
203 | ParseERE(')'); | ||
204 | VERIFY(m_ParseParens[m_Subexps].m_End = m_Strip.GetSize()); | ||
205 | m_Error || m_Strip.Add(CSop(CSop::opRightParen,subno)); | ||
206 | if(m_ParsePointer >= m_Pattern.GetLength() || m_Pattern[m_ParsePointer++]!=')'){ | ||
207 | TRACE0("RE: No matching ')'\n"); | ||
208 | if(!m_Error) | ||
209 | m_Error = regeParen; | ||
210 | // ??? point to nuls? | ||
211 | } | ||
212 | break; | ||
213 | case '^': | ||
214 | m_Error || m_Strip.Add(CSop(CSop::opBOL)); | ||
215 | m_iFlags|=iflagsUseBOL; | ||
216 | m_BOLs++; | ||
217 | wascaret=TRUE; | ||
218 | break; | ||
219 | case '$': | ||
220 | m_Error || m_Strip.Add(CSop(CSop::opEOL)); | ||
221 | m_iFlags|=iflagsUseEOL; | ||
222 | m_EOLs++; | ||
223 | break; | ||
224 | case '|': | ||
225 | TRACE0("RE: '|' outside of expression\n"); | ||
226 | if(!m_Error) | ||
227 | m_Error = regeEmpty; | ||
228 | // ??? point to nuls? | ||
229 | break; | ||
230 | case '*': | ||
231 | case '+': | ||
232 | case '?': | ||
233 | TRACE0("RE: '*'/'+'/'?' with no previous expression\n"); | ||
234 | if(!m_Error) | ||
235 | m_Error = regeBadRepeat; | ||
236 | // ??? point to nuls? | ||
237 | break; | ||
238 | case '.': | ||
239 | if(m_Flags®NewLine) | ||
240 | EmitNonNewLineAny(); | ||
241 | else | ||
242 | m_Error || m_Strip.Add(CSop(CSop::opAny)); | ||
243 | break; | ||
244 | case '[': | ||
245 | ParseBracket(); | ||
246 | break; | ||
247 | case '\\': | ||
248 | if(m_ParsePointer >= m_Pattern.GetLength()){ | ||
249 | TRACE0("RE: '\\' at the end of the pattern\n"); | ||
250 | if(!m_Error) | ||
251 | m_Error = regeEscape; | ||
252 | // ??? point to nuls? | ||
253 | }else{ | ||
254 | c = m_Pattern[m_ParsePointer++]; | ||
255 | EmitOrdinary(c); | ||
256 | } | ||
257 | break; | ||
258 | case '{': | ||
259 | if(m_ParsePointer >= m_Pattern.GetLength() || !isdigit(m_Pattern[m_ParsePointer])){ | ||
260 | TRACE0("RE: '{' with no repeat count\n"); | ||
261 | if(!m_Error) | ||
262 | m_Error = regeBadRepeat; | ||
263 | // ??? point to nuls? | ||
264 | } | ||
265 | // Fallthrough.. | ||
266 | default: | ||
267 | EmitOrdinary(c); | ||
268 | break; | ||
269 | } | ||
270 | if(m_ParsePointer >= m_Pattern.GetLength()) | ||
271 | return; | ||
272 | c = m_Pattern[m_ParsePointer]; | ||
273 | // Call a '{' repetition if followed by a digit | ||
274 | if (!(c=='*' || c=='+' || c=='?' || ( c=='{' && (m_ParsePointer+1) < m_Pattern.GetLength() && isdigit(m_Pattern[m_ParsePointer+1])) )) | ||
275 | return; // No repetitor - done. | ||
276 | m_ParsePointer++; | ||
277 | if(wascaret){ | ||
278 | TRACE0("RE: repetitive '^' detected\n"); | ||
279 | if(!m_Error) | ||
280 | m_Error = regeBadRepeat; | ||
281 | // ??? point to nuls? | ||
282 | } | ||
283 | switch(c){ | ||
284 | case '*':// Implemeted as +? | ||
285 | // + expression | ||
286 | StripInsert(pos,CSop(CSop::opPlus0,m_Strip.GetSize()-pos+1)); | ||
287 | m_Error || m_Strip.Add(CSop(CSop::opPlus1,m_Strip.GetSize()-pos)); | ||
288 | // ? expression | ||
289 | StripInsert(pos,CSop(CSop::opQuest0,m_Strip.GetSize()-pos+1)); | ||
290 | m_Error || m_Strip.Add(CSop(CSop::opQuest1,m_Strip.GetSize()-pos)); | ||
291 | break; | ||
292 | case '+': | ||
293 | // + expression | ||
294 | StripInsert(pos,CSop(CSop::opPlus0,m_Strip.GetSize()-pos+1)); | ||
295 | m_Error || m_Strip.Add(CSop(CSop::opPlus1,m_Strip.GetSize()-pos)); | ||
296 | break; | ||
297 | case '?': | ||
298 | // Kludge - emit y? as (y|) until subtle bug gets fixed :-) | ||
299 | StripInsert(pos,CSop(CSop::opChoice0,m_Strip.GetSize()-pos+1)); | ||
300 | m_Error || m_Strip.Add(CSop(CSop::opOr0,m_Strip.GetSize()-pos)); | ||
301 | m_Error || (m_Strip[pos].m_Operand=m_Strip.GetSize()-pos); | ||
302 | m_Error || m_Strip.Add(CSop(CSop::opOr1,1)); | ||
303 | m_Error || m_Strip.Add(CSop(CSop::opChoice1,2)); | ||
304 | break; | ||
305 | case '{': | ||
306 | count = ParseCount(); | ||
307 | if(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]==','){ | ||
308 | m_ParsePointer++; | ||
309 | if(isdigit(m_Pattern[m_ParsePointer])){ // HHH Personally, I doubt it is always available | ||
310 | count2=ParseCount(); | ||
311 | if(!(count<=count2)){ | ||
312 | TRACE0("RE: Disbalanced counts in '{}' repeater\n"); | ||
313 | m_Error || (m_Error=regeBadBrace); | ||
314 | // ??? point to nuls? | ||
315 | } | ||
316 | }else // Single number with comma | ||
317 | count2=256; // Infinity | ||
318 | }else // Single number | ||
319 | count2=count; | ||
320 | EmitRepeat(pos,count,count2); | ||
321 | if(m_ParsePointer >= m_Pattern.GetLength() || m_Pattern[m_ParsePointer]!='}'){ | ||
322 | // No '}'.. | ||
323 | TRACE0("RE: No immediately following '}' of '{' expression\n"); | ||
324 | while(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]!='}') | ||
325 | m_ParsePointer++; | ||
326 | if(m_ParsePointer >= m_Pattern.GetLength()){ | ||
327 | TRACE0("RE: No closing '}' found\n"); | ||
328 | m_Error || (m_Error=regeBrace); | ||
329 | }else | ||
330 | m_Error || (m_Error=regeBadBrace); | ||
331 | // ??? point to nuls? | ||
332 | }else | ||
333 | m_ParsePointer++; | ||
334 | break; | ||
335 | } | ||
336 | if(m_ParsePointer >= m_Pattern.GetLength()) | ||
337 | return; | ||
338 | c = m_Pattern[m_ParsePointer]; | ||
339 | if(!(c=='*' || c=='+' || c=='?' || (c=='{' && (m_ParsePointer+1)<m_Pattern.GetLength() && isdigit(m_Pattern[m_ParsePointer+1])))) | ||
340 | return; | ||
341 | TRACE0("RE: Double repeater\n"); | ||
342 | m_Error || (m_Error=regeBadRepeat); | ||
343 | // ??? point to nuls? | ||
344 | } | ||
345 | |||
346 | void CRegEx::StripInsert(int pos,CSop& sop) | ||
347 | { | ||
348 | if(m_Error) | ||
349 | return; | ||
350 | int sn = m_Strip.GetSize(); | ||
351 | m_Strip.InsertAt(pos,sop); | ||
352 | for(int tmp=1;tmp<m_ParseParens.GetSize();tmp++){ | ||
353 | if(m_ParseParens[tmp].m_Begin>=pos) | ||
354 | m_ParseParens[tmp].m_Begin++; | ||
355 | if(m_ParseParens[tmp].m_End>=pos) | ||
356 | m_ParseParens[tmp].m_End++; | ||
357 | } | ||
358 | } | ||
359 | |||
360 | void CRegEx::EmitOrdinary(UCHAR c) | ||
361 | { | ||
362 | if(m_Flags®IgnoreCase && isalpha(c) && (tolower(c) !=toupper(c))){ | ||
363 | // Emit both cases | ||
364 | CString savePattern = m_Pattern; | ||
365 | int savePointer = m_ParsePointer; | ||
366 | m_Pattern=c; | ||
367 | m_Pattern+=']'; | ||
368 | m_ParsePointer=0; | ||
369 | ParseBracket(); | ||
370 | m_Pattern=savePattern; | ||
371 | m_ParsePointer=savePointer; | ||
372 | }else{ | ||
373 | m_Error || m_Strip.Add(CSop(CSop::opChar,c)); | ||
374 | if(!m_Category[(BYTE)c]) | ||
375 | m_Category[(BYTE)c]=m_Categories++; | ||
376 | } | ||
377 | } | ||
378 | |||
379 | void CRegEx::EmitNonNewLineAny() | ||
380 | { | ||
381 | // Kludges're going on and on.. | ||
382 | CString savePattern = m_Pattern; | ||
383 | int savePointer = m_ParsePointer; | ||
384 | m_Pattern="^\n]"; | ||
385 | m_ParsePointer=0; | ||
386 | ParseBracket(); | ||
387 | m_Pattern=savePattern; | ||
388 | m_ParsePointer=savePointer; | ||
389 | } | ||
390 | |||
391 | int CRegEx::ParseCount() | ||
392 | { | ||
393 | BOOL nonEmpty=FALSE; | ||
394 | int rv = 0; | ||
395 | UCHAR c; | ||
396 | while(m_ParsePointer < m_Pattern.GetLength() && isdigit(c=m_Pattern[m_ParsePointer]) && rv <=255){ | ||
397 | rv = rv*10 + c-'0'; | ||
398 | nonEmpty=TRUE; | ||
399 | m_ParsePointer++; | ||
400 | } | ||
401 | if(rv>255 || !nonEmpty){ | ||
402 | m_Error || (m_Error=regeBadBrace); | ||
403 | // ??? point to nuls? | ||
404 | } | ||
405 | return rv; | ||
406 | } | ||
407 | |||
408 | void CRegEx::ParseBracket() | ||
409 | { | ||
410 | // Dept. of truly sickening special case kludges | ||
411 | if((m_ParsePointer+5) < m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,6).Compare("[:<]]")){ | ||
412 | m_Error || m_Strip.Add(CSop(CSop::opBOW)); | ||
413 | m_ParsePointer+=6; | ||
414 | return; | ||
415 | } | ||
416 | if((m_ParsePointer+5) < m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,6).Compare("[:>]]")){ | ||
417 | m_Error || m_Strip.Add(CSop(CSop::opEOW)); | ||
418 | m_ParsePointer+=6; | ||
419 | return; | ||
420 | } | ||
421 | BOOL invert=TRUE; | ||
422 | if(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='^') | ||
423 | m_ParsePointer++; | ||
424 | else | ||
425 | invert=FALSE; | ||
426 | CSet cset; | ||
427 | if(m_ParsePointer < m_Pattern.GetLength()){ | ||
428 | switch(m_Pattern[m_ParsePointer]){ | ||
429 | case ']': | ||
430 | case '-': | ||
431 | cset.Add(m_Pattern[m_ParsePointer]); | ||
432 | m_ParsePointer++; | ||
433 | break; | ||
434 | } | ||
435 | } | ||
436 | while(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]!=']' && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("-]"))) | ||
437 | ParseBracketTerm(cset); | ||
438 | if(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='-'){ | ||
439 | m_ParsePointer++; | ||
440 | cset.Add('-'); | ||
441 | } | ||
442 | if(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]==']') | ||
443 | m_ParsePointer++; | ||
444 | else{ | ||
445 | m_Error || (m_Error=regeBracket); | ||
446 | // ??? point to nuls? | ||
447 | return; | ||
448 | } | ||
449 | if(m_Flags®IgnoreCase){ | ||
450 | for(int tmp=CSet::size-1;tmp>=0;tmp--){ | ||
451 | if(cset.IsIn(tmp) && isalpha(tmp) && (toupper(tmp)!=tolower(tmp))) | ||
452 | cset.Add(isupper(tmp)?tolower(tmp):toupper(tmp)); | ||
453 | } | ||
454 | /* | ||
455 | if(!cset->m_Multis.IsEmpty()) | ||
456 | cset.CollatingCase(); | ||
457 | */ | ||
458 | } | ||
459 | if(invert){ | ||
460 | for(int tmp=CSet::size-1;tmp>=0;tmp--) | ||
461 | if(cset.IsIn(tmp)) | ||
462 | cset.Sub(tmp); | ||
463 | else | ||
464 | cset.Add(tmp); | ||
465 | if(m_Flags®NewLine) | ||
466 | cset.Sub('\n'); | ||
467 | /* | ||
468 | if(!cset.m_Multis.IsEmpty()) | ||
469 | cset.CollatingInvert(); | ||
470 | */ | ||
471 | } | ||
472 | UCHAR c = cset.GetOnly(); | ||
473 | if(c){ | ||
474 | EmitOrdinary(c); | ||
475 | }else | ||
476 | m_Error || m_Strip.Add(CSop(CSop::opAnyOf,StoreSet(cset))); | ||
477 | } | ||
478 | |||
479 | void CRegEx::CSet::Add(UCHAR c) | ||
480 | { | ||
481 | m_Set[(BYTE)c]=TRUE; | ||
482 | m_Hash+=c; | ||
483 | } | ||
484 | |||
485 | BOOL CRegEx::CSet::IsIn(UCHAR c) | ||
486 | { | ||
487 | return m_Set[(BYTE)c]; | ||
488 | } | ||
489 | |||
490 | void CRegEx::CSet::Sub(UCHAR c) | ||
491 | { | ||
492 | m_Set[(BYTE)c]=FALSE; | ||
493 | m_Hash-=c; | ||
494 | } | ||
495 | |||
496 | UCHAR CRegEx::CSet::GetOnly() | ||
497 | { | ||
498 | int rv = 0; | ||
499 | UCHAR only = 0; | ||
500 | for(int tmp=0;tmp<size;tmp++){ | ||
501 | rv+=m_Set[tmp]?(only=tmp,1):0; | ||
502 | } | ||
503 | return (rv==1)?only:0; | ||
504 | } | ||
505 | |||
506 | int CRegEx::StoreSet(CSet& cset) | ||
507 | { | ||
508 | for(int tmp=0;tmp<m_Sets.GetSize();tmp++) | ||
509 | if(m_Sets[tmp]==cset) | ||
510 | return tmp; | ||
511 | return m_Sets.Add(cset); | ||
512 | } | ||
513 | |||
514 | void CRegEx::ParseBracketTerm(CSet& cset) | ||
515 | { | ||
516 | UCHAR c; | ||
517 | switch((m_ParsePointer<m_Pattern.GetLength())?m_Pattern[m_ParsePointer]:0){ | ||
518 | case '[': | ||
519 | c = ((m_ParsePointer+1)<m_Pattern.GetLength())?m_Pattern[m_ParsePointer+1]:0; | ||
520 | break; | ||
521 | case '-': | ||
522 | m_Error || (m_Error=regeRange); | ||
523 | // ??? point to nuls? | ||
524 | return; | ||
525 | default: | ||
526 | c = 0; | ||
527 | break; | ||
528 | } | ||
529 | switch(c){ | ||
530 | case ':':// Character class | ||
531 | m_ParsePointer+=2; | ||
532 | if(m_ParsePointer>=m_Pattern.GetLength()){ | ||
533 | m_Error || (m_Error=regeBracket); | ||
534 | // ??? point to nuls? | ||
535 | } | ||
536 | c = m_Pattern[m_ParsePointer]; | ||
537 | if(c== '-' || c==']'){ | ||
538 | m_Error || (m_Error=regeCType); | ||
539 | // ??? point to nuls? | ||
540 | } | ||
541 | ParseBracketCClass(cset); | ||
542 | if(m_ParsePointer>=m_Pattern.GetLength()){ | ||
543 | m_Error || (m_Error=regeBracket); | ||
544 | // ??? point to nuls? | ||
545 | } | ||
546 | if((m_ParsePointer+1)>=m_Pattern.GetLength() || (m_Pattern.Mid(m_ParsePointer,2).Compare(":]"))){ | ||
547 | m_Error || (m_Error=regeCType); | ||
548 | // ??? point to nuls? | ||
549 | }else | ||
550 | m_ParsePointer+=2; | ||
551 | break; | ||
552 | case '=':// Equivalence class | ||
553 | m_ParsePointer+=2; | ||
554 | if(m_ParsePointer >= m_Pattern.GetLength()){ | ||
555 | m_Error || (m_Error=regeBracket); | ||
556 | // ??? point to nuls? | ||
557 | } | ||
558 | c = m_Pattern[m_ParsePointer]; | ||
559 | if(c== '-' || c==']'){ | ||
560 | m_Error || (m_Error=regeCollate); | ||
561 | // ??? point to nuls? | ||
562 | } | ||
563 | ParseBracketEClass(cset); | ||
564 | if((m_ParsePointer+1)>=m_Pattern.GetLength() || (m_Pattern.Mid(m_ParsePointer,2).Compare("=]"))){ | ||
565 | m_Error || (m_Error=regeCollate); | ||
566 | // ??? point to nuls? | ||
567 | }else | ||
568 | m_ParsePointer+=2; | ||
569 | break; | ||
570 | default:// Symbol, character or range | ||
571 | { | ||
572 | UCHAR start, finish; | ||
573 | start = ParseBracketSymbol(); | ||
574 | if((m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='-') /*&& (m_ParsePointer+1)<m_Pattern.GetLength() && m_Pattern[m_ParsePointer+1]==']'*/){ | ||
575 | // I believe the expression above is seetwo.. | ||
576 | // range. | ||
577 | m_ParsePointer++; | ||
578 | if(m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='-'){ | ||
579 | m_ParsePointer++; | ||
580 | finish='-'; | ||
581 | }else | ||
582 | finish=ParseBracketSymbol(); | ||
583 | }else | ||
584 | finish=start; | ||
585 | if(((BYTE)start)>((BYTE)finish)){ | ||
586 | m_Error || (m_Error=regeRange); | ||
587 | // ??? point to nuls? | ||
588 | } | ||
589 | for(int tmp=start;tmp<=(BYTE)finish;tmp++) | ||
590 | cset.Add(tmp); | ||
591 | } | ||
592 | break; | ||
593 | } | ||
594 | } | ||
595 | |||
596 | void CRegEx::ParseBracketCClass(CSet& cset) | ||
597 | { | ||
598 | static struct{ | ||
599 | char *className; | ||
600 | char *classChars; | ||
601 | }cc[] = { | ||
602 | {"alnum","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"}, | ||
603 | {"alpha","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"}, | ||
604 | {"blank"," \t"}, | ||
605 | {"cntrl","\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37\177"}, | ||
606 | {"digit","0123456789"}, | ||
607 | {"graph","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"}, | ||
608 | {"lower","abcdefghijklmnopqrstuvwxyz"}, | ||
609 | {"print","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ "}, | ||
610 | {"punct","!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"}, | ||
611 | {"space","\t\n\v\f\r "}, | ||
612 | {"upper","ABCDEFGHIJKLMNOPQRSTUVWXYZ"}, | ||
613 | {"xdigit","0123456789ABCDEFabcdef"} | ||
614 | }; | ||
615 | CString cclass; | ||
616 | UCHAR c; | ||
617 | while(m_ParsePointer < m_Pattern.GetLength() && isalpha(c=m_Pattern[m_ParsePointer])){ | ||
618 | cclass+=c; | ||
619 | m_ParsePointer++; | ||
620 | } | ||
621 | char *classChars = NULL; | ||
622 | for(int tmp=0;tmp<(sizeof(cc)/sizeof(cc[0]));tmp++){ | ||
623 | if(!cclass.CompareNoCase(cc[tmp].className)){ | ||
624 | classChars=cc[tmp].classChars; | ||
625 | break; | ||
626 | } | ||
627 | } | ||
628 | if(!classChars){ | ||
629 | m_Error || (m_Error=regeCType); | ||
630 | // ??? point to nuls? | ||
631 | return; | ||
632 | } | ||
633 | while(*classChars) | ||
634 | cset.Add(*(classChars++)); | ||
635 | // --- multis | ||
636 | } | ||
637 | |||
638 | void CRegEx::ParseBracketEClass(CSet& cset) | ||
639 | { | ||
640 | cset.Add(ParseBracketCollatingElement('='));; | ||
641 | } | ||
642 | |||
643 | UCHAR CRegEx::ParseBracketCollatingElement(UCHAR term) | ||
644 | { | ||
645 | static struct{ | ||
646 | char *entityName; | ||
647 | char entity; | ||
648 | }cc[] = { {"NUL",'\0'},{"SOH",'\001'},{"STX",'\002'},{"ETX",'\003'},{"EOT",'\004'},{"ENQ",'\005'},{"ACK",'\006'},{"BEL",'\007'},{"alert",'\007'},{"BS",'\010'},{"backspace",'\b'},{"HT",'\011'},{"tab",'\t'},{"LF",'\012'},{"newline",'\n'},{"VT",'\013'},{"vertical-tab",'\v'},{"FF",'\014'},{"form-feed",'\f'},{"CR",'\015'},{"carriage-return",'\r'},{"SO",'\016'},{"SI",'\017'},{"DLE",'\020'},{"DC1",'\021'},{"DC2",'\022'},{"DC3",'\023'},{"DC4",'\024'},{"NAK",'\025'},{"SYN",'\026'},{"ETB",'\027'},{"CAN",'\030'},{"EM",'\031'},{"SUB",'\032'},{"ESC",'\033'},{"IS4",'\034'},{"FS",'\034'},{"IS3",'\035'},{"GS",'\035'},{"IS2",'\036'},{"RS",'\036'},{"IS1",'\037'},{"US",'\037'},{"space",' '},{"exclamation-mark",'!'},{"quotation-mark",'"'},{"number-sign",'#'},{"dollar-sign",'$'},{"percent-sign",'%'},{"ampersand",'&'},{"apostrophe",'\''},{"left-parenthesis",'('},{"right-parenthesis",')'},{"asterisk",'*'},{"plus-sign",'+'},{"comma",','},{"hyphen",'-'},{"hyphen-minus",'-'},{"period",'.'},{"full-stop",'.'},{"slash",'/'},{"solidus",'/'},{"zero",'0'},{"one",'1'},{"two",'2'},{"three",'3'},{"four",'4'},{"five",'5'},{"six",'6'},{"seven",'7'},{"eight",'8'},{"nine",'9'},{"colon",':'},{"semicolon",';'},{"less-than-sign",'<'},{"equals-sign",'='},{"greater-than-sign",'>'},{"question-mark",'?'},{"commercial-at",'@'},{"left-square-bracket",'['},{"backslash",'\\'},{"reverse-solidus",'\\'},{"right-square-bracket",']'},{"circumflex",'^'},{"circumflex-accent",'^'},{"underscore",'_'},{"low-line",'_'},{"grave-accent",'`'},{"left-brace",'{'},{"left-curly-bracket",'{'},{"vertical-line",'|'},{"right-brace",'}'},{"right-curly-bracket",'}'},{"tilde",'~'},{"DEL",'\177'} }; | ||
649 | CString seeTwo; | ||
650 | seeTwo=term; | ||
651 | seeTwo+=']'; | ||
652 | CString entityName; | ||
653 | while(m_ParsePointer<m_Pattern.GetLength() && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare(seeTwo))) | ||
654 | entityName+=m_Pattern[m_ParsePointer++]; | ||
655 | if(m_ParsePointer>=m_Pattern.GetLength()){ | ||
656 | m_Error || (m_Error=regeBracket); | ||
657 | // ??? point to nuls? | ||
658 | return 0; | ||
659 | } | ||
660 | for(int tmp=0;tmp<(sizeof(cc)/sizeof(cc[0]));tmp++) | ||
661 | if(!entityName.CompareNoCase(cc[tmp].entityName)) | ||
662 | return cc[tmp].entity; | ||
663 | if(entityName.GetLength()==1) | ||
664 | return entityName[0]; | ||
665 | m_Error || (m_Error=regeCollate); | ||
666 | // ??? point to nuls? | ||
667 | return 0; | ||
668 | } | ||
669 | |||
670 | UCHAR CRegEx::ParseBracketSymbol() | ||
671 | { | ||
672 | if(m_ParsePointer>=m_Pattern.GetLength()){ | ||
673 | m_Error || (m_Error=regeBracket); | ||
674 | // ??? point to nuls? | ||
675 | } | ||
676 | if((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("[.")) | ||
677 | m_ParsePointer+=2; | ||
678 | else | ||
679 | return m_Pattern[m_ParsePointer++]; | ||
680 | // Collating symbol | ||
681 | UCHAR rv = ParseBracketCollatingElement('.'); | ||
682 | if((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("[.")) | ||
683 | m_ParsePointer+=2; | ||
684 | else{ | ||
685 | m_Error || (m_Error=regeCollate); | ||
686 | // ??? point to nuls? | ||
687 | } | ||
688 | return rv; | ||
689 | } | ||
690 | |||
691 | void CRegEx::EmitRepeat(int pos,int from,int to) | ||
692 | { | ||
693 | if(m_Error) | ||
694 | return; | ||
695 | ASSERT(from<=to); | ||
696 | int finish = m_Strip.GetSize(); | ||
697 | int copy; | ||
698 | #defineN 2 | ||
699 | #define INF 3 | ||
700 | #define REP(f,t) ((f)*8+(t)) | ||
701 | #define MAP(n) (((n)<=1)?(n):((n)==256)?INF:N) | ||
702 | switch(REP(MAP(from),MAP(to))){ | ||
703 | case REP(0,0):// must be user doing ths?? | ||
704 | m_Strip.SetSize(pos); | ||
705 | break; | ||
706 | case REP(0,1):// as in '?' | ||
707 | case REP(0,N):// as in '{1,n}?' | ||
708 | case REP(0,INF):// as in '{1,}?' | ||
709 | // Kludge - emit y? as (y|) until something gets fixed.. | ||
710 | StripInsert(pos,CSop(CSop::opChoice0,pos)); | ||
711 | EmitRepeat(pos+1,1,to); | ||
712 | m_Error || m_Strip.Add(CSop(CSop::opOr0,m_Strip.GetSize()-pos)); | ||
713 | m_Error || (m_Strip[pos].m_Operand=m_Strip.GetSize()-pos); | ||
714 | m_Error || m_Strip.Add(CSop(CSop::opOr1,1)); | ||
715 | m_Error || m_Strip.Add(CSop(CSop::opChoice1,2)); | ||
716 | break; | ||
717 | case REP(1,1): | ||
718 | break; | ||
719 | case REP(1,N):// as in 'x?x{1,n-1}' | ||
720 | // Kludge again.. | ||
721 | StripInsert(pos,CSop(CSop::opChoice0,pos)); | ||
722 | m_Error || m_Strip.Add(CSop(CSop::opOr0,m_Strip.GetSize()-pos)); | ||
723 | m_Error || (m_Strip[pos].m_Operand=m_Strip.GetSize()-pos); | ||
724 | m_Error || m_Strip.Add(CSop(CSop::opOr1,1)); | ||
725 | m_Error || m_Strip.Add(CSop(CSop::opChoice1,2)); | ||
726 | copy = StripDuplicate(pos+1,finish+1); | ||
727 | ASSERT(copy==(finish+4)); | ||
728 | EmitRepeat(copy,1,to-1); | ||
729 | break; | ||
730 | case REP(1,INF): // as in '+' | ||
731 | StripInsert(pos,CSop(CSop::opPlus0,pos)); | ||
732 | m_Error || m_Strip.Add(CSop(CSop::opPlus1,m_Strip.GetSize()-pos)); | ||
733 | break; | ||
734 | case REP(N,N):// as in 'xx{from-1,to-1}' | ||
735 | copy = StripDuplicate(pos,finish); | ||
736 | EmitRepeat(copy,from-1,to-1); | ||
737 | break; | ||
738 | case REP(N,INF): // as in 'xx{n-1,}' | ||
739 | copy = StripDuplicate(pos,finish); | ||
740 | EmitRepeat(copy,from-1,to); | ||
741 | break; | ||
742 | #ifndef NDEBUG | ||
743 | default: | ||
744 | ASSERT(FALSE); | ||
745 | break; | ||
746 | #endif | ||
747 | } | ||
748 | #undef MAP | ||
749 | #undef REP | ||
750 | #undef INF | ||
751 | #undef N | ||
752 | } | ||
753 | |||
754 | int CRegEx::StripDuplicate(int from,int to) | ||
755 | { | ||
756 | int rv = m_Strip.GetSize(); | ||
757 | ASSERT(from<=to); | ||
758 | if(from==to) | ||
759 | return rv; | ||
760 | // Maybe should be optimized for copying the whole thing. | ||
761 | for(int tmp=from;tmp<to;tmp++) | ||
762 | m_Strip.Add(m_Strip[tmp]); | ||
763 | return rv; | ||
764 | } | ||
765 | |||
766 | void CRegEx::Categorize() | ||
767 | { | ||
768 | if(m_Error) | ||
769 | return; | ||
770 | for(int tmp=0;tmp<(sizeof(m_Category)/sizeof(m_Category[0]));tmp++) | ||
771 | if((!m_Category[tmp]) && IsInSets(tmp)){ | ||
772 | int cat = m_Categories++; | ||
773 | m_Category[tmp]=cat; | ||
774 | for(int c=tmp+1;c<(sizeof(m_Category)/sizeof(m_Category[0]));c++) | ||
775 | if((!m_Category[c]) && IsInSameSets(tmp,c)) | ||
776 | m_Category[c]=cat; | ||
777 | } | ||
778 | } | ||
779 | |||
780 | BOOL CRegEx::IsInSets(UCHAR c) | ||
781 | { | ||
782 | for(int tmp=0;tmp<m_Sets.GetSize();tmp++) | ||
783 | if(m_Sets[tmp].IsIn(c)) | ||
784 | return TRUE; | ||
785 | return FALSE; | ||
786 | } | ||
787 | |||
788 | BOOL CRegEx::IsInSameSets(UCHAR c1,UCHAR c2) | ||
789 | { | ||
790 | for(int tmp=0;tmp<m_Sets.GetSize();tmp++) | ||
791 | if(m_Sets[tmp].IsIn(c1)!=m_Sets[tmp].IsIn(c2)) | ||
792 | return FALSE; | ||
793 | return TRUE; | ||
794 | } | ||
795 | |||
796 | void CRegEx::FigureMust() | ||
797 | { | ||
798 | if(m_Error) | ||
799 | return; | ||
800 | m_Must.Empty(); | ||
801 | int stripLen = m_Strip.GetSize(); | ||
802 | int seqStart, seqLength = 0; | ||
803 | int mustStart, mustLength = 0; | ||
804 | for(int tmp=1;tmp<stripLen;tmp++){ | ||
805 | switch(m_Strip[tmp].m_Operator){ | ||
806 | case CSop::opChar: | ||
807 | if(!seqLength) | ||
808 | seqStart=tmp; | ||
809 | seqLength++; | ||
810 | break; | ||
811 | case CSop::opPlus0: | ||
812 | case CSop::opLeftParen: | ||
813 | case CSop::opRightParen: | ||
814 | break;// Break, since they don't break the sequence | ||
815 | case CSop::opQuest0: | ||
816 | case CSop::opChoice0: | ||
817 | // These ones we skip. | ||
818 | do{ | ||
819 | tmp+=m_Strip[tmp].m_Operand; | ||
820 | // I still think it could be ASSERTed.. | ||
821 | if(m_Strip[tmp].m_Operator!=CSop::opQuest1 && m_Strip[tmp].m_Operator!=CSop::opChoice1 && m_Strip[tmp].m_Operator!=CSop::opOr1){ | ||
822 | m_iFlags|=iflagsBad; | ||
823 | return; | ||
824 | } | ||
825 | }while(m_Strip[tmp].m_Operator!=CSop::opQuest1 && m_Strip[tmp].m_Operator!=CSop::opChoice1); | ||
826 | // Fallthrough.. | ||
827 | default: | ||
828 | // End of sequence | ||
829 | if(seqLength>mustLength){ | ||
830 | mustStart=seqStart; | ||
831 | mustLength=seqLength; | ||
832 | } | ||
833 | seqLength=0; | ||
834 | break; | ||
835 | } | ||
836 | }// Hmm.. originally it's meant to be do while not opEnd.. | ||
837 | if(!mustLength) | ||
838 | return; | ||
839 | // Turn into string, but, wait, personally I'm sure it could be put in the main loop.. or maybe not.. | ||
840 | for(tmp=0;tmp<seqLength;tmp++){ | ||
841 | while(m_Strip[seqStart+tmp].m_Operator!=CSop::opChar) | ||
842 | ASSERT(tmp<seqLength); | ||
843 | m_Must+=m_Strip[tmp].m_Operand; | ||
844 | } | ||
845 | } | ||
846 | |||
847 | int CRegEx::CountPluses() | ||
848 | { | ||
849 | if(m_Error) | ||
850 | return 0; | ||
851 | int stripLen = m_Strip.GetSize(); | ||
852 | int rv = 0; | ||
853 | int nest = 0; | ||
854 | for(int tmp=0;tmp<stripLen;tmp++){ | ||
855 | switch(m_Strip[tmp].m_Operator){ | ||
856 | case CSop::opPlus0: | ||
857 | nest++; | ||
858 | break; | ||
859 | case CSop::opPlus1: | ||
860 | if(nest>rv) | ||
861 | rv = nest; | ||
862 | nest--; | ||
863 | break; | ||
864 | } | ||
865 | }// Again, originally we were supposed to scan till opEnd.. | ||
866 | if(nest) | ||
867 | m_iFlags|=iflagsBad;// Could this be an ASSERTion? | ||
868 | return rv; | ||
869 | } | ||
870 | |||
871 | void CRegEx::ParseLiteral() | ||
872 | { | ||
873 | if(!m_Pattern.GetLength()){ | ||
874 | m_Error || (m_Error=regeEmpty); | ||
875 | // ??? point to nuls? | ||
876 | } | ||
877 | while(m_ParsePointer < m_Pattern.GetLength()) | ||
878 | EmitOrdinary(m_Pattern[m_ParsePointer++]); | ||
879 | } | ||
880 | |||
881 | void CRegEx::ParseBRE(int stopa,int stopb) | ||
882 | { | ||
883 | int start = m_Strip.GetSize(); | ||
884 | BOOL first=TRUE; | ||
885 | BOOL wasDollar=FALSE; | ||
886 | if(m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='^'){ | ||
887 | m_ParsePointer++; | ||
888 | m_Error || m_Strip.Add(CSop(CSop::opBOL,0)); | ||
889 | m_iFlags|=iflagsUseBOL; | ||
890 | m_BOLs++; | ||
891 | } | ||
892 | CString stopstr; | ||
893 | if(stopa){ | ||
894 | stopstr+=stopa; | ||
895 | if(stopb) | ||
896 | stopstr+=stopb; | ||
897 | } | ||
898 | while(m_ParsePointer < m_Pattern.GetLength() && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare(stopstr))){ | ||
899 | wasDollar = ParseBREexp(first); | ||
900 | first=FALSE; | ||
901 | } | ||
902 | if(wasDollar){// Trailing anchor that was.. | ||
903 | m_Strip.SetSize(m_Strip.GetSize()-1); | ||
904 | m_Error || m_Strip.Add(CSop(CSop::opEOL,0)); | ||
905 | m_iFlags|=iflagsUseEOL; | ||
906 | m_EOLs++; | ||
907 | } | ||
908 | if(m_Strip.GetSize()==start){ | ||
909 | m_Error || (m_Error=regeEmpty); | ||
910 | // ??? point to nuls? | ||
911 | } | ||
912 | } | ||
913 | |||
914 | BOOL CRegEx::ParseBREexp(BOOL ordinaryStar) | ||
915 | { | ||
916 | int subno; | ||
917 | int pos = m_Strip.GetSize(); | ||
918 | ASSERT(m_ParsePointer<m_Pattern.GetLength()); | ||
919 | int c = m_Pattern[m_ParsePointer++]; | ||
920 | if(c=='\\'){ | ||
921 | if(m_ParsePointer>=m_Pattern.GetLength()){ | ||
922 | m_Error || (m_Error=regeEscape); | ||
923 | // ??? point to nuls | ||
924 | }else | ||
925 | c = 0x100|m_Pattern[m_ParsePointer++]; | ||
926 | } | ||
927 | switch(c){ | ||
928 | case '.': | ||
929 | if(m_Flags®NewLine) | ||
930 | EmitNonNewLineAny(); | ||
931 | else | ||
932 | m_Error || m_Strip.Add(CSop(CSop::opAny,0)); | ||
933 | break; | ||
934 | case '[': | ||
935 | ParseBracket(); | ||
936 | break; | ||
937 | case 0x100|'{': | ||
938 | m_Error || (m_Error=regeBadRepeat); | ||
939 | // ??? point to nuls? | ||
940 | break; | ||
941 | case 0x100|'(': | ||
942 | m_Subexps++; | ||
943 | subno=m_Subexps; | ||
944 | m_ParseParens.SetAtGrow(m_Subexps,CParenthesis(m_Strip.GetSize())); | ||
945 | m_Error || m_Strip.Add(CSop(CSop::opLeftParen,subno)); | ||
946 | if(m_ParsePointer<m_Pattern.GetLength() && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("\\)"))) | ||
947 | ParseBRE('\\',')'); | ||
948 | VERIFY(m_ParseParens[m_Subexps].m_End = m_Strip.GetSize()); | ||
949 | m_Error || m_Strip.Add(CSop(CSop::opRightParen,subno)); | ||
950 | if((m_ParsePointer+1) < m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("\\)")) | ||
951 | m_ParsePointer+=2; | ||
952 | else{ | ||
953 | m_Error || (m_Error=regeParen); | ||
954 | // ??? point to nuls? | ||
955 | } | ||
956 | break; | ||
957 | case 0x100|')': | ||
958 | case 0x100|'}': | ||
959 | // Can this possibly happen?! | ||
960 | m_Error || (m_Error=regeParen); | ||
961 | // ??? point to nuls? | ||
962 | break; | ||
963 | case 0x100|'1': | ||
964 | case 0x100|'2': | ||
965 | case 0x100|'3': | ||
966 | case 0x100|'4': | ||
967 | case 0x100|'5': | ||
968 | case 0x100|'6': | ||
969 | case 0x100|'7': | ||
970 | case 0x100|'8': | ||
971 | case 0x100|'9': | ||
972 | { | ||
973 | int i = (c&0xFF)-'0'; | ||
974 | if(i < m_ParseParens.GetSize() && m_ParseParens[i].m_End){ | ||
975 | m_Error || m_Strip.Add(CSop(CSop::opBackRef0,i)); | ||
976 | ASSERT(m_ParseParens[i].m_Begin); | ||
977 | ASSERT(m_Strip[m_ParseParens[i].m_Begin].m_Operator==CSop::opLeftParen); | ||
978 | ASSERT(m_Strip[m_ParseParens[i].m_End].m_Operator==CSop::opRightParen); | ||
979 | StripDuplicate(m_ParseParens[i].m_Begin+1,m_ParseParens[i].m_End); | ||
980 | m_Error || m_Strip.Add(CSop(CSop::opBackRef1,i)); | ||
981 | }else{ | ||
982 | m_Error || (m_Error=regeSubReg); | ||
983 | // ??? point to nuls? | ||
984 | } | ||
985 | m_bBackRefs=TRUE; | ||
986 | } | ||
987 | break; | ||
988 | case '*': | ||
989 | if(!ordinaryStar){ | ||
990 | m_Error || (m_Error=regeBadRepeat); | ||
991 | // ??? point to nuls? | ||
992 | } | ||
993 | // Fallthrough.. | ||
994 | default: | ||
995 | EmitOrdinary(c&0xFF); | ||
996 | break; | ||
997 | } | ||
998 | if(m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='*'){ | ||
999 | m_ParsePointer++; | ||
1000 | // as in '+?' | ||
1001 | StripInsert(pos,CSop(CSop::opPlus0,m_Strip.GetSize()-pos+1)); | ||
1002 | m_Error || m_Strip.Add(CSop(CSop::opPlus1,m_Strip.GetSize()-pos)); | ||
1003 | StripInsert(pos,CSop(CSop::opQuest0,m_Strip.GetSize()-pos+1)); | ||
1004 | m_Error || m_Strip.Add(CSop(CSop::opQuest1,m_Strip.GetSize()-pos)); | ||
1005 | }else if ((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("\\{")){ | ||
1006 | m_ParsePointer+=2; | ||
1007 | int count = ParseCount(); | ||
1008 | int count2; | ||
1009 | if(m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]==','){ | ||
1010 | m_ParsePointer++; | ||
1011 | if(m_ParsePointer<m_Pattern.GetLength() && isdigit(m_Pattern[m_ParsePointer])){ | ||
1012 | count2=ParseCount(); | ||
1013 | if(count>count2){ | ||
1014 | m_Error || (m_Error=regeBadBrace); | ||
1015 | // ??? poin to nuls? | ||
1016 | } | ||
1017 | }else // Single number with comma | ||
1018 | count2=256; | ||
1019 | }else // Single number | ||
1020 | count2=count; | ||
1021 | EmitRepeat(pos,count,count2); | ||
1022 | if((m_ParsePointer+1)>=m_Pattern.GetLength() || m_Pattern.Mid(m_ParsePointer,2).Compare("\\}")){ | ||
1023 | while(m_ParsePointer<m_Pattern.GetLength() && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("\\}"))) | ||
1024 | m_ParsePointer++; | ||
1025 | if(m_ParsePointer>=m_Pattern.GetLength()){ | ||
1026 | m_Error || (m_Error=regeBrace); | ||
1027 | // ??? point to nuls? | ||
1028 | } | ||
1029 | m_Error || (m_Error=regeBadBrace); | ||
1030 | }else | ||
1031 | m_ParsePointer+=2; | ||
1032 | }else if(c=='$') | ||
1033 | return TRUE; | ||
1034 | return FALSE; | ||
1035 | } | ||
1036 | |||
1037 | CRegEx::CRegEx() | ||
1038 | { | ||
1039 | m_bCompiled=FALSE; | ||
1040 | } | ||
1041 | |||
1042 | LPCTSTR CRegEx::MatchFast(LPCTSTR begin) | ||
1043 | { | ||
1044 | MatchStatesClear(CSop::stCurrent); | ||
1045 | m_Strip[1].m_MatchData|=CSop::stCurrent; | ||
1046 | int stripLen = m_Strip.GetSize(); | ||
1047 | MatchStep(1,stripLen-1,CSop::stCurrent,charNothing,CSop::stCurrent); | ||
1048 | MatchStatesCopy(CSop::stFresh,CSop::stCurrent); | ||
1049 | LPCTSTR coldp = NULL; | ||
1050 | LPCTSTR p = begin; | ||
1051 | int c = (begin==m_mBegin)?charOut:((int)(BYTE)m_mPointer[-1]); | ||
1052 | for(;;){ | ||
1053 | // next character.. | ||
1054 | int lastc = c; | ||
1055 | c = (p==m_mEnd)?charOut:(int)*(BYTE*)p; | ||
1056 | if(MatchStatesEqual(CSop::stCurrent,CSop::stFresh)) | ||
1057 | coldp=p; | ||
1058 | // Is there an EOL and/or BOL between lastc and c? - they ask.. | ||
1059 | intflagc=0; | ||
1060 | inti = 0; | ||
1061 | if((lastc=='\n' && m_Flags®NewLine) || (lastc==charOut && !(m_mFlags®NotBOL))){ | ||
1062 | flagc=charBOL; | ||
1063 | i=m_BOLs; | ||
1064 | } | ||
1065 | if((c=='\n' && m_Flags®NewLine) || (c==charOut && !(m_mFlags®NotEOL))){ | ||
1066 | flagc=(flagc==charBOL)?charBOLEOL:charEOL; | ||
1067 | i+=m_EOLs; | ||
1068 | } | ||
1069 | if(i){ | ||
1070 | for(;i>0;i--) | ||
1071 | MatchStep(1,stripLen-1,CSop::stCurrent,flagc,CSop::stCurrent); | ||
1072 | } | ||
1073 | // What about a word boundary? - they wonder.. | ||
1074 | if((flagc==charBOL || (lastc!=charOut && !isWordableChar(c))) && (c!=charOut && isWordableChar(c))) | ||
1075 | flagc = charBOW; | ||
1076 | if((lastc!=charOut && isWordableChar(lastc)) && (flagc==charEOL || (c!=charOut && !isWordableChar(c)))) | ||
1077 | flagc = charEOW; | ||
1078 | if(flagc==charBOW || flagc==charEOW){ | ||
1079 | MatchStep(1,stripLen-1,CSop::stCurrent,flagc,CSop::stCurrent); | ||
1080 | } | ||
1081 | // Are we done? Now WE wonder.. | ||
1082 | if((m_Strip[stripLen-1].m_MatchData&CSop::stCurrent) || p==m_mEnd) | ||
1083 | break;// They insist I need to note break out.. Okay, I do.. | ||
1084 | // Nope, we're not done. We have to face this character.. | ||
1085 | MatchStatesCopy(CSop::stTemp,CSop::stCurrent); | ||
1086 | MatchStatesCopy(CSop::stCurrent,CSop::stFresh); | ||
1087 | ASSERT(c!=charOut); | ||
1088 | MatchStep(1,stripLen-1,CSop::stTemp,c,CSop::stCurrent); | ||
1089 | p++; | ||
1090 | } | ||
1091 | ASSERT(coldp); | ||
1092 | m_cOldP=coldp;// *** I believe this variable can be changed 'in-place' | ||
1093 | if(m_Strip[stripLen-1].m_MatchData&CSop::stCurrent) | ||
1094 | return &p[1]; | ||
1095 | else | ||
1096 | return NULL; | ||
1097 | } | ||
1098 | |||
1099 | void CRegEx::MatchStatesClear(BYTE mask) | ||
1100 | { | ||
1101 | int stripLen = m_Strip.GetSize(); | ||
1102 | for(int tmp=0;tmp<stripLen;tmp++) | ||
1103 | m_Strip[tmp].m_MatchData&=~mask; | ||
1104 | } | ||
1105 | |||
1106 | void CRegEx::MatchStep(int from,int to,BYTE maskBefore,int charCode,BYTE maskAfter) | ||
1107 | { | ||
1108 | BOOL i; | ||
1109 | int look; | ||
1110 | int here = from; | ||
1111 | for(int pc=from;pc!=to;pc++,here++){ | ||
1112 | CSop s=m_Strip[pc]; | ||
1113 | switch(s.m_Operator){ | ||
1114 | case CSop::opEnd: | ||
1115 | ASSERT(pc==(to-1)); | ||
1116 | break; | ||
1117 | case CSop::opChar: | ||
1118 | // Only characters can match.. | ||
1119 | ASSERT((charCode<charOut) || charCode!=s.m_Operand); | ||
1120 | if(charCode==s.m_Operand) | ||
1121 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0; | ||
1122 | break; | ||
1123 | case CSop::opBOL: | ||
1124 | if(charCode==charBOL || charCode==charBOLEOL) | ||
1125 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0; | ||
1126 | break; | ||
1127 | case CSop::opEOL: | ||
1128 | if(charCode==charEOL || charCode==charBOLEOL) | ||
1129 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0; | ||
1130 | break; | ||
1131 | case CSop::opBOW: | ||
1132 | if(charCode==charBOW) | ||
1133 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0; | ||
1134 | break; | ||
1135 | case CSop::opEOW: | ||
1136 | if(charCode==charEOW) | ||
1137 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0; | ||
1138 | break; | ||
1139 | case CSop::opAny: | ||
1140 | if(charCode<charOut) | ||
1141 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0; | ||
1142 | break; | ||
1143 | case CSop::opAnyOf: | ||
1144 | if(charCode<charOut && m_Sets[s.m_Operand].m_Set[charCode]) | ||
1145 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0; | ||
1146 | break; | ||
1147 | case CSop::opBackRef0:// Ignored here.. | ||
1148 | case CSop::opBackRef1: | ||
1149 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1150 | break; | ||
1151 | case CSop::opPlus0: | ||
1152 | // Forward, this is just an empty, comment says.. | ||
1153 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1154 | break; | ||
1155 | case CSop::opPlus1: | ||
1156 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1157 | i =(m_Strip[here-s.m_Operand].m_MatchData&maskAfter)!=0; | ||
1158 | m_Strip[here-s.m_Operand].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1159 | if(!i && (m_Strip[here-s.m_Operand].m_MatchData&maskAfter)){ | ||
1160 | // oho, must reconsider loop body, comment says.. what's so 'oho' about it? | ||
1161 | pc-=s.m_Operand+1; | ||
1162 | here=pc; | ||
1163 | } | ||
1164 | break; | ||
1165 | case CSop::opQuest0: | ||
1166 | // two branches, both forward.. | ||
1167 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1168 | m_Strip[here+s.m_Operand].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1169 | break; | ||
1170 | case CSop::opQuest1: | ||
1171 | // just an empty.. aren't we tired of justanempties? | ||
1172 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1173 | break; | ||
1174 | case CSop::opLeftParen: // they say it's not significan there.. | ||
1175 | case CSop::opRightParen: | ||
1176 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1177 | break; | ||
1178 | case CSop::opChoice0:// mark the first two branches.. | ||
1179 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1180 | ASSERT(m_Strip[pc+s.m_Operand].m_Operator==CSop::opOr1); | ||
1181 | m_Strip[here+s.m_Operand].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1182 | break; | ||
1183 | case CSop::opOr0:// done a branch, find the end of choice.. | ||
1184 | if(m_Strip[here].m_MatchData&maskAfter){ | ||
1185 | for(look=1;(s=m_Strip[pc+look]).m_Operator!=CSop::opChoice1;look+=s.m_Operand) | ||
1186 | ASSERT(s.m_Operator==CSop::opOr1); | ||
1187 | m_Strip[here+look].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1188 | } | ||
1189 | break; | ||
1190 | case CSop::opOr1: // Propagate Choice's marking.. | ||
1191 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1192 | if(m_Strip[pc+s.m_Operand].m_Operator!=CSop::opChoice1){ | ||
1193 | ASSERT(m_Strip[pc+s.m_Operand].m_Operator==CSop::opOr1); | ||
1194 | m_Strip[here+s.m_Operand].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1195 | } | ||
1196 | break; | ||
1197 | case CSop::opChoice1: // Just empty.. :-).. | ||
1198 | m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0; | ||
1199 | break; | ||
1200 | #ifdef _DEBUG | ||
1201 | default: | ||
1202 | ASSERT(FALSE); | ||
1203 | break; | ||
1204 | #endif | ||
1205 | } | ||
1206 | } | ||
1207 | } | ||
1208 | |||
1209 | void CRegEx::MatchStatesCopy(BYTE dst,BYTE src) | ||
1210 | { | ||
1211 | int stripLen = m_Strip.GetSize(); | ||
1212 | for(int tmp=0;tmp<stripLen;tmp++){ | ||
1213 | // I believe this can be optimized, easily.. | ||
1214 | m_Strip[tmp].m_MatchData&=~dst; | ||
1215 | m_Strip[tmp].m_MatchData|=(m_Strip[tmp].m_MatchData&src)?dst:0; | ||
1216 | } | ||
1217 | } | ||
1218 | |||
1219 | BOOL CRegEx::MatchStatesEqual(BYTE m1,BYTE m2) | ||
1220 | { | ||
1221 | int stripLen = m_Strip.GetSize(); | ||
1222 | for(int tmp=0;tmp<stripLen;tmp++){ | ||
1223 | BYTE mm = m_Strip[tmp].m_MatchData; | ||
1224 | if(((mm&m1) && (mm&m2)) || !(mm&(m1|m2))) | ||
1225 | continue; | ||
1226 | return FALSE; | ||
1227 | } | ||
1228 | return TRUE; | ||
1229 | } | ||
1230 | |||
1231 | LPCTSTR CRegEx::MatchSlow(LPCTSTR begin,LPCTSTR end,int from,int to) | ||
1232 | { | ||
1233 | MatchStatesClear(CSop::stCurrent); | ||
1234 | m_Strip[from].m_MatchData|=CSop::stCurrent; | ||
1235 | MatchStep(from,to,CSop::stCurrent,charNothing,CSop::stCurrent); | ||
1236 | LPCTSTR mp = NULL; | ||
1237 | int c = (m_mBegin==m_mPointer)?charOut:(int)(BYTE)begin[-1]; | ||
1238 | LPCTSTR p = begin; | ||
1239 | for(;;){ | ||
1240 | // next character.. | ||
1241 | int lastc = c; | ||
1242 | c = (p==m_mEnd)?charOut:(int)*(BYTE*)p; | ||
1243 | // Now we start to wonder if there is an EOL and/or BOL between lastc and c | ||
1244 | int flagc = 0; | ||
1245 | int i = 0; | ||
1246 | if((lastc=='\n' && m_Flags®NewLine) || (lastc==charOut && !(m_mFlags®NotBOL))){ | ||
1247 | flagc = charBOL; | ||
1248 | i = m_BOLs; | ||
1249 | } | ||
1250 | if((c=='\n' && m_Flags®NewLine) || (c==charOut && !(m_mFlags®NotEOL))){ | ||
1251 | flagc = (flagc==charBOL)?charBOLEOL:charEOL; | ||
1252 | i+=m_EOLs; | ||
1253 | } | ||
1254 | if(i){ | ||
1255 | for(;i>0;i--) | ||
1256 | MatchStep(from,to,CSop::stCurrent,flagc,CSop::stCurrent); | ||
1257 | } | ||
1258 | // Now we wonder about word boundaries.. | ||
1259 | if((flagc==charBOL || (lastc!=charOut && !isWordableChar(lastc))) && (c!=charOut && isWordableChar(c))) | ||
1260 | flagc=charBOW; | ||
1261 | if((lastc!=charOut && isWordableChar(lastc)) && (flagc==charEOL || (c!=charOut && !isWordableChar(c)))) | ||
1262 | flagc=charEOW; | ||
1263 | if(flagc==charBOW || flagc==charEOW){ | ||
1264 | MatchStep(from,to,CSop::stCurrent,flagc,CSop::stCurrent); | ||
1265 | } | ||
1266 | // Are we done we all wonder?? | ||
1267 | if(m_Strip[to].m_MatchData&CSop::stCurrent) | ||
1268 | mp=p; | ||
1269 | if(MatchStatesEqual(CSop::stCurrent,CSop::stEmpty) || p==end) | ||
1270 | break;// Again, we're obliged to note break out. We do. | ||
1271 | // Sucks.. we have to face this character.. | ||
1272 | MatchStatesCopy(CSop::stTemp,CSop::stCurrent); | ||
1273 | MatchStatesCopy(CSop::stCurrent,CSop::stEmpty); | ||
1274 | ASSERT(c!=charOut); | ||
1275 | MatchStep(from,to,CSop::stTemp,c,CSop::stCurrent); | ||
1276 | MatchStep(from,to,CSop::stCurrent,charNothing,CSop::stCurrent); | ||
1277 | p++; | ||
1278 | } | ||
1279 | return mp; | ||
1280 | } | ||
1281 | |||
1282 | LPCTSTR CRegEx::MatchDissect(LPCTSTR begin,LPCTSTR end,int from,int to) | ||
1283 | { | ||
1284 | LPCTSTR sp = begin, dp; | ||
1285 | LPCTSTR stp, rest, tail, ssp, oldssp, sep; | ||
1286 | int ssub, esub; | ||
1287 | int es; | ||
1288 | int i; | ||
1289 | for(int ss=from;ss<to;ss = es){ | ||
1290 | // Identify end of SubRE | ||
1291 | es = ss; | ||
1292 | switch(m_Strip[es].m_Operator){ | ||
1293 | case CSop::opPlus0: | ||
1294 | case CSop::opQuest0: | ||
1295 | es+=m_Strip[es].m_Operand; | ||
1296 | break; | ||
1297 | case CSop::opChoice0: | ||
1298 | while(m_Strip[es].m_Operator!=CSop::opChoice1) | ||
1299 | es+=m_Strip[es].m_Operand; | ||
1300 | break; | ||
1301 | } | ||
1302 | es++; | ||
1303 | // Figure out what it matched | ||
1304 | switch(m_Strip[ss].m_Operator){ | ||
1305 | case CSop::opEnd: | ||
1306 | ASSERT(FALSE); | ||
1307 | break; | ||
1308 | case CSop::opChar: | ||
1309 | sp++; | ||
1310 | break; | ||
1311 | case CSop::opBOL: | ||
1312 | case CSop::opEOL: | ||
1313 | case CSop::opBOW: | ||
1314 | case CSop::opEOW: | ||
1315 | break; | ||
1316 | case CSop::opAny: | ||
1317 | case CSop::opAnyOf: | ||
1318 | sp++; | ||
1319 | break; | ||
1320 | case CSop::opBackRef0: | ||
1321 | case CSop::opBackRef1: | ||
1322 | ASSERT(FALSE); | ||
1323 | break; | ||
1324 | // Cases where lenght of match is hard to find.. | ||
1325 | case CSop::opQuest0: | ||
1326 | stp=end; | ||
1327 | for(;;){ | ||
1328 | // How long could this one be?? | ||
1329 | rest = MatchSlow(sp,stp,ss,es); | ||
1330 | ASSERT(rest);// It did match.. It should've.. | ||
1331 | // Could the rest match the rest? (good question) | ||
1332 | tail = MatchSlow(rest,end,es,to); | ||
1333 | if(tail==end) | ||
1334 | break;// yup. | ||
1335 | // nope, try a shorter match for this one.. | ||
1336 | stp=rest-1; | ||
1337 | ASSERT(stp>=sp);// It did work.. It should've.. | ||
1338 | } | ||
1339 | ssub=ss+1; | ||
1340 | esub=es-1; | ||
1341 | // Did innards match? | ||
1342 | if(MatchSlow(sp,rest,ssub,esub)){ | ||
1343 | dp = MatchDissect(sp,rest,ssub,esub); | ||
1344 | ASSERT(dp==rest); | ||
1345 | }else// nope.. | ||
1346 | ASSERT(sp==rest); | ||
1347 | sp = rest; | ||
1348 | break; | ||
1349 | case CSop::opPlus0: | ||
1350 | stp=end; | ||
1351 | for(;;){ | ||
1352 | // How long could this one be?? | ||
1353 | rest = MatchSlow(sp,stp,ss,es); | ||
1354 | ASSERT(rest);// It did.. It should've.. | ||
1355 | // Could the rest match the rest? | ||
1356 | tail = MatchSlow(rest,end,es,to); | ||
1357 | if(tail==end) | ||
1358 | break;// yup. | ||
1359 | // nope.. | ||
1360 | stp=rest-1; | ||
1361 | ASSERT(stp>=sp);// It should've worked, we believe.. | ||
1362 | } | ||
1363 | ssub=ss+1; | ||
1364 | esub=es-1; | ||
1365 | ssp=sp; | ||
1366 | oldssp=ssp; | ||
1367 | for(;;){// Find last match of innards.. | ||
1368 | sep = MatchSlow(ssp,rest,ssub,esub); | ||
1369 | if((!sep) || sep==ssp) | ||
1370 | break; // Failed or matched nothin' | ||
1371 | oldssp=ssp; | ||
1372 | ssp=sep; | ||
1373 | } | ||
1374 | if(!sep){ | ||
1375 | // Last successfull.. | ||
1376 | sep=ssp; | ||
1377 | ssp=oldssp; | ||
1378 | } | ||
1379 | ASSERT(sep=rest);// Must exhaust substring they say.. | ||
1380 | VERIFY(MatchSlow(ssp,sep,ssub,esub)==rest);// Assert or verify - that is the question.. | ||
1381 | dp = MatchDissect(ssp,sep,ssub,esub); | ||
1382 | ASSERT(dp==sep); | ||
1383 | sp=rest; | ||
1384 | break; | ||
1385 | case CSop::opChoice0: | ||
1386 | stp = end; | ||
1387 | for(;;){ | ||
1388 | // how long.. | ||
1389 | rest = MatchSlow(sp,stp,ss,es); | ||
1390 | ASSERT(rest); | ||
1391 | // Could it.. | ||
1392 | tail = MatchSlow(rest,end,es,to); | ||
1393 | if(tail==end) | ||
1394 | break;// y | ||
1395 | // n | ||
1396 | stp = rest-1; | ||
1397 | ASSERT(stp>=sp); | ||
1398 | } | ||
1399 | ssub=ss+1; | ||
1400 | esub=ss+m_Strip[ss].m_Operand-1; | ||
1401 | ASSERT(m_Strip[esub].m_Operator==CSop::opOr0); | ||
1402 | for(;;){// Find first matching branch.. | ||
1403 | if(MatchSlow(sp,rest,ssub,esub)==rest) | ||
1404 | break; | ||
1405 | // this one missed, try next.. | ||
1406 | ASSERT(m_Strip[esub].m_Operator==CSop::opOr0); | ||
1407 | esub++; | ||
1408 | ASSERT(m_Strip[esub].m_Operator==CSop::opOr1); | ||
1409 | ssub=esub+1; | ||
1410 | esub+=m_Strip[esub].m_Operand; | ||
1411 | if(m_Strip[esub].m_Operator==CSop::opOr1) | ||
1412 | esub--; | ||
1413 | else | ||
1414 | ASSERT(m_Strip[esub].m_Operator==CSop::opChoice1); | ||
1415 | } | ||
1416 | dp = MatchDissect(sp,rest,ssub,esub); | ||
1417 | ASSERT(dp==rest); | ||
1418 | sp=rest; | ||
1419 | break; | ||
1420 | case CSop::opPlus1: | ||
1421 | case CSop::opQuest1: | ||
1422 | case CSop::opOr0: | ||
1423 | case CSop::opOr1: | ||
1424 | case CSop::opChoice1: | ||
1425 | ASSERT(FALSE); | ||
1426 | break; | ||
1427 | case CSop::opLeftParen: | ||
1428 | i = m_Strip[ss].m_Operand; | ||
1429 | ASSERT(0<i && i<=m_Subexps); | ||
1430 | m_Matches[i].m_Begin=sp-m_mBegin; | ||
1431 | break; | ||
1432 | case CSop::opRightParen: | ||
1433 | i = m_Strip[ss].m_Operand; | ||
1434 | ASSERT(0<i && i<=m_Subexps); | ||
1435 | m_Matches[i].m_End=sp-m_mBegin; | ||
1436 | break; | ||
1437 | #ifdef _DEBUG | ||
1438 | default:// Uh.. oh.. | ||
1439 | ASSERT(FALSE); | ||
1440 | break; | ||
1441 | #endif | ||
1442 | } | ||
1443 | } | ||
1444 | ASSERT(sp==end); | ||
1445 | return sp; | ||
1446 | } | ||
1447 | |||
1448 | LPCTSTR CRegEx::MatchBackRef(LPCTSTR begin,LPCTSTR end,int from,int to,int level) | ||
1449 | { | ||
1450 | LPCTSTR sp = begin; | ||
1451 | BOOL hard = FALSE; | ||
1452 | // Get as far as we can as long as it's easy | ||
1453 | for(int ss=from;!hard && ss<to;ss++){ | ||
1454 | CSop s = m_Strip[ss]; | ||
1455 | switch(s.m_Operator){ | ||
1456 | case CSop::opChar: | ||
1457 | if(sp==end || *sp++ != s.m_Operand) | ||
1458 | return NULL; | ||
1459 | break; | ||
1460 | case CSop::opAny: | ||
1461 | if(sp==end) | ||
1462 | return NULL; | ||
1463 | sp++;// I'm sure this ++ could be embedded in previous expression.. | ||
1464 | break; | ||
1465 | case CSop::opAnyOf: | ||
1466 | if(sp==end || !m_Sets[s.m_Operand].IsIn(*sp++)) | ||
1467 | return NULL; | ||
1468 | break; | ||
1469 | case CSop::opBOL: | ||
1470 | if(!((sp==m_mBegin && !(m_mFlags®NotBOL)) || (sp<m_mEnd && *(sp-1)=='\n' && (m_Flags®NewLine)))) | ||
1471 | return NULL; | ||
1472 | break; | ||
1473 | case CSop::opEOL: | ||
1474 | if(!((sp==m_mEnd && !(m_mFlags®NotEOL)) || (sp<m_mEnd && *sp=='\n' && (m_Flags®NewLine)))) | ||
1475 | return NULL; | ||
1476 | break; | ||
1477 | case CSop::opBOW: | ||
1478 | if(!(((sp==m_mBegin && !(m_mFlags®NotBOL)) || (sp<m_mEnd && *(sp-1)=='\n' && (m_Flags®NewLine)) || (sp>m_mBegin && !isWordableChar(*(sp-1)))) && (sp<m_mEnd && isWordableChar(*sp)))) | ||
1479 | return NULL; | ||
1480 | break; | ||
1481 | case CSop::opEOW: | ||
1482 | if(!(((sp==m_mEnd && !(m_mFlags®NotEOL)) || (sp<m_mEnd && *sp=='\n' && (m_Flags®NewLine)) || (sp<m_mEnd && !isWordableChar(*sp))) && (sp>m_mBegin && isWordableChar(*(sp-1))))) | ||
1483 | return NULL; | ||
1484 | break; | ||
1485 | case CSop::opQuest1: | ||
1486 | break; | ||
1487 | case CSop::opOr0:// Matches null, but needs to skip | ||
1488 | ss++; | ||
1489 | s = m_Strip[ss]; | ||
1490 | do{ | ||
1491 | ASSERT(s.m_Operator==CSop::opOr1); | ||
1492 | ss+=s.m_Operand; | ||
1493 | }while((s=m_Strip[ss]).m_Operator!=CSop::opChoice1); | ||
1494 | // Now we should note that ss++ gets us past the Choice1.. | ||
1495 | break; | ||
1496 | default: | ||
1497 | // Have to make a choice.. | ||
1498 | hard=TRUE; | ||
1499 | break; | ||
1500 | } | ||
1501 | } | ||
1502 | if(!hard){// That was it.. | ||
1503 | if(sp!=end) | ||
1504 | return NULL; | ||
1505 | return sp; | ||
1506 | } | ||
1507 | ss--;// Adjust for ther for's final increment.. | ||
1508 | // Hard stuff.. is going on and on.. | ||
1509 | CSop s = m_Strip[ss]; | ||
1510 | int i, len, offsave; | ||
1511 | int ssub,esub; | ||
1512 | LPCTSTR ssp, dp; | ||
1513 | switch(s.m_Operator){ | ||
1514 | case CSop::opBackRef0:// The vilest depths they say.. If I only knew what the 'viles' stands for.. | ||
1515 | i = s.m_Operand; | ||
1516 | ASSERT(0<i && i<=m_Subexps); | ||
1517 | if(m_Matches[i].m_End<0) | ||
1518 | return NULL; | ||
1519 | ASSERT(m_Matches[i].m_Begin>=0); | ||
1520 | len = m_Matches[i].GetLength(); | ||
1521 | ASSERT((end-m_mBegin)>=len); | ||
1522 | if(sp>end-len) | ||
1523 | return NULL;// Not enough left to match.. | ||
1524 | ssp = m_mBegin+m_Matches[i].m_Begin; | ||
1525 | if(memcmp(sp,ssp,len)) | ||
1526 | return NULL; | ||
1527 | while(m_Strip[ss]!=CSop(CSop::opBackRef1,i)) | ||
1528 | ss++; | ||
1529 | return MatchBackRef(sp+len,end,ss+1,to,level-1); | ||
1530 | break; | ||
1531 | case CSop::opQuest0:// to null or not they wonder.. | ||
1532 | dp = MatchBackRef(sp,end,ss+1,to,level); | ||
1533 | if(dp) | ||
1534 | return dp;// not.. | ||
1535 | return MatchBackRef(sp,end,ss+s.m_Operand+1,to,level-1); | ||
1536 | break; | ||
1537 | case CSop::opPlus0: | ||
1538 | ASSERT(m_mLastPos.GetSize()); | ||
1539 | ASSERT(level+1 <= m_Pluses); | ||
1540 | m_mLastPos[level+1]=sp; | ||
1541 | return MatchBackRef(sp,end,ss+1,to,level+1); | ||
1542 | break; | ||
1543 | case CSop::opPlus1: | ||
1544 | if(sp == m_mLastPos[level])// Last pass matched null | ||
1545 | return MatchBackRef(sp,end,ss+1,to,level-1); | ||
1546 | // Try another pass.. | ||
1547 | m_mLastPos[level]=sp; | ||
1548 | dp = MatchBackRef(sp,end,ss-s.m_Operand+1,to,level); | ||
1549 | if(dp) | ||
1550 | return dp; | ||
1551 | return MatchBackRef(sp,end,ss+1,to,level-1); | ||
1552 | break; | ||
1553 | case CSop::opChoice0:// find the right one, ifany | ||
1554 | ssub = ss+1; | ||
1555 | esub = ss+s.m_Operand-1; | ||
1556 | ASSERT(m_Strip[esub].m_Operator==CSop::opOr0); | ||
1557 | for(;;){// Find first matching branch. | ||
1558 | dp = MatchBackRef(sp,end,ssub,esub,level); | ||
1559 | if(dp) | ||
1560 | return dp; | ||
1561 | // This one missed, try next one.. | ||
1562 | if(m_Strip[esub].m_Operator==CSop::opChoice1) | ||
1563 | return NULL;// There is none.. | ||
1564 | esub++; | ||
1565 | ASSERT(m_Strip[esub].m_Operator==CSop::opOr1); | ||
1566 | ssub=esub+1; | ||
1567 | esub+=m_Strip[esub].m_Operand; | ||
1568 | if(m_Strip[esub].m_Operator==CSop::opOr1) | ||
1569 | esub--; | ||
1570 | else | ||
1571 | ASSERT(m_Strip[esub].m_Operator==CSop::opChoice1); | ||
1572 | } | ||
1573 | break; | ||
1574 | case CSop::opLeftParen:// Must undo assignment if rest fails.. | ||
1575 | i = s.m_Operand; | ||
1576 | ASSERT(0<i && i<=m_Subexps); | ||
1577 | offsave = m_Matches[i].m_Begin; | ||
1578 | m_Matches[i].m_Begin = sp-m_mBegin; | ||
1579 | dp = MatchBackRef(sp,end,ss+1,to,level); | ||
1580 | if(dp) | ||
1581 | return dp; | ||
1582 | m_Matches[i].m_Begin=offsave; | ||
1583 | return NULL; | ||
1584 | break; | ||
1585 | case CSop::opRightParen: // Must undo assignment if rest fails.. | ||
1586 | i = s.m_Operand; | ||
1587 | ASSERT(0<i && i<=m_Subexps); | ||
1588 | offsave = m_Matches[i].m_End; | ||
1589 | m_Matches[i].m_End = sp-m_mBegin; | ||
1590 | dp = MatchBackRef(sp,end,ss+1,to,level); | ||
1591 | if(dp) | ||
1592 | return dp; | ||
1593 | m_Matches[i].m_End = offsave; | ||
1594 | return NULL; | ||
1595 | break; | ||
1596 | #ifdef_DEBUG | ||
1597 | default: | ||
1598 | ASSERT(FALSE); | ||
1599 | break; | ||
1600 | #endif | ||
1601 | } | ||
1602 | ASSERT(FALSE); | ||
1603 | return NULL;// Anyway - we can never get here.. | ||
1604 | } | ||
1605 | |||
1606 | #ifdef_DEBUG | ||
1607 | void CRegEx::CSop::Dump(CDumpContext& dc) | ||
1608 | { | ||
1609 | switch(m_Operator){ | ||
1610 | case opEnd: | ||
1611 | dc << "end"; | ||
1612 | break; | ||
1613 | case opChar: | ||
1614 | dc << "char('" << (char)m_Operand << "')"; | ||
1615 | break; | ||
1616 | case opBOL: | ||
1617 | dc << "BOL"; | ||
1618 | break; | ||
1619 | case opEOL: | ||
1620 | dc << "EOL"; | ||
1621 | break; | ||
1622 | case opAny: | ||
1623 | dc << "any"; | ||
1624 | break; | ||
1625 | case opAnyOf: | ||
1626 | dc << "anyOf(" << m_Operand << ")"; | ||
1627 | break; | ||
1628 | case opBackRef0: | ||
1629 | dc << "[ backref(" << m_Operand << ")"; | ||
1630 | break; | ||
1631 | case opBackRef1: | ||
1632 | dc << "] backref(" << m_Operand << ")"; | ||
1633 | break; | ||
1634 | case opPlus0: | ||
1635 | dc << "[ + (" << m_Operand << ")"; | ||
1636 | break; | ||
1637 | case opPlus1: | ||
1638 | dc << "] + (" << m_Operand << ")"; | ||
1639 | break; | ||
1640 | case opQuest0: | ||
1641 | dc << "[ ? (" << m_Operand << ")"; | ||
1642 | break; | ||
1643 | case opQuest1: | ||
1644 | dc << "] ? (" << m_Operand << ")"; | ||
1645 | break; | ||
1646 | case opLeftParen: | ||
1647 | dc << "[ ( (" << m_Operand << ")"; | ||
1648 | break; | ||
1649 | case opRightParen: | ||
1650 | dc << "] ) (" << m_Operand << ")"; | ||
1651 | break; | ||
1652 | case opChoice0: | ||
1653 | dc << "[ choice (" << m_Operand << ")"; | ||
1654 | break; | ||
1655 | case opOr0: | ||
1656 | dc << "[ | (" << m_Operand << ")"; | ||
1657 | break; | ||
1658 | case opOr1: | ||
1659 | dc << "] | (" << m_Operand << ")"; | ||
1660 | break; | ||
1661 | case opChoice1: | ||
1662 | dc << "] choice (" << m_Operand << ")"; | ||
1663 | break; | ||
1664 | case opBOW: | ||
1665 | dc << "BOW"; | ||
1666 | break; | ||
1667 | case opEOW: | ||
1668 | dc << "EOW"; | ||
1669 | break; | ||
1670 | } | ||
1671 | } | ||
1672 | void CRegEx::DumpStrip(CDumpContext& dc) | ||
1673 | { | ||
1674 | for(int tmp=0;tmp<m_Strip.GetSize();tmp++) | ||
1675 | dc << tmp << ": " << m_Strip[tmp] << ";\n"; | ||
1676 | } | ||
1677 | #endif | ||
1678 | |||
1679 | |||
1680 | CString CRegEx::GetMatch(int match) | ||
1681 | { | ||
1682 | CString rv; | ||
1683 | if(!m_Matches.GetSize()) | ||
1684 | return rv; | ||
1685 | ASSERT(m_Matches[0].m_Begin<m_Input.GetLength() && m_Matches[0].m_End<=m_Input.GetLength()); | ||
1686 | if(match==matchPreMatch) | ||
1687 | return m_Input.Left(m_Matches[0].m_Begin); | ||
1688 | if(match==matchPostMatch) | ||
1689 | return m_Input.Mid(m_Matches[0].m_End); | ||
1690 | if(match<0 || match >= m_Matches.GetSize()) | ||
1691 | return rv; | ||
1692 | if(m_Matches[match].m_Begin<0 || m_Matches[match].m_End<0) | ||
1693 | return rv; | ||
1694 | ASSERT(m_Matches[match].m_Begin<m_Input.GetLength() && m_Matches[match].m_End<=m_Input.GetLength()); | ||
1695 | rv = m_Input.Mid(m_Matches[match].m_Begin,m_Matches[match].m_End-m_Matches[match].m_Begin); | ||
1696 | return rv; | ||
1697 | } | ||
diff --git a/shared-code/RegEx.h b/shared-code/RegEx.h new file mode 100644 index 0000000..2534768 --- a/dev/null +++ b/shared-code/RegEx.h | |||
@@ -0,0 +1,158 @@ | |||
1 | #ifndef __REGEX_H | ||
2 | #define __REGEX_H | ||
3 | |||
4 | class CRegEx{ | ||
5 | public: | ||
6 | CString GetMatch(int match=0); | ||
7 | CString m_Input; | ||
8 | struct CMatch{ | ||
9 | CMatch() : m_Begin(-1), m_End(-1) {} | ||
10 | int GetLength() { return m_End-m_Begin; } | ||
11 | int m_Begin; | ||
12 | int m_End; | ||
13 | }; | ||
14 | typedefCArray<CMatch,CMatch&> CMatchBox; | ||
15 | enum{ | ||
16 | matchMatch = 0, | ||
17 | matchPreMatch = -1, | ||
18 | matchPostMatch = -2 | ||
19 | }; | ||
20 | CMatchBox m_Matches; | ||
21 | enum{ | ||
22 | charOut = 256, | ||
23 | charBOL, charEOL, charBOLEOL, charNothing, charBOW, charEOW, | ||
24 | charMaxCode = charEOW, | ||
25 | charNNChars = (charMaxCode-255) | ||
26 | }; | ||
27 | int m_mFlags; | ||
28 | enum{ | ||
29 | regeSuccess = 0, | ||
30 | regeNoMatch = 1, regeBadPattern, regeCollate, regeCType, regeEscape, regeSubReg, regeBracket, | ||
31 | regeParen, regeBrace, regeBadBrace, regeRange, regeSpace, regeBadRepeat, regeEmpty, regeAssert, | ||
32 | regeInvArg | ||
33 | }; | ||
34 | int m_Error; | ||
35 | CRegEx(); | ||
36 | BOOL m_bCompiled; | ||
37 | CString m_Pattern; | ||
38 | BOOL m_bBackRefs; | ||
39 | int m_Pluses; | ||
40 | CString m_Must; | ||
41 | BYTE m_Category[CHAR_MAX-CHAR_MIN+1]; | ||
42 | int m_Categories; | ||
43 | int m_EOLs; | ||
44 | int m_BOLs; | ||
45 | int m_iFlags; | ||
46 | int m_Subexps; | ||
47 | struct CSop { | ||
48 | void Dump(CDumpContext& dc); | ||
49 | CSop(){} | ||
50 | CSop(BYTE op,DWORD opnd=0) : m_Operator(op), m_Operand(opnd) {} | ||
51 | BOOL operator==(CSop& other) {return m_Operator==other.m_Operator && m_Operand==other.m_Operand;} | ||
52 | BOOL operator!=(CSop& other) { return !((*this)==other);} | ||
53 | enum{ | ||
54 | opEnd = 1, opChar, opBOL, opEOL, opAny, opAnyOf, opBackRef0, opBackRef1, | ||
55 | opPlus0, opPlus1, opQuest0, opQuest1, opLeftParen, opRightParen, opChoice0, | ||
56 | opOr0, opOr1, opChoice1, opBOW, opEOW | ||
57 | }; | ||
58 | BYTE m_Operator; | ||
59 | DWORD m_Operand; | ||
60 | enum{ | ||
61 | stCurrent = 1, stFresh = 2, stTemp = 4, stEmpty = 8 | ||
62 | }; | ||
63 | BYTE m_MatchData; | ||
64 | }; | ||
65 | typedef CArray<CSop,CSop&> CStrip; | ||
66 | CStrip m_Strip; | ||
67 | int m_Flags; | ||
68 | struct CSet{ | ||
69 | CSet() : m_Hash(0) { memset(m_Set,0,sizeof(m_Set)); } | ||
70 | CSet(CSet& src) { (*this)=src; } | ||
71 | CSet& operator=(CSet& src) { memmove(this,&src,sizeof(*this)); return *this; } | ||
72 | BOOL operator==(CSet& other) { if(m_Hash!=other.m_Hash)return FALSE;return !memcmp(m_Set,other.m_Set,sizeof(m_Set)); } | ||
73 | enum{ | ||
74 | size = (CHAR_MAX-CHAR_MIN+1) | ||
75 | }; | ||
76 | BOOL m_Set[size]; | ||
77 | BYTE m_Hash; | ||
78 | public: | ||
79 | UCHAR GetOnly(); | ||
80 | void Sub(UCHAR c); | ||
81 | BOOL IsIn(UCHAR c); | ||
82 | void Add(UCHAR c); | ||
83 | }; | ||
84 | typedef CArray<CSet,CSet&> CSets; | ||
85 | CSets m_Sets; | ||
86 | enum{ | ||
87 | // Compile flags | ||
88 | regBasic = 0, regExtended = 1, | ||
89 | regIgnoreCase = 2, | ||
90 | regNoSubExpressions = 4,// Also works for matching. | ||
91 | regNewLine = 16, | ||
92 | regLiteral = 32, | ||
93 | // Match Flags | ||
94 | regNotBOL = 1, | ||
95 | regNotEOL = 2, | ||
96 | regOneMatch=64, | ||
97 | regBackRefs=128, | ||
98 | // iFlags | ||
99 | iflagsUseBOL=1, iflagsUseEOL=2, iflagsBad=4 | ||
100 | }; | ||
101 | CString Replace(LPCTSTR src,LPCTSTR rep,int flags=0); | ||
102 | BOOL Match(LPCTSTR src,int flags=0); | ||
103 | BOOL Compile(LPCTSTR regex,int flags=0); | ||
104 | private: | ||
105 | #ifdef_DEBUG | ||
106 | void DumpStrip(CDumpContext& dc); | ||
107 | #endif | ||
108 | LPCTSTR MatchBackRef(LPCTSTR begin,LPCTSTR end,int from,int to,int level); | ||
109 | typedef CArray<LPCTSTR,LPCTSTR> CStrPtrArray; | ||
110 | CStrPtrArray m_mLastPos; | ||
111 | LPCTSTR MatchDissect(LPCTSTR begin,LPCTSTR end,int from,int to); | ||
112 | LPCTSTR MatchSlow(LPCTSTR begin,LPCTSTR end,int from,int to); | ||
113 | LPCTSTR m_cOldP; | ||
114 | BOOL MatchStatesEqual(BYTE m1,BYTE m2); | ||
115 | LPCTSTR m_mBegin; | ||
116 | void MatchStatesCopy(BYTE dst,BYTE src); | ||
117 | void MatchStep(int from,int to,BYTE maskBefore,int charCode,BYTE maskAfter); | ||
118 | void MatchStatesClear(BYTE mask); | ||
119 | LPCTSTR MatchFast(LPCTSTR begin); | ||
120 | LPCTSTR m_mEnd; | ||
121 | LPCTSTR m_mPointer; | ||
122 | BOOL ParseBREexp(BOOL ordinaryStar); | ||
123 | void ParseBRE(int stopa=0,int stopb=0); | ||
124 | void ParseLiteral(); | ||
125 | int CountPluses(); | ||
126 | void FigureMust(); | ||
127 | BOOL IsInSameSets(UCHAR c1,UCHAR c2); | ||
128 | BOOL IsInSets(UCHAR c); | ||
129 | void Categorize(); | ||
130 | int StripDuplicate(int from,int to); | ||
131 | void EmitRepeat(int pos,int from,int to); | ||
132 | UCHAR ParseBracketSymbol(); | ||
133 | UCHAR ParseBracketCollatingElement(UCHAR term); | ||
134 | void ParseBracketEClass(CSet& cset); | ||
135 | void ParseBracketCClass(CSet& cset); | ||
136 | void ParseBracketTerm(CSet& cset); | ||
137 | int StoreSet(CSet& cset); | ||
138 | void ParseBracket(); | ||
139 | int ParseCount(); | ||
140 | void EmitNonNewLineAny(); | ||
141 | void EmitOrdinary(UCHAR c); | ||
142 | void StripInsert(int pos,CSop& sop); | ||
143 | void ParseEREexp(); | ||
144 | void ParseERE(int stop=0); | ||
145 | struct CParenthesis{ | ||
146 | long m_Begin; | ||
147 | long m_End; | ||
148 | CParenthesis(long b=0,long e=0) : m_Begin(b), m_End(e) {} | ||
149 | }; | ||
150 | typedef CArray<CParenthesis,CParenthesis&> CParens; | ||
151 | CParens m_ParseParens; | ||
152 | int m_ParsePointer; | ||
153 | }; | ||
154 | #ifdef_DEBUG | ||
155 | inline CDumpContext& operator<<(CDumpContext& dc, CRegEx::CSop& sop) { sop.Dump(dc); return dc; } | ||
156 | #endif | ||
157 | |||
158 | #endif // __REGEX_H \ No newline at end of file | ||
diff --git a/shared-code/SNMPExtDll.h b/shared-code/SNMPExtDll.h new file mode 100644 index 0000000..14c920d --- a/dev/null +++ b/shared-code/SNMPExtDll.h | |||
@@ -0,0 +1,252 @@ | |||
1 | #ifndef__SNMPEXTDLL_H | ||
2 | #define __SNMPEXTDLL_H | ||
3 | |||
4 | #include "snmpeer.h" | ||
5 | |||
6 | #include <snmp.h> | ||
7 | |||
8 | namespace Klever { | ||
9 | |||
10 | class CSNMPExtDLL : public CSNMPeer{ | ||
11 | public: | ||
12 | HINSTANCE m_hInstance; | ||
13 | HANDLE m_hEvent; | ||
14 | AsnObjectIdentifier m_OID; | ||
15 | BOOL (SNMP_FUNC_TYPE *m_extInit)(DWORD dw,HANDLE h,AsnObjectIdentifier* aoid); | ||
16 | BOOL (SNMP_FUNC_TYPE *m_extQuery)(BYTE b,RFC1157VarBindList* rvbl,AsnInteger* ai1,AsnInteger* ai2); | ||
17 | BOOL (SNMP_FUNC_TYPE *m_extTrap)(AsnObjectIdentifier*,AsnNetworkAddress*,AsnInteger*,AsnInteger*,AsnTimeticks*,RFC1157VarBindList*); | ||
18 | |||
19 | HINSTANCE m_hSNMPAPI; | ||
20 | void (SNMP_FUNC_TYPE *m_snmpOIDFree)(AsnObjectIdentifier*); | ||
21 | LPVOID (SNMP_FUNC_TYPE *m_snmpAlloc)(UINT); | ||
22 | void (SNMP_FUNC_TYPE *m_snmpFree)(LPVOID); | ||
23 | void (SNMP_FUNC_TYPE *m_snmpVBLFree)(RFC1157VarBindList* vbl); | ||
24 | void InitSNMP() { | ||
25 | m_hSNMPAPI = ::LoadLibraryEx("SNMPAPI",NULL,0); | ||
26 | if(!m_hSNMPAPI) | ||
27 | return; | ||
28 | *(FARPROC*)&m_snmpOIDFree = ::GetProcAddress(m_hSNMPAPI,"SnmpUtilOidFree"); | ||
29 | *(FARPROC*)&m_snmpAlloc = ::GetProcAddress(m_hSNMPAPI,"SnmpUtilMemAlloc"); | ||
30 | *(FARPROC*)&m_snmpFree = ::GetProcAddress(m_hSNMPAPI,"SnmpUtilMemFree"); | ||
31 | *(FARPROC*)&m_snmpVBLFree = ::GetProcAddress(m_hSNMPAPI,"SnmpUtilVarBindListFree"); | ||
32 | if( | ||
33 | (m_snmpFree && !m_snmpAlloc) || | ||
34 | (m_snmpAlloc && !m_snmpFree) | ||
35 | ) | ||
36 | DeinitSNMP(); | ||
37 | } | ||
38 | void DeinitSNMP() { | ||
39 | if(!m_hSNMPAPI) | ||
40 | return; | ||
41 | ::FreeLibrary(m_hSNMPAPI); | ||
42 | m_hSNMPAPI=NULL; | ||
43 | } | ||
44 | void SNMPFreeOID(AsnObjectIdentifier* oid) { | ||
45 | if(m_hSNMPAPI && m_snmpOIDFree) | ||
46 | (*m_snmpOIDFree)(oid); | ||
47 | else | ||
48 | ::GlobalFree((HGLOBAL)oid->ids); | ||
49 | } | ||
50 | LPVOID SNMPAlloc(UINT size) { | ||
51 | if(m_hSNMPAPI && m_snmpAlloc) | ||
52 | return (*m_snmpAlloc)(size); | ||
53 | else | ||
54 | return ::GlobalAlloc(GMEM_FIXED,size); | ||
55 | } | ||
56 | void SNMPFree(LPVOID addr) { | ||
57 | if(m_hSNMPAPI && m_snmpFree) | ||
58 | (*m_snmpFree)(addr); | ||
59 | else | ||
60 | :: GlobalFree((HGLOBAL)addr); | ||
61 | } | ||
62 | void SNMPFreeVBL(RFC1157VarBindList& vbl) { | ||
63 | if(m_hSNMPAPI && m_snmpVBLFree) | ||
64 | (*m_snmpVBLFree)(&vbl); | ||
65 | else{ | ||
66 | for(UINT tmp=0;tmp<vbl.len;tmp++) { | ||
67 | SNMPFree(vbl.list[tmp].name.ids); | ||
68 | switch(vbl.list[tmp].value.asnType){ | ||
69 | case ASN_OCTETSTRING: | ||
70 | case ASN_SEQUENCE: | ||
71 | case ASN_RFC1155_IPADDRESS: | ||
72 | case ASN_RFC1155_OPAQUE: | ||
73 | // case ASN_RFC1213_DISPSTRING: | ||
74 | if(vbl.list[tmp].value.asnValue.arbitrary.dynamic) | ||
75 | SNMPFree(vbl.list[tmp].value.asnValue.arbitrary.stream); | ||
76 | break; | ||
77 | case ASN_OBJECTIDENTIFIER: | ||
78 | SNMPFree(vbl.list[tmp].value.asnValue.object.ids); | ||
79 | break; | ||
80 | default: | ||
81 | break; | ||
82 | } | ||
83 | } | ||
84 | SNMPFree(vbl.list); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | BOOL SNMPBuildVBL(RFC1157VarBindList& vbl,CSNMPVarBindList& in) { | ||
89 | vbl.len = in.GetCount(); | ||
90 | vbl.list = (RFC1157VarBind*)SNMPAlloc(sizeof(RFC1157VarBind)*vbl.len); | ||
91 | POSITION p = in.GetHeadPosition(); | ||
92 | UINT ptr = 0; | ||
93 | while(p){ | ||
94 | CSNMPVarBind& vb = in.GetNext(p); | ||
95 | ASSERT(ptr<vbl.len); | ||
96 | SNMPBuildVB(vbl.list[ptr++],vb); | ||
97 | } | ||
98 | return TRUE; | ||
99 | } | ||
100 | BOOL SNMPBuildVB(RFC1157VarBind& vb,CSNMPVarBind& in) { | ||
101 | ASSERT(in.name.type==CASNAny::typeASNOID); | ||
102 | return SNMPBuildOID(vb.name,in.name.value.oid) && SNMPBuildAA(vb.value,in.value); | ||
103 | } | ||
104 | BOOL SNMPBuildAA(AsnAny& aa,CASNAny& in) { | ||
105 | aa.asnType=in.type; | ||
106 | switch(in.type) { | ||
107 | case CASNAny::typeASNInteger: | ||
108 | aa.asnValue.number=in.value.number; break; | ||
109 | case CASNAny::typeASNOctetString: | ||
110 | // case CASNAny::typeASNDispString: | ||
111 | SNMPBuildOS(aa.asnValue.string,in.value.string); break; | ||
112 | case CASNAny::typeASNNull: | ||
113 | break; | ||
114 | case CASNAny::typeASNOID: | ||
115 | SNMPBuildOID(aa.asnValue.object,in.value.oid); break; | ||
116 | case CASNAny::typeASNSequence: | ||
117 | // case CASNAny::typeASNSequenceOf: | ||
118 | SNMPBuildOS(aa.asnValue.sequence,in.value.sequence); break; | ||
119 | case CASNAny::typeASNIP: | ||
120 | SNMPBuildFLOS(aa.asnValue.address,(LPBYTE)&in.value.ip,sizeof(in.value.ip)); break; | ||
121 | case CASNAny::typeASNCounter: | ||
122 | aa.asnValue.counter = in.value.counter; break; | ||
123 | case CASNAny::typeASNGauge: | ||
124 | aa.asnValue.gauge = in.value.gauge; break; | ||
125 | case CASNAny::typeASNTicks: | ||
126 | aa.asnValue.ticks = in.value.ticks; break; | ||
127 | case CASNAny::typeASNOpaque: | ||
128 | ASSERT(in.storeType==CASNAny::storeDynamic); | ||
129 | SNMPBuildOS(aa.asnValue.arbitrary,in.value.data); break; | ||
130 | break; | ||
131 | default: | ||
132 | ASSERT(FALSE); | ||
133 | return FALSE; | ||
134 | } | ||
135 | return TRUE; | ||
136 | } | ||
137 | BOOL SNMPBuildOS(AsnOctetString& os,CASNAny::asnOctetString& in) { | ||
138 | return SNMPBuildFLOS(os,in.data,in.size); | ||
139 | } | ||
140 | BOOL SNMPBuildOID(AsnObjectIdentifier& oid,CASNAny::asnOID& in) { | ||
141 | oid.idLength = in.size/sizeof(UINT); | ||
142 | ASSERT(!(in.size%sizeof(UINT))); | ||
143 | VERIFY(oid.ids = (UINT*)SNMPAlloc(in.size)); | ||
144 | memmove(oid.ids,in.data,in.size); | ||
145 | return TRUE; | ||
146 | } | ||
147 | BOOL SNMPBuildFLOS(AsnOctetString& os,LPBYTE data,UINT size) { | ||
148 | os.length = size; | ||
149 | VERIFY(os.stream = (BYTE*)SNMPAlloc(os.length)); | ||
150 | os.dynamic=TRUE; | ||
151 | memmove(os.stream,data,size); | ||
152 | return TRUE; | ||
153 | } | ||
154 | BOOL SNMPParseVBL(RFC1157VarBindList& vbl,CSNMPVarBindList& ou) { | ||
155 | for(UINT tmp=0;tmp<vbl.len;tmp++){ | ||
156 | CSNMPVarBind vb; | ||
157 | SNMPParseVB(vbl.list[tmp],vb); | ||
158 | ou.AddTail(vb); | ||
159 | } | ||
160 | return TRUE; | ||
161 | } | ||
162 | BOOL SNMPParseVB(RFC1157VarBind& vb,CSNMPVarBind& ou) { | ||
163 | ou.name.Set(CASNAny::typeASNOID,(LPBYTE)vb.name.ids,vb.name.idLength*sizeof(UINT)); | ||
164 | return SNMPParseAA(vb.value,ou.value); | ||
165 | } | ||
166 | BOOL SNMPParseAA(AsnAny& aa,CASNAny& ou) { | ||
167 | switch(aa.asnType){ | ||
168 | case ASN_INTEGER: | ||
169 | ou.Set(CASNAny::typeASNInteger,aa.asnValue.number); break; | ||
170 | case ASN_OCTETSTRING: | ||
171 | // case ASN_RFC1213_DISPSTRING: | ||
172 | ou.Set(CASNAny::typeASNOctetString,aa.asnValue.string.stream,aa.asnValue.string.length); break; | ||
173 | case ASN_OBJECTIDENTIFIER: | ||
174 | ou.Set(CASNAny::typeASNOID,(LPBYTE)aa.asnValue.object.ids,aa.asnValue.object.idLength); | ||
175 | SNMPParseOID(aa.asnValue.object,ou.value.oid); break; | ||
176 | case ASN_SEQUENCE: | ||
177 | ou.Set(CASNAny::typeASNSequence,aa.asnValue.sequence.stream,aa.asnValue.sequence.length); break; | ||
178 | case ASN_RFC1155_IPADDRESS: | ||
179 | SNMPParseIP(aa.asnValue.address,ou); break; | ||
180 | case ASN_RFC1155_COUNTER: | ||
181 | ou.Set(CASNAny::typeASNCounter,(LONG)aa.asnValue.counter); break; | ||
182 | case ASN_RFC1155_GAUGE: | ||
183 | ou.Set(CASNAny::typeASNGauge,(LONG)aa.asnValue.gauge); break; | ||
184 | case ASN_RFC1155_TIMETICKS: | ||
185 | ou.Set(CASNAny::typeASNTicks,(LONG)aa.asnValue.ticks); break; | ||
186 | case ASN_RFC1155_OPAQUE: | ||
187 | ou.Set(CASNAny::typeASNOpaque,aa.asnValue.arbitrary.stream,aa.asnValue.arbitrary.length); break; | ||
188 | case ASN_NULL: | ||
189 | ou.Free(); break; | ||
190 | default: | ||
191 | ASSERT(FALSE); | ||
192 | return FALSE; | ||
193 | } | ||
194 | return TRUE; | ||
195 | } | ||
196 | BOOL SNMPParseOID(AsnObjectIdentifier& oid,CASNAny::asnOID& ou) { | ||
197 | ASSERT(ou.size==(oid.idLength*sizeof(UINT))); | ||
198 | memmove(ou.data,oid.ids,ou.size); | ||
199 | return TRUE; | ||
200 | } | ||
201 | BOOL SNMPParseIP(AsnIPAddress& ip,CASNAny& ou) { | ||
202 | in_addr i; | ||
203 | if(ip.length>sizeof(i)) | ||
204 | return FALSE; | ||
205 | i.s_addr=0; | ||
206 | memmove(&i,ip.stream,ip.length); | ||
207 | ou.Set(i); | ||
208 | return TRUE; | ||
209 | } | ||
210 | |||
211 | |||
212 | CSNMPExtDLL(LPCTSTR dllName) : m_hInstance(NULL) { InitSNMP(); Init(dllName); } | ||
213 | ~CSNMPExtDLL() { Deinit(); DeinitSNMP(); } | ||
214 | |||
215 | BOOL Init(LPCTSTR dllName) { | ||
216 | Deinit(); | ||
217 | m_hInstance = ::LoadLibraryEx(dllName,NULL,0); | ||
218 | if(!m_hInstance) | ||
219 | return FALSE; | ||
220 | *(FARPROC*)&m_extInit = ::GetProcAddress(m_hInstance,"SnmpExtensionInit"); | ||
221 | *(FARPROC*)&m_extQuery = ::GetProcAddress(m_hInstance,"SnmpExtensionQuery"); | ||
222 | *(FARPROC*)&m_extTrap = ::GetProcAddress(m_hInstance,"SnmpExtensionTrap"); | ||
223 | if(!(m_extInit && m_extQuery && m_extTrap)){ | ||
224 | Deinit(); | ||
225 | return FALSE; | ||
226 | } | ||
227 | if(!((*m_extInit)(GetCurrentTime(),&m_hEvent,&m_OID))){ | ||
228 | Deinit(); | ||
229 | return FALSE; | ||
230 | } | ||
231 | return TRUE; | ||
232 | } | ||
233 | void Deinit() { | ||
234 | if(!m_hInstance) | ||
235 | return; | ||
236 | ::FreeLibrary(m_hInstance); | ||
237 | } | ||
238 | virtual BOOL Request(BYTE type,CSNMPVarBindList& in,CSNMPVarBindList& ou) { | ||
239 | RFC1157VarBindList vbl; | ||
240 | SNMPBuildVBL(vbl,in); | ||
241 | AsnInteger errorStatus, errorIndex; | ||
242 | (*m_extQuery)(type,&vbl,&errorStatus,&errorIndex); | ||
243 | ou.RemoveAll(); | ||
244 | SNMPParseVBL(vbl,ou); | ||
245 | SNMPFreeVBL(vbl); | ||
246 | return TRUE; | ||
247 | } | ||
248 | }; | ||
249 | |||
250 | }; | ||
251 | |||
252 | #endif// __SNMPEXTDLL_H | ||
diff --git a/shared-code/SNMPOIDs.h b/shared-code/SNMPOIDs.h new file mode 100644 index 0000000..68ee659 --- a/dev/null +++ b/shared-code/SNMPOIDs.h | |||
@@ -0,0 +1,221 @@ | |||
1 | #ifndef__SNMPOIDS_H | ||
2 | #define__SNMPOIDS_H | ||
3 | |||
4 | #define DEFINE_OID(name,oid)static UINT name[] = oid | ||
5 | |||
6 | // MIB-II OIDs | ||
7 | |||
8 | #define OIDccitt {0} | ||
9 | #define OIDnull {0,0} | ||
10 | #define OIDiso {1} | ||
11 | #define OIDorg {1,3} | ||
12 | #define OIDdod {1,3,6} | ||
13 | #define OIDinternet {1,3,6,1} | ||
14 | #define OIDdirectory {1,3,6,1,1} | ||
15 | #define OIDmgmt {1,3,6,1,2} | ||
16 | #define OIDmib_2 {1,3,6,1,2,1} | ||
17 | #define OIDsystem {1,3,6,1,2,1,1} | ||
18 | #define OIDsysDescr {1,3,6,1,2,1,1,1} | ||
19 | #define OIDsysObjectID {1,3,6,1,2,1,1,2} | ||
20 | #define OIDsysUpTime {1,3,6,1,2,1,1,3} | ||
21 | #define OIDsysContact {1,3,6,1,2,1,1,4} | ||
22 | #define OIDsysName {1,3,6,1,2,1,1,5} | ||
23 | #define OIDsysLocation {1,3,6,1,2,1,1,6} | ||
24 | #define OIDsysServices {1,3,6,1,2,1,1,7} | ||
25 | #define OIDtransmission {1,3,6,1,2,1,10} | ||
26 | #define OIDsnmp {1,3,6,1,2,1,11} | ||
27 | #define OIDsnmpInPkts {1,3,6,1,2,1,11,1} | ||
28 | #define OIDsnmpInBadValues {1,3,6,1,2,1,11,10} | ||
29 | #define OIDsnmpInReadOnlys {1,3,6,1,2,1,11,11} | ||
30 | #define OIDsnmpInGenErrs {1,3,6,1,2,1,11,12} | ||
31 | #define OIDsnmpInTotalReqVars {1,3,6,1,2,1,11,13} | ||
32 | #define OIDsnmpInTotalSetVars {1,3,6,1,2,1,11,14} | ||
33 | #define OIDsnmpInGetRequests {1,3,6,1,2,1,11,15} | ||
34 | #define OIDsnmpInGetNexts {1,3,6,1,2,1,11,16} | ||
35 | #define OIDsnmpInSetRequests {1,3,6,1,2,1,11,17} | ||
36 | #define OIDsnmpInGetResponses {1,3,6,1,2,1,11,18} | ||
37 | #define OIDsnmpInTraps {1,3,6,1,2,1,11,19} | ||
38 | #define OIDsnmpOutPkts {1,3,6,1,2,1,11,2} | ||
39 | #define OIDsnmpOutTooBigs {1,3,6,1,2,1,11,20} | ||
40 | #define OIDsnmpOutNoSuchNames {1,3,6,1,2,1,11,21} | ||
41 | #define OIDsnmpOutBadValues {1,3,6,1,2,1,11,22} | ||
42 | #define OIDsnmpOutGenErrs {1,3,6,1,2,1,11,24} | ||
43 | #define OIDsnmpOutGetRequests {1,3,6,1,2,1,11,25} | ||
44 | #define OIDsnmpOutGetNexts {1,3,6,1,2,1,11,26} | ||
45 | #define OIDsnmpOutSetRequests {1,3,6,1,2,1,11,27} | ||
46 | #define OIDsnmpOutGetResponses {1,3,6,1,2,1,11,28} | ||
47 | #define OIDsnmpOutTraps {1,3,6,1,2,1,11,29} | ||
48 | #define OIDsnmpInBadVersions {1,3,6,1,2,1,11,3} | ||
49 | #define OIDsnmpEnableAuthenTraps {1,3,6,1,2,1,11,30} | ||
50 | #define OIDsnmpInBadCommunityNames {1,3,6,1,2,1,11,4} | ||
51 | #define OIDsnmpInBadCommunityUses {1,3,6,1,2,1,11,5} | ||
52 | #define OIDsnmpInASNParseErrs {1,3,6,1,2,1,11,6} | ||
53 | #define OIDsnmpInTooBigs {1,3,6,1,2,1,11,8} | ||
54 | #define OIDsnmpInNoSuchNames {1,3,6,1,2,1,11,9} | ||
55 | #define OIDinterfaces {1,3,6,1,2,1,2} | ||
56 | #define OIDifNumber {1,3,6,1,2,1,2,1} | ||
57 | #define OIDifTable {1,3,6,1,2,1,2,2} | ||
58 | #define OIDifEntry {1,3,6,1,2,1,2,2,1} | ||
59 | #define OIDifIndex {1,3,6,1,2,1,2,2,1,1} | ||
60 | #define OIDifInOctets {1,3,6,1,2,1,2,2,1,10} | ||
61 | #define OIDifInUcastPkts {1,3,6,1,2,1,2,2,1,11} | ||
62 | #define OIDifInNUcastPkts {1,3,6,1,2,1,2,2,1,12} | ||
63 | #define OIDifInDiscards {1,3,6,1,2,1,2,2,1,13} | ||
64 | #define OIDifInErrors {1,3,6,1,2,1,2,2,1,14} | ||
65 | #define OIDifInUnknownProtos {1,3,6,1,2,1,2,2,1,15} | ||
66 | #define OIDifOutOctets {1,3,6,1,2,1,2,2,1,16} | ||
67 | #define OIDifOutUcastPkts {1,3,6,1,2,1,2,2,1,17} | ||
68 | #define OIDifOutNUcastPkts {1,3,6,1,2,1,2,2,1,18} | ||
69 | #define OIDifOutDiscards {1,3,6,1,2,1,2,2,1,19} | ||
70 | #define OIDifDescr {1,3,6,1,2,1,2,2,1,2} | ||
71 | #define OIDifOutErrors {1,3,6,1,2,1,2,2,1,20} | ||
72 | #define OIDifOutQLen {1,3,6,1,2,1,2,2,1,21} | ||
73 | #define OIDifSpecific {1,3,6,1,2,1,2,2,1,22} | ||
74 | #define OIDifType {1,3,6,1,2,1,2,2,1,3} | ||
75 | #define OIDifMtu {1,3,6,1,2,1,2,2,1,4} | ||
76 | #define OIDifSpeed {1,3,6,1,2,1,2,2,1,5} | ||
77 | #define OIDifPhysAddress {1,3,6,1,2,1,2,2,1,6} | ||
78 | #define OIDifAdminStatus {1,3,6,1,2,1,2,2,1,7} | ||
79 | #define OIDifOperStatus {1,3,6,1,2,1,2,2,1,8} | ||
80 | #define OIDifLastChange {1,3,6,1,2,1,2,2,1,9} | ||
81 | #define OIDat {1,3,6,1,2,1,3} | ||
82 | #define OIDatTable {1,3,6,1,2,1,3,1} | ||
83 | #define OIDatEntry {1,3,6,1,2,1,3,1,1} | ||
84 | #define OIDatIfIndex {1,3,6,1,2,1,3,1,1,1} | ||
85 | #define OIDatPhysAddress {1,3,6,1,2,1,3,1,1,2} | ||
86 | #define OIDatNetAddress {1,3,6,1,2,1,3,1,1,3} | ||
87 | #define OIDip {1,3,6,1,2,1,4} | ||
88 | #define OIDipForwarding {1,3,6,1,2,1,4,1} | ||
89 | #define OIDipOutRequests {1,3,6,1,2,1,4,10} | ||
90 | #define OIDipOutDiscards {1,3,6,1,2,1,4,11} | ||
91 | #define OIDipOutNoRoutes {1,3,6,1,2,1,4,12} | ||
92 | #define OIDipReasmTimeout {1,3,6,1,2,1,4,13} | ||
93 | #define OIDipReasmReqds {1,3,6,1,2,1,4,14} | ||
94 | #define OIDipReasmOKs {1,3,6,1,2,1,4,15} | ||
95 | #define OIDipReasmFails {1,3,6,1,2,1,4,16} | ||
96 | #define OIDipFragOKs {1,3,6,1,2,1,4,17} | ||
97 | #define OIDipFragFails {1,3,6,1,2,1,4,18} | ||
98 | #define OIDipFragCreates {1,3,6,1,2,1,4,19} | ||
99 | #define OIDipDefaultTTL {1,3,6,1,2,1,4,2} | ||
100 | #define OIDipAddrTable {1,3,6,1,2,1,4,20} | ||
101 | #define OIDipAddrEntry {1,3,6,1,2,1,4,20,1} | ||
102 | #define OIDipAdEntAddr {1,3,6,1,2,1,4,20,1,1} | ||
103 | #define OIDipAdEntIfIndex {1,3,6,1,2,1,4,20,1,2} | ||
104 | #define OIDipAdEntNetMask {1,3,6,1,2,1,4,20,1,3} | ||
105 | #define OIDipAdEntBcastAddr {1,3,6,1,2,1,4,20,1,4} | ||
106 | #define OIDipAdEntReasmMaxSize {1,3,6,1,2,1,4,20,1,5} | ||
107 | #define OIDipRouteTable {1,3,6,1,2,1,4,21} | ||
108 | #define OIDipRouteEntry {1,3,6,1,2,1,4,21,1} | ||
109 | #define OIDipRouteDest {1,3,6,1,2,1,4,21,1,1} | ||
110 | #define OIDipRouteAge {1,3,6,1,2,1,4,21,1,10} | ||
111 | #define OIDipRouteMask {1,3,6,1,2,1,4,21,1,11} | ||
112 | #define OIDipRouteMetric5 {1,3,6,1,2,1,4,21,1,12} | ||
113 | #define OIDipRouteInfo {1,3,6,1,2,1,4,21,1,13} | ||
114 | #define OIDipRouteIfIndex {1,3,6,1,2,1,4,21,1,2} | ||
115 | #define OIDipRouteMetric1 {1,3,6,1,2,1,4,21,1,3} | ||
116 | #define OIDipRouteMetric2 {1,3,6,1,2,1,4,21,1,4} | ||
117 | #define OIDipRouteMetric3 {1,3,6,1,2,1,4,21,1,5} | ||
118 | #define OIDipRouteMetric4 {1,3,6,1,2,1,4,21,1,6} | ||
119 | #define OIDipRouteNextHop {1,3,6,1,2,1,4,21,1,7} | ||
120 | #define OIDipRouteType {1,3,6,1,2,1,4,21,1,8} | ||
121 | #define OIDipRouteProto {1,3,6,1,2,1,4,21,1,9} | ||
122 | #define OIDipNetToMediaTable {1,3,6,1,2,1,4,22} | ||
123 | #define OIDipNetToMediaEntry {1,3,6,1,2,1,4,22,1} | ||
124 | #define OIDipNetToMediaIfIndex {1,3,6,1,2,1,4,22,1,1} | ||
125 | #define OIDipNetToMediaPhysAddress {1,3,6,1,2,1,4,22,1,2} | ||
126 | #define OIDipNetToMediaNetAddress {1,3,6,1,2,1,4,22,1,3} | ||
127 | #define OIDipNetToMediaType {1,3,6,1,2,1,4,22,1,4} | ||
128 | #define OIDipRoutingDiscards {1,3,6,1,2,1,4,23} | ||
129 | #define OIDipInReceives {1,3,6,1,2,1,4,3} | ||
130 | #define OIDipInHdrErrors {1,3,6,1,2,1,4,4} | ||
131 | #define OIDipInAddrErrors {1,3,6,1,2,1,4,5} | ||
132 | #define OIDipForwDatagrams {1,3,6,1,2,1,4,6} | ||
133 | #define OIDipInUnknownProtos {1,3,6,1,2,1,4,7} | ||
134 | #define OIDipInDiscards {1,3,6,1,2,1,4,8} | ||
135 | #define OIDipInDelivers {1,3,6,1,2,1,4,9} | ||
136 | #define OIDicmp {1,3,6,1,2,1,5} | ||
137 | #define OIDicmpInMsgs {1,3,6,1,2,1,5,1} | ||
138 | #define OIDicmpInTimestamps {1,3,6,1,2,1,5,10} | ||
139 | #define OIDicmpInTimestampReps {1,3,6,1,2,1,5,11} | ||
140 | #define OIDicmpInAddrMasks {1,3,6,1,2,1,5,12} | ||
141 | #define OIDicmpInAddrMaskReps {1,3,6,1,2,1,5,13} | ||
142 | #define OIDicmpOutMsgs {1,3,6,1,2,1,5,14} | ||
143 | #define OIDicmpOutErrors {1,3,6,1,2,1,5,15} | ||
144 | #define OIDicmpOutDestUnreachs {1,3,6,1,2,1,5,16} | ||
145 | #define OIDicmpOutTimeExcds {1,3,6,1,2,1,5,17} | ||
146 | #define OIDicmpOutParmProbs {1,3,6,1,2,1,5,18} | ||
147 | #define OIDicmpOutSrcQuenchs {1,3,6,1,2,1,5,19} | ||
148 | #define OIDicmpInErrors {1,3,6,1,2,1,5,2} | ||
149 | #define OIDicmpOutRedirects {1,3,6,1,2,1,5,20} | ||
150 | #define OIDicmpOutEchos {1,3,6,1,2,1,5,21} | ||
151 | #define OIDicmpOutEchoReps {1,3,6,1,2,1,5,22} | ||
152 | #define OIDicmpOutTimestamps {1,3,6,1,2,1,5,23} | ||
153 | #define OIDicmpOutTimestampReps {1,3,6,1,2,1,5,24} | ||
154 | #define OIDicmpOutAddrMasks {1,3,6,1,2,1,5,25} | ||
155 | #define OIDicmpOutAddrMaskReps {1,3,6,1,2,1,5,26} | ||
156 | #define OIDicmpInDestUnreachs {1,3,6,1,2,1,5,3} | ||
157 | #define OIDicmpInTimeExcds {1,3,6,1,2,1,5,4} | ||
158 | #define OIDicmpInParmProbs {1,3,6,1,2,1,5,5} | ||
159 | #define OIDicmpInSrcQuenchs {1,3,6,1,2,1,5,6} | ||
160 | #define OIDicmpInRedirects {1,3,6,1,2,1,5,7} | ||
161 | #define OIDicmpInEchos {1,3,6,1,2,1,5,8} | ||
162 | #define OIDicmpInEchoReps {1,3,6,1,2,1,5,9} | ||
163 | #define OIDtcp {1,3,6,1,2,1,6} | ||
164 | #define OIDtcpRtoAlgorithm {1,3,6,1,2,1,6,1} | ||
165 | #define OIDtcpInSegs {1,3,6,1,2,1,6,10} | ||
166 | #define OIDtcpOutSegs {1,3,6,1,2,1,6,11} | ||
167 | #define OIDtcpRetransSegs {1,3,6,1,2,1,6,12} | ||
168 | #define OIDtcpConnTable {1,3,6,1,2,1,6,13} | ||
169 | #define OIDtcpConnEntry {1,3,6,1,2,1,6,13,1} | ||
170 | #define OIDtcpConnState {1,3,6,1,2,1,6,13,1,1} | ||
171 | #define OIDtcpConnLocalAddress {1,3,6,1,2,1,6,13,1,2} | ||
172 | #define OIDtcpConnLocalPort {1,3,6,1,2,1,6,13,1,3} | ||
173 | #define OIDtcpConnRemAddress {1,3,6,1,2,1,6,13,1,4} | ||
174 | #define OIDtcpConnRemPort {1,3,6,1,2,1,6,13,1,5} | ||
175 | #define OIDtcpInErrs {1,3,6,1,2,1,6,14} | ||
176 | #define OIDtcpOutRsts {1,3,6,1,2,1,6,15} | ||
177 | #define OIDtcpRtoMin {1,3,6,1,2,1,6,2} | ||
178 | #define OIDtcpRtoMax {1,3,6,1,2,1,6,3} | ||
179 | #define OIDtcpMaxConn {1,3,6,1,2,1,6,4} | ||
180 | #define OIDtcpActiveOpens {1,3,6,1,2,1,6,5} | ||
181 | #define OIDtcpPassiveOpens {1,3,6,1,2,1,6,6} | ||
182 | #define OIDtcpAttemptFails {1,3,6,1,2,1,6,7} | ||
183 | #define OIDtcpEstabResets {1,3,6,1,2,1,6,8} | ||
184 | #define OIDtcpCurrEstab {1,3,6,1,2,1,6,9} | ||
185 | #define OIDudp {1,3,6,1,2,1,7} | ||
186 | #define OIDudpInDatagrams {1,3,6,1,2,1,7,1} | ||
187 | #define OIDudpNoPorts {1,3,6,1,2,1,7,2} | ||
188 | #define OIDudpInErrors {1,3,6,1,2,1,7,3} | ||
189 | #define OIDudpOutDatagrams {1,3,6,1,2,1,7,4} | ||
190 | #define OIDudpTable {1,3,6,1,2,1,7,5} | ||
191 | #define OIDudpEntry {1,3,6,1,2,1,7,5,1} | ||
192 | #define OIDudpLocalAddress {1,3,6,1,2,1,7,5,1,1} | ||
193 | #define OIDudpLocalPort {1,3,6,1,2,1,7,5,1,2} | ||
194 | #define OIDegp {1,3,6,1,2,1,8} | ||
195 | #define OIDegpInMsgs {1,3,6,1,2,1,8,1} | ||
196 | #define OIDegpInErrors {1,3,6,1,2,1,8,2} | ||
197 | #define OIDegpOutMsgs {1,3,6,1,2,1,8,3} | ||
198 | #define OIDegpOutErrors {1,3,6,1,2,1,8,4} | ||
199 | #define OIDegpNeighTable {1,3,6,1,2,1,8,5} | ||
200 | #define OIDegpNeighEntry {1,3,6,1,2,1,8,5,1} | ||
201 | #define OIDegpNeighState {1,3,6,1,2,1,8,5,1,1} | ||
202 | #define OIDegpNeighStateUps {1,3,6,1,2,1,8,5,1,10} | ||
203 | #define OIDegpNeighStateDowns {1,3,6,1,2,1,8,5,1,11} | ||
204 | #define OIDegpNeighIntervalHello {1,3,6,1,2,1,8,5,1,12} | ||
205 | #define OIDegpNeighIntervalPoll {1,3,6,1,2,1,8,5,1,13} | ||
206 | #define OIDegpNeighMode {1,3,6,1,2,1,8,5,1,14} | ||
207 | #define OIDegpNeighEventTrigger {1,3,6,1,2,1,8,5,1,15} | ||
208 | #define OIDegpNeighAddr {1,3,6,1,2,1,8,5,1,2} | ||
209 | #define OIDegpNeighAs {1,3,6,1,2,1,8,5,1,3} | ||
210 | #define OIDegpNeighInMsgs {1,3,6,1,2,1,8,5,1,4} | ||
211 | #define OIDegpNeighInErrs {1,3,6,1,2,1,8,5,1,5} | ||
212 | #define OIDegpNeighOutMsgs {1,3,6,1,2,1,8,5,1,6} | ||
213 | #define OIDegpNeighOutErrs {1,3,6,1,2,1,8,5,1,7} | ||
214 | #define OIDegpNeighInErrMsgs {1,3,6,1,2,1,8,5,1,8} | ||
215 | #define OIDegpNeighOutErrMsgs {1,3,6,1,2,1,8,5,1,9} | ||
216 | #define OIDegpAs {1,3,6,1,2,1,8,6} | ||
217 | #define OIDexperimental {1,3,6,1,3} | ||
218 | #define OIDprivate {1,3,6,1,4} | ||
219 | #define OIDenterprises {1,3,6,1,4,1} | ||
220 | |||
221 | #endif// __SNMPOIDS_H \ No newline at end of file | ||
diff --git a/shared-code/SNMPeer.h b/shared-code/SNMPeer.h new file mode 100644 index 0000000..68f2efe --- a/dev/null +++ b/shared-code/SNMPeer.h | |||
@@ -0,0 +1,286 @@ | |||
1 | #ifndef__SNMPEER_H | ||
2 | #define __SNMPEER_H | ||
3 | |||
4 | namespace Klever { | ||
5 | |||
6 | class CASNAny{ | ||
7 | public: | ||
8 | enum{ | ||
9 | asnCls = 0xC0, | ||
10 | asnClsUniversal = 0x00, | ||
11 | asnClsApplication = 0x40, | ||
12 | asnClsContextSpecific = 0x80, | ||
13 | asnClsPrivate = 0xC0, | ||
14 | asnConstructed = 0x20, | ||
15 | asnPrimitive = 0x00, | ||
16 | asnTag = 0x1F, | ||
17 | // ASN.1 Primitive Tags | ||
18 | asnTagInteger = 0x02, | ||
19 | asnTagOctetString = 0x04, | ||
20 | asnTagNull = 0x05, | ||
21 | asnTagOID = 0x06, | ||
22 | // ASN.1 Constructed Tags | ||
23 | asnTagSequence = 0x10, | ||
24 | // RFC1155 Primitive Tags | ||
25 | asnTagIP = 0x00, | ||
26 | asnTagCounter = 0x01, | ||
27 | asnTagGauge = 0x02, | ||
28 | asnTagTicks = 0x03, | ||
29 | asnTagOpaque = 0x04, | ||
30 | // RFC1213 alias | ||
31 | asnTagDispString = 0x04,// (ASN.1 Octet string) | ||
32 | // RFC1157 Constructed Tags | ||
33 | asnTagGetRequest = 0x00, | ||
34 | asnTagGetNextRequest = 0x01, | ||
35 | asnTagGetResponse = 0x02, | ||
36 | asnTagSetRequest = 0x03, | ||
37 | asnTagTrap = 0x04 | ||
38 | }; | ||
39 | enum{ | ||
40 | typeASNInteger = (asnClsUniversal|asnPrimitive|asnTagInteger), | ||
41 | typeASNOctetString = (asnClsUniversal|asnPrimitive|asnTagOctetString), | ||
42 | typeASNNull = (asnClsUniversal|asnPrimitive|asnTagNull), | ||
43 | typeASNOID = (asnClsUniversal|asnPrimitive|asnTagOID), | ||
44 | |||
45 | typeASNSequence = (asnClsUniversal|asnConstructed|asnTagSequence), | ||
46 | typeASNSequenceOf = (asnClsUniversal|asnConstructed|asnTagSequence), | ||
47 | |||
48 | typeASNIP = (asnClsApplication|asnPrimitive|asnTagIP), | ||
49 | typeASNCounter = (asnClsApplication|asnPrimitive|asnTagCounter), | ||
50 | typeASNGauge = (asnClsApplication|asnPrimitive|asnTagGauge), | ||
51 | typeASNTicks = (asnClsApplication|asnPrimitive|asnTagTicks), | ||
52 | typeASNOpaque = (asnClsApplication|asnPrimitive|asnTagOpaque), | ||
53 | typeASNDispString = (asnClsUniversal|asnPrimitive|asnTagOctetString), | ||
54 | |||
55 | typeASNGetRequest = (asnClsContextSpecific|asnConstructed|asnTagGetRequest), | ||
56 | typeASNGetNextRequest = (asnClsContextSpecific|asnConstructed|asnTagGetNextRequest), | ||
57 | typeASNGetResponse = (asnClsContextSpecific|asnConstructed|asnTagGetResponse), | ||
58 | typeASNSetRequest = (asnClsContextSpecific|asnConstructed|asnTagSetRequest), | ||
59 | typeASNTrap = (asnClsContextSpecific|asnConstructed|asnTagTrap) | ||
60 | }; | ||
61 | |||
62 | typedefLONG asnInteger; | ||
63 | typedef LARGE_INTEGER asnInteger64; | ||
64 | typedefDWORD asnCounter; | ||
65 | typedef ULARGE_INTEGER asnCounter64; | ||
66 | typedef DWORD asnGauge; | ||
67 | typedef ULARGE_INTEGER asnGauge64; | ||
68 | typedefDWORD asnTicks; | ||
69 | typedef ULARGE_INTEGER asnTicks64; | ||
70 | struct asnDynamic{ | ||
71 | UINT size; | ||
72 | LPBYTE data; | ||
73 | BOOL Allocate(UINT size) { | ||
74 | BOOL rv = Free(); | ||
75 | if(size) | ||
76 | rv=rv&&(data=new BYTE[size]); | ||
77 | if(rv) | ||
78 | asnDynamic::size=size; | ||
79 | return rv; | ||
80 | } | ||
81 | BOOL Set(LPBYTE data,UINT size) { | ||
82 | BOOL rv = Allocate(size); | ||
83 | if(rv && size) | ||
84 | memmove(asnDynamic::data,data,size); | ||
85 | return rv; | ||
86 | } | ||
87 | BOOL Free() { | ||
88 | if(!size) | ||
89 | return TRUE; | ||
90 | delete data; | ||
91 | size=0; | ||
92 | data=0; | ||
93 | return TRUE; | ||
94 | } | ||
95 | void Clean() { | ||
96 | size=0; | ||
97 | data=0; | ||
98 | } | ||
99 | BOOL Copy(asnDynamic& src) { | ||
100 | BOOL rv = Free(); | ||
101 | if(rv){ | ||
102 | if(src.size) | ||
103 | rv=rv&&(data = new BYTE[src.size]); | ||
104 | if(rv){ | ||
105 | if(size=src.size) | ||
106 | memmove(data,src.data,size); | ||
107 | } | ||
108 | } | ||
109 | return rv; | ||
110 | } | ||
111 | }; | ||
112 | typedefasnDynamic asnOctetString; | ||
113 | typedef asnDynamic asnOID; | ||
114 | typedef in_addr asnIP; | ||
115 | typedef asnDynamic asnSequence; | ||
116 | |||
117 | BYTE type; | ||
118 | enum _storeType{ | ||
119 | storeDynamic, | ||
120 | storeStatic | ||
121 | }storeType; | ||
122 | union{ | ||
123 | asnInteger number; | ||
124 | asnInteger64 number64; | ||
125 | asnOctetString string; | ||
126 | asnOID oid; | ||
127 | asnSequence sequence; | ||
128 | asnIP ip; | ||
129 | asnCounter counter; | ||
130 | asnCounter64 counter64; | ||
131 | asnGauge gauge; | ||
132 | asnGauge64 gauge64; | ||
133 | asnTicks ticks; | ||
134 | asnTicks64 ticks64; | ||
135 | asnDynamic data; | ||
136 | } value; | ||
137 | |||
138 | CASNAny() : type(typeASNNull), storeType(storeStatic) { value.data.Clean(); } | ||
139 | CASNAny(CASNAny& src) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Copy(src); } | ||
140 | CASNAny(BYTE type) : type(type), storeType(storeStatic) { value.data.Clean(); } | ||
141 | CASNAny(BYTE type,LONG number) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,number); } | ||
142 | CASNAny(BYTE type,LONGLONG number) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,number); } | ||
143 | CASNAny(BYTE type,LPCTSTR string) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,string); } | ||
144 | CASNAny(BYTE type,LPBYTE data,UINT length) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,data,length); } | ||
145 | CASNAny(BYTE type,UINT* data,UINT size) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,(LPBYTE)data,size); } | ||
146 | CASNAny(in_addr& ip) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(ip); } | ||
147 | ~CASNAny() { Free(); } | ||
148 | |||
149 | BOOL Set(BYTE type) { | ||
150 | BOOL rv = Free(); | ||
151 | CASNAny::type=type; | ||
152 | return rv; | ||
153 | } | ||
154 | BOOL Set(BYTE type,LONG number) { | ||
155 | BOOL rv = Free(); | ||
156 | CASNAny::type=type; | ||
157 | value.number=number; | ||
158 | storeType=storeStatic; | ||
159 | return rv; | ||
160 | } | ||
161 | BOOL Set(BYTE type,LONGLONG number) { | ||
162 | BOOL rv = Free(); | ||
163 | CASNAny::type=type; | ||
164 | value.number64.QuadPart = number; | ||
165 | storeType=storeStatic; | ||
166 | return rv; | ||
167 | } | ||
168 | BOOL Set(BYTE type,LPCTSTR string) { | ||
169 | BOOL rv = Free(); | ||
170 | CASNAny::type=type; | ||
171 | rv=rv&&value.string.Set((LPBYTE)string,strlen(string)+1); | ||
172 | if(rv){ | ||
173 | value.string.size--; | ||
174 | storeType=storeDynamic; | ||
175 | } | ||
176 | return rv; | ||
177 | } | ||
178 | BOOL Set(BYTE type,LPBYTE data,UINT length) { | ||
179 | BOOL rv = Free(); | ||
180 | CASNAny::type=type; | ||
181 | rv=rv&&value.data.Set(data,length); | ||
182 | if(rv) | ||
183 | storeType=storeDynamic; | ||
184 | return rv; | ||
185 | } | ||
186 | BOOL Set(in_addr& ip) { | ||
187 | BOOL rv = Free(); | ||
188 | memmove(&value.ip,&ip,sizeof(value.ip)); | ||
189 | type=typeASNIP; | ||
190 | storeType=storeStatic; | ||
191 | return rv; | ||
192 | } | ||
193 | BOOL Free() { | ||
194 | if(storeType==storeDynamic) | ||
195 | value.data.Free(); | ||
196 | else{ | ||
197 | memset(&value,0,sizeof(value)); | ||
198 | value.data.Clean(); | ||
199 | } | ||
200 | storeType=storeStatic; | ||
201 | type=typeASNNull; | ||
202 | return TRUE; | ||
203 | } | ||
204 | BOOL Copy(CASNAny& src) { | ||
205 | BOOL rv = Free(); | ||
206 | if(src.storeType==storeDynamic){ | ||
207 | rv=rv&&value.data.Copy(src.value.data); | ||
208 | if(rv){ | ||
209 | type=src.type; | ||
210 | storeType=src.storeType; | ||
211 | } | ||
212 | }else{ | ||
213 | memmove(this,&src,sizeof(*this)); | ||
214 | } | ||
215 | return rv; | ||
216 | } | ||
217 | CASNAny& operator=(CASNAny& src) { | ||
218 | VERIFY(Copy(src)); | ||
219 | return *this; | ||
220 | } | ||
221 | |||
222 | // High Level | ||
223 | CString GetString() { | ||
224 | ASSERT(storeType==storeDynamic); | ||
225 | CString rv; | ||
226 | LPTSTR b = rv.GetBuffer(value.data.size+1); | ||
227 | ASSERT(b); | ||
228 | b[value.data.size]=0; | ||
229 | memmove(b,value.data.data,value.data.size); | ||
230 | rv.ReleaseBuffer(); | ||
231 | return rv; | ||
232 | } | ||
233 | }; | ||
234 | |||
235 | |||
236 | class CSNMPVarBind{ | ||
237 | public: | ||
238 | CASNAny name; | ||
239 | CASNAny value; | ||
240 | |||
241 | CSNMPVarBind() {} | ||
242 | CSNMPVarBind(CASNAny& name,CASNAny& value) : name(name), value(value) {} | ||
243 | CSNMPVarBind(CASNAny& name) : name(name) {} | ||
244 | CSNMPVarBind(CSNMPVarBind& src) { Copy(src); } | ||
245 | BOOL Copy(CSNMPVarBind& src) { | ||
246 | name.Copy(src.name); | ||
247 | value.Copy(src.value); | ||
248 | return TRUE; | ||
249 | } | ||
250 | CSNMPVarBind& operator=(CSNMPVarBind& src) { | ||
251 | Copy(src); | ||
252 | return *this; | ||
253 | } | ||
254 | // High level | ||
255 | BOOL IsName(UINT* prefix,UINT prefixSize,BOOL bExact=FALSE) { | ||
256 | if(name.type!=CASNAny::typeASNOID) | ||
257 | return FALSE; | ||
258 | if(name.value.oid.size<prefixSize) | ||
259 | return FALSE; | ||
260 | if(bExact && (name.value.oid.size!=prefixSize)) | ||
261 | return FALSE; | ||
262 | return !memcmp(prefix,name.value.oid.data,prefixSize); | ||
263 | } | ||
264 | }; | ||
265 | |||
266 | class CSNMPVarBindList: public CList<CSNMPVarBind,CSNMPVarBind&> { | ||
267 | public: | ||
268 | CSNMPVarBind* GetVarBind(UINT* prefix,UINT prefixSize,BOOL bExact=FALSE) { | ||
269 | POSITION p = GetHeadPosition(); | ||
270 | while(p){ | ||
271 | CSNMPVarBind& vb = GetNext(p); | ||
272 | if(vb.IsName(prefix,prefixSize,bExact)) | ||
273 | return &vb; | ||
274 | } | ||
275 | return NULL; | ||
276 | } | ||
277 | }; | ||
278 | |||
279 | class CSNMPeer{ | ||
280 | public: | ||
281 | virtual BOOL Request(BYTE type,CSNMPVarBindList& in,CSNMPVarBindList& ou) = 0; | ||
282 | }; | ||
283 | |||
284 | }; | ||
285 | |||
286 | #endif// __SNMPEER_H | ||
diff --git a/shared-code/install.h b/shared-code/install.h new file mode 100644 index 0000000..8c55ca9 --- a/dev/null +++ b/shared-code/install.h | |||
@@ -0,0 +1,370 @@ | |||
1 | #defineWIN32_LEAN_AND_MEAN | ||
2 | #define VC_EXTRALEAN | ||
3 | #define WIN32_EXTRALEAN | ||
4 | #include <windows.h> | ||
5 | #include <shlobj.h> | ||
6 | #include <winver.h> | ||
7 | #include <crtdbg.h> | ||
8 | #include <string.h> | ||
9 | #include <stdio.h> | ||
10 | |||
11 | extern "C" WINSHELLAPI void WINAPI SHFree( LPVOID); | ||
12 | |||
13 | template<class T> class Smart{ | ||
14 | public: | ||
15 | T *pT; | ||
16 | |||
17 | Smart() : pT(NULL) {} | ||
18 | Smart(int cb) : pT(new T[cb]) {} | ||
19 | Smart(T* p) : pT(p) {} | ||
20 | ~Smart() { if(pT)delete pT; } | ||
21 | |||
22 | Smart& operator=(T* p) { if(pT)delete pT; pT=p; return *this; } | ||
23 | operator T* () { return pT; } | ||
24 | |||
25 | //T& operator[](int ndx) { return pT[ndx]; } | ||
26 | |||
27 | T* Detach() { T* rv = pT; pT=NULL; return rv; } | ||
28 | }; | ||
29 | typedefSmart<char> STRING; | ||
30 | |||
31 | #define APPEND_SLASH(str) if((str)[strlen(str)-1]!='\\')strcat(str,"\\") | ||
32 | |||
33 | HINSTANCE theInstance; | ||
34 | |||
35 | LPSTR strFETCH_REG_KEY(HKEY hRoot,LPCSTR subKey,LPCSTR val) | ||
36 | { | ||
37 | HKEY hkey; | ||
38 | if(RegOpenKeyEx(hRoot,subKey,0,KEY_QUERY_VALUE,&hkey)!=ERROR_SUCCESS) | ||
39 | return NULL; | ||
40 | DWORD kType,cb=0; | ||
41 | STRING rv; | ||
42 | if(RegQueryValueEx(hkey,val,NULL,&kType,NULL,&cb)==ERROR_SUCCESS && kType==REG_SZ){ | ||
43 | rv= new char[cb]; | ||
44 | _ASSERT(rv!=NULL); | ||
45 | if(RegQueryValueEx(hkey,val,NULL,&kType,(LPBYTE)(LPSTR)rv,&cb)!=ERROR_SUCCESS) | ||
46 | rv=NULL; | ||
47 | } | ||
48 | RegCloseKey(hkey); | ||
49 | return rv.Detach(); | ||
50 | } | ||
51 | |||
52 | BOOL strSET_REG_KEY(HKEY hRoot,LPCSTR subKey,LPCSTR valName,LPCSTR val) | ||
53 | { | ||
54 | HKEY hkey; | ||
55 | DWORD dw; | ||
56 | if(RegCreateKeyEx(hRoot,subKey,0,REG_NONE,REG_OPTION_NON_VOLATILE,KEY_READ|KEY_WRITE,NULL,&hkey,&dw)!=ERROR_SUCCESS) | ||
57 | return FALSE; | ||
58 | BOOL rv = (RegSetValueEx(hkey,valName,0,REG_SZ,(LPBYTE)val,strlen(val)+1)==ERROR_SUCCESS); | ||
59 | RegCloseKey(hkey); | ||
60 | return rv; | ||
61 | } | ||
62 | |||
63 | void MAKE_PATH(LPCSTR path) | ||
64 | { | ||
65 | STRING tmp(strlen(path)+1); | ||
66 | LPCSTR t0=path; | ||
67 | LPSTR t1=tmp; | ||
68 | while(*t0){ | ||
69 | if((*t0)=='\\'){ | ||
70 | *t1=0; | ||
71 | CreateDirectory(tmp,NULL); | ||
72 | } | ||
73 | *(t1++)=*(t0++); | ||
74 | } | ||
75 | *t1=0; | ||
76 | CreateDirectory(tmp,NULL); | ||
77 | } | ||
78 | |||
79 | BOOL ADDMENU(LPCSTR menu,LPCSTR item,LPCSTR path,LPCSTR program) | ||
80 | { | ||
81 | STRING stm = strFETCH_REG_KEY(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders","Programs"); | ||
82 | if(!stm) | ||
83 | return FALSE; | ||
84 | int pil = 1+strlen(path)+1+strlen(program)+1+1; | ||
85 | STRING pi(pil); | ||
86 | strcpy(pi,path); | ||
87 | APPEND_SLASH(pi); | ||
88 | strcat(pi,program); | ||
89 | int ipl = strlen(stm)+1+strlen(menu)+1+strlen(item)+4+1; | ||
90 | STRING ip(ipl); | ||
91 | memmove(ip,stm,strlen(stm)+1); | ||
92 | APPEND_SLASH(ip); | ||
93 | strcat(ip,menu); | ||
94 | MAKE_PATH(ip); | ||
95 | APPEND_SLASH(ip); | ||
96 | strcat(ip,item); | ||
97 | strcat(ip,".lnk"); | ||
98 | IShellLink* sl = NULL; | ||
99 | IPersistFile* pf = NULL; | ||
100 | BOOL rv = FALSE; | ||
101 | do{ | ||
102 | HRESULT hrv = CoCreateInstance(CLSID_ShellLink,NULL,CLSCTX_INPROC_SERVER,IID_IShellLink,(LPVOID*)&sl); | ||
103 | if(!SUCCEEDED(hrv)) | ||
104 | break; | ||
105 | sl->SetDescription(item); | ||
106 | sl->SetPath(pi); | ||
107 | hrv = sl->QueryInterface(IID_IPersistFile,(LPVOID*)&pf); | ||
108 | if(!SUCCEEDED(hrv)) | ||
109 | break; | ||
110 | WORD wsz[MAX_PATH]; | ||
111 | MultiByteToWideChar(CP_ACP,0,ip,-1,wsz,MAX_PATH); | ||
112 | hrv = pf->Save(wsz,TRUE); | ||
113 | if(SUCCEEDED(hrv)) | ||
114 | rv=TRUE; | ||
115 | }while(FALSE); | ||
116 | if(pf) | ||
117 | pf->Release(); | ||
118 | if(sl) | ||
119 | sl->Release(); | ||
120 | return rv; | ||
121 | } | ||
122 | |||
123 | FILE* CREATE_INF_FILE(LPCSTR path,LPCSTR file) | ||
124 | { | ||
125 | STRING fn(strlen(path)+1+strlen(file)+1); | ||
126 | strcpy(fn,path); | ||
127 | APPEND_SLASH(fn); | ||
128 | strcat(fn,file); | ||
129 | return fopen(fn,"wt"); | ||
130 | } | ||
131 | |||
132 | BOOL INSTALLFILE(LPCSTR res,LPCSTR path,LPCSTR file) | ||
133 | { | ||
134 | STRING temp(MAX_PATH); | ||
135 | if(!GetTempPath(MAX_PATH,temp)) return FALSE; | ||
136 | STRING tf(MAX_PATH); | ||
137 | if(!GetTempFileName(temp,"KGI",0,tf)) return FALSE; | ||
138 | HRSRC hrsrc = FindResource(NULL,res,MAKEINTRESOURCE(RT_RCDATA)); | ||
139 | if(!hrsrc) return FALSE; | ||
140 | DWORD sor = SizeofResource(NULL,hrsrc); | ||
141 | if(!sor) return FALSE; | ||
142 | HGLOBAL hglobal = LoadResource(NULL,hrsrc); | ||
143 | if(!hglobal) return FALSE; | ||
144 | LPVOID lpv = LockResource(hglobal); | ||
145 | if(!lpv) return FALSE; | ||
146 | HANDLE hf = CreateFile(tf,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_TEMPORARY,NULL); | ||
147 | if(!hf) return FALSE; | ||
148 | DWORD written = 0; | ||
149 | if(!WriteFile(hf,lpv,sor,&written,NULL) || written!=sor){ | ||
150 | CloseHandle(hf); | ||
151 | return FALSE; | ||
152 | } | ||
153 | CloseHandle(hf); | ||
154 | STRING toKill(strlen(tf)+1); | ||
155 | strcpy(toKill,tf); | ||
156 | for(int tmp=strlen(tf)-1;tmp>0 && ((tf[tmp])!='\\');tmp--); | ||
157 | if(tf[tmp]=='\\') | ||
158 | tf[tmp++]=0; | ||
159 | STRING nothing(_MAX_PATH); | ||
160 | UINT nothingLength=_MAX_PATH; | ||
161 | if(VerInstallFile(0,&tf[tmp],(LPSTR)file,tf,(LPSTR)path,NULL,nothing,¬hingLength)){ | ||
162 | DeleteFile(toKill); | ||
163 | return FALSE; | ||
164 | } | ||
165 | DeleteFile(toKill); | ||
166 | return TRUE; | ||
167 | } | ||
168 | |||
169 | LPCSTR pdTitle, pdPrompt; | ||
170 | char pdPath[_MAX_PATH]; | ||
171 | BOOL CALLBACK pathDlgProc(HWND hwnd,UINT uMsg,WPARAM wP,LPARAM lP) | ||
172 | { | ||
173 | switch(uMsg){ | ||
174 | case WM_INITDIALOG: | ||
175 | SetWindowText(hwnd,pdTitle); | ||
176 | SetDlgItemText(hwnd,IDC_PROMPT,pdPrompt); | ||
177 | SetDlgItemText(hwnd,IDC_PATH,pdPath); | ||
178 | SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); | ||
179 | return 1; | ||
180 | case WM_COMMAND: | ||
181 | switch(LOWORD(wP)){ // ID | ||
182 | case IDC_BROWSE: | ||
183 | switch(HIWORD(wP)){ | ||
184 | case BN_CLICKED: | ||
185 | { | ||
186 | BROWSEINFO bi; | ||
187 | memset(&bi,0,sizeof(bi)); | ||
188 | bi.hwndOwner=hwnd; | ||
189 | bi.pszDisplayName=pdPath; | ||
190 | bi.lpszTitle="Select Folder.."; | ||
191 | bi.ulFlags=BIF_RETURNONLYFSDIRS; | ||
192 | LPITEMIDLIST lpidl=SHBrowseForFolder(&bi); | ||
193 | if(lpidl){ | ||
194 | SHGetPathFromIDList(lpidl,pdPath); | ||
195 | SHFree(lpidl); | ||
196 | SetDlgItemText(hwnd,IDC_PATH,pdPath); | ||
197 | } | ||
198 | } | ||
199 | return 1; | ||
200 | } | ||
201 | break; | ||
202 | case IDOK: | ||
203 | switch(HIWORD(wP)){ | ||
204 | case BN_CLICKED: | ||
205 | if(GetDlgItemText(hwnd,IDC_PATH,pdPath,sizeof(pdPath))) | ||
206 | EndDialog(hwnd,IDOK); | ||
207 | else | ||
208 | // *** Error message | ||
209 | EndDialog(hwnd,IDCANCEL); | ||
210 | return 1; | ||
211 | } | ||
212 | break; | ||
213 | case IDCANCEL: | ||
214 | switch(HIWORD(wP)){ | ||
215 | case BN_CLICKED: | ||
216 | EndDialog(hwnd,IDCANCEL); | ||
217 | return 1; | ||
218 | } | ||
219 | break; | ||
220 | }; | ||
221 | break; | ||
222 | } | ||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | LPSTR REQUESTPATH(LPCSTR title,LPCSTR prompt,LPCSTR defPath) | ||
227 | { | ||
228 | pdTitle=title;pdPrompt=prompt; | ||
229 | strcpy(pdPath,defPath); | ||
230 | if(DialogBox(NULL,MAKEINTRESOURCE(IDD_PATH),NULL/*Parent*/,(DLGPROC)&pathDlgProc)!=IDOK) | ||
231 | return NULL; | ||
232 | STRING rv(strlen(pdPath)+1); | ||
233 | strcpy(rv,pdPath); | ||
234 | return rv.Detach(); | ||
235 | } | ||
236 | |||
237 | HKEY uninstallKey(LPCSTR regKey) { | ||
238 | STRING rk(100+strlen(regKey)+1); | ||
239 | sprintf(rk,"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s",regKey); | ||
240 | HKEY rv = NULL; | ||
241 | DWORD dw; | ||
242 | if(RegCreateKeyEx(HKEY_LOCAL_MACHINE,rk,0,REG_NONE,REG_OPTION_NON_VOLATILE,KEY_READ|KEY_WRITE,NULL,&rv,&dw)!=ERROR_SUCCESS) | ||
243 | return NULL; | ||
244 | return rv; | ||
245 | } | ||
246 | |||
247 | BOOL REG_UNINSTALL_COMMAND(LPCSTR regKey,LPCSTR dName,LPCSTR iPath,LPCSTR iFile,LPCSTR iSection) | ||
248 | { | ||
249 | HKEY hKey = uninstallKey(regKey); | ||
250 | if(!hKey) | ||
251 | return FALSE; | ||
252 | BOOL rv=FALSE; | ||
253 | do{ | ||
254 | if(RegSetValueEx(hKey,"DisplayName",0,REG_SZ,(LPBYTE)dName,strlen(dName)+1)!=ERROR_SUCCESS) | ||
255 | break; | ||
256 | STRING us(50+strlen(iPath)+1+strlen(iFile)+strlen(iSection)+1); | ||
257 | strcpy(us,"RunDll32 setupapi.dll,InstallHinfSection "); | ||
258 | strcat(us,iSection); | ||
259 | strcat(us," 132 "); | ||
260 | strcat(us,iPath); | ||
261 | APPEND_SLASH(us); | ||
262 | strcat(us,iFile); | ||
263 | if(RegSetValueEx(hKey,"UninstallString",0,REG_SZ,(LPBYTE)(LPCSTR)us,strlen(us)+1)!=ERROR_SUCCESS) | ||
264 | break; | ||
265 | rv=TRUE; | ||
266 | }while(FALSE); | ||
267 | RegCloseKey(hKey); | ||
268 | return rv; | ||
269 | } | ||
270 | BOOL REG_UNINSTALL_ICON(LPCSTR regKey,LPCSTR path,LPCSTR file,int n) { | ||
271 | HKEY hKey = uninstallKey(regKey); | ||
272 | if(!hKey) | ||
273 | return FALSE; | ||
274 | STRING uis(strlen(path)+1+strlen(file)+7); | ||
275 | strcpy(uis,path); | ||
276 | APPEND_SLASH(uis); | ||
277 | strcat(uis,file); | ||
278 | char tmp[8]; | ||
279 | sprintf(tmp,";%d",n); | ||
280 | strcat(uis,tmp); | ||
281 | BOOL rv = TRUE; | ||
282 | if(RegSetValueEx(hKey,"DisplayIcon",0,REG_SZ,(LPBYTE)(LPCSTR)uis,strlen(uis)+1)!=ERROR_SUCCESS) | ||
283 | rv = FALSE; | ||
284 | RegCloseKey(hKey); | ||
285 | return rv; | ||
286 | } | ||
287 | BOOL REG_UNINSTALL_COMMENT(LPCSTR regKey,LPCSTR comment) { | ||
288 | HKEY hKey = uninstallKey(regKey); | ||
289 | if(!hKey) | ||
290 | return FALSE; | ||
291 | BOOL rv = TRUE; | ||
292 | if(RegSetValueEx(hKey,"lComment",0,REG_SZ,(LPBYTE)comment,strlen(comment)+1)!=ERROR_SUCCESS) | ||
293 | rv = FALSE; | ||
294 | RegCloseKey(hKey); | ||
295 | return rv; | ||
296 | } | ||
297 | BOOL REG_UNINSTALL_VERSION(LPCSTR regKey,LPCSTR version) { | ||
298 | HKEY hKey = uninstallKey(regKey); | ||
299 | if(!hKey) | ||
300 | return FALSE; | ||
301 | BOOL rv = TRUE; | ||
302 | if(RegSetValueEx(hKey,"DisplayVersion",0,REG_SZ,(LPBYTE)version,strlen(version)+1)!=ERROR_SUCCESS) | ||
303 | rv = FALSE; | ||
304 | RegCloseKey(hKey); | ||
305 | return rv; | ||
306 | } | ||
307 | BOOL REG_UNINSTALL_LOCATION(LPCSTR regKey,LPCSTR location) { | ||
308 | HKEY hKey = uninstallKey(regKey); | ||
309 | if(!hKey) | ||
310 | return FALSE; | ||
311 | BOOL rv = TRUE; | ||
312 | if(RegSetValueEx(hKey,"InstallLocation",0,REG_SZ,(LPBYTE)location,strlen(location)+1)!=ERROR_SUCCESS) | ||
313 | rv = FALSE; | ||
314 | RegCloseKey(hKey); | ||
315 | return rv; | ||
316 | } | ||
317 | BOOL REG_UNINSTALL_PUBLISHER(LPCSTR regKey,LPCSTR publisher) { | ||
318 | HKEY hKey = uninstallKey(regKey); | ||
319 | if(!hKey) | ||
320 | return FALSE; | ||
321 | BOOL rv = TRUE; | ||
322 | if(RegSetValueEx(hKey,"Publisher",0,REG_SZ,(LPBYTE)publisher,strlen(publisher)+1)!=ERROR_SUCCESS) | ||
323 | rv = FALSE; | ||
324 | RegCloseKey(hKey); | ||
325 | return rv; | ||
326 | } | ||
327 | BOOL REG_UNINSTALL_URLS(LPCSTR regKey,LPCSTR about,LPCSTR update) { | ||
328 | HKEY hKey = uninstallKey(regKey); | ||
329 | if(!hKey) | ||
330 | return FALSE; | ||
331 | BOOL rv = TRUE; | ||
332 | if(RegSetValueEx(hKey,"URLInfoAbout",0,REG_SZ,(LPBYTE)about,strlen(about)+1)!=ERROR_SUCCESS) | ||
333 | rv = FALSE; | ||
334 | if(RegSetValueEx(hKey,"URLUpdateInfo",0,REG_SZ,(LPBYTE)update,strlen(update)+1)!=ERROR_SUCCESS) | ||
335 | rv = FALSE; | ||
336 | RegCloseKey(hKey); | ||
337 | return rv; | ||
338 | } | ||
339 | |||
340 | #defineINF_FILE_HEADER(i) fprintf(i,"[Version]\nSignature=\"$CHICAGO$\"\n\n") | ||
341 | #define INF_FILE_SECTION(i,s) fprintf(i,"\n[%s]\n",s) | ||
342 | #defineINF_UNINSTALL_REG(i,p) fprintf(i,"HKLM,Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s\nHKLM,Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s,DisplayName\nHKLM,Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s,UninstallString\n",p,p,p) | ||
343 | #define INF_MENU_GROUP(i,n,m) fprintf(i,"setup.ini, progman.groups,,\"group%d=%s\"\n",n,m) | ||
344 | #define INF_MENU_ITEM(i,n,m) fprintf(i,"setup.ini, group%d,, \"\"\"%s\"\"\"\n",n,m); | ||
345 | #define INF_REMOVE_ROOT(i,g,r) fprintf(i,"HKLM,Software\\Microsoft\\Windows\\CurrentVersion\\DeleteFiles\\%s,,,\"%s\"\n",g,r) | ||
346 | #define INF_REMOVE_FILE(i,g,f) fprintf(i,"HKLM,Software\\Microsoft\\Windows\\CurrentVersion\\DeleteFiles\\%s,%s,,\"%s\"\n",g,f,f) | ||
347 | #define INF_REMOVE_HELP_FILE(i,g,f) {INF_REMOVE_FILE(i,g,f".hlp");INF_REMOVE_FILE(i,g,f".cnt");INF_REMOVE_FILE(i,g,f".GID");INF_REMOVE_FILE(i,g,f".FTS");} | ||
348 | |||
349 | LPSTR GET_SHORT_PATH(LPCSTR path) | ||
350 | { | ||
351 | char tmp; | ||
352 | DWORD len = GetShortPathName(path,&tmp,1); | ||
353 | if(!len) | ||
354 | return NULL; | ||
355 | STRING rv(len+1); | ||
356 | if(!GetShortPathName(path,rv,len+1)) | ||
357 | return NULL; | ||
358 | return rv.Detach(); | ||
359 | } | ||
360 | |||
361 | BOOL Install(void); | ||
362 | |||
363 | int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,int) | ||
364 | { | ||
365 | theInstance=hInstance; | ||
366 | CoInitialize(NULL); | ||
367 | Install(); | ||
368 | CoUninitialize(); | ||
369 | return 0; | ||
370 | } | ||
diff --git a/shared-code/ip_icmp.h b/shared-code/ip_icmp.h new file mode 100644 index 0000000..acaf7e9 --- a/dev/null +++ b/shared-code/ip_icmp.h | |||
@@ -0,0 +1,91 @@ | |||
1 | #ifndef IP_ICMPHEADER | ||
2 | |||
3 | #define IP_ICMPHEADER | ||
4 | |||
5 | struct icmp { | ||
6 | BYTE icmp_type; | ||
7 | BYTE icmp_code; | ||
8 | WORD icmp_cksum; | ||
9 | WORD icmp_id; | ||
10 | WORD icmp_seq; | ||
11 | char icmp_data[1]; | ||
12 | }; | ||
13 | |||
14 | #define SIZE_ICMP_HDR 8 | ||
15 | #define SIZE_TIME_DATA 8 | ||
16 | |||
17 | struct ip { | ||
18 | BYTE ip_hl:4, /* header length */ | ||
19 | ip_v:4; /* version */ | ||
20 | BYTE ip_tos; /* type of service */ | ||
21 | short ip_len; /* total length */ | ||
22 | u_short ip_id; /* identification */ | ||
23 | short ip_off; /* fragment offset field */ | ||
24 | BYTE ip_ttl; /* time to live */ | ||
25 | BYTE ip_p; /* protocol */ | ||
26 | u_short ip_sum; /* checksum */ | ||
27 | struct in_addr ip_src,ip_dst; /* source and dest address */ | ||
28 | }; | ||
29 | |||
30 | #define ICMP_ECHOREPLY 0 /* echo reply */ | ||
31 | #define ICMP_UNREACH 3 /* dest unreachable, codes: */ | ||
32 | #define ICMP_UNREACH_NET 0 /* bad net */ | ||
33 | #define ICMP_UNREACH_HOST 1 /* bad host */ | ||
34 | #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ | ||
35 | #define ICMP_UNREACH_PORT 3 /* bad port */ | ||
36 | #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ | ||
37 | #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ | ||
38 | #define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ | ||
39 | #define ICMP_REDIRECT 5 /* shorter route, codes: */ | ||
40 | #define ICMP_REDIRECT_NET 0 /* for network */ | ||
41 | #define ICMP_REDIRECT_HOST 1 /* for host */ | ||
42 | #define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ | ||
43 | #define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ | ||
44 | #define ICMP_ECHO 8 /* echo service */ | ||
45 | #define ICMP_TIMXCEED 11 /* time exceeded, code: */ | ||
46 | #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ | ||
47 | #define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ | ||
48 | #define ICMP_PARAMPROB 12 /* ip header bad */ | ||
49 | #define ICMP_TSTAMP 13 /* timestamp request */ | ||
50 | #define ICMP_TSTAMPREPLY 14 /* timestamp reply */ | ||
51 | #define ICMP_IREQ 15 /* information request */ | ||
52 | #define ICMP_IREQREPLY 16 /* information reply */ | ||
53 | #define ICMP_MASKREQ 17 /* address mask request */ | ||
54 | #define ICMP_MASKREPLY 18 /* address mask reply */ | ||
55 | |||
56 | #define ICMP_MAXTYPE 18 | ||
57 | |||
58 | #define ICMP_MINLEN 8 /* abs minimum */ | ||
59 | #define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ | ||
60 | #define ICMP_MASKLEN 12 /* address mask */ | ||
61 | #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ | ||
62 | #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) | ||
63 | |||
64 | #define STNORM 0 | ||
65 | |||
66 | /* Definition of the lowest telnet byte following an IAC byte */ | ||
67 | #define LOW_TEL_OPT 236 | ||
68 | |||
69 | #define TEL_EOF 236 | ||
70 | #define SUSP 237 | ||
71 | #define ABORT 238 | ||
72 | |||
73 | #define SE 240 | ||
74 | #define NOP 241 | ||
75 | #define DM 242 | ||
76 | #define BREAK 243 | ||
77 | #define IP 244 | ||
78 | #define AO 245 | ||
79 | #define AYT 246 | ||
80 | #define EC 247 | ||
81 | #define EL 248 | ||
82 | #define GOAHEAD 249 | ||
83 | #define SB 250 | ||
84 | #define WILL 251 | ||
85 | #define WONT 252 | ||
86 | #define DO 253 | ||
87 | #define DONT 254 | ||
88 | #define IAC 255 | ||
89 | |||
90 | #endif | ||
91 | |||
diff --git a/shared-code/kHelpers.h b/shared-code/kHelpers.h new file mode 100644 index 0000000..209c6b0 --- a/dev/null +++ b/shared-code/kHelpers.h | |||
@@ -0,0 +1,159 @@ | |||
1 | #ifndef__KHELPERS_H | ||
2 | #define __KHELPERS_H | ||
3 | |||
4 | #include <shlobj.h> | ||
5 | |||
6 | extern "C" WINSHELLAPI void WINAPI SHFree( LPVOID); | ||
7 | |||
8 | namespace Klever { | ||
9 | |||
10 | inline BOOL BrowseForFolder(CString& folder,LPCTSTR title=NULL,CWnd* pParent=NULL) { | ||
11 | BROWSEINFO bi; | ||
12 | memset(&bi,0,sizeof(bi)); | ||
13 | if(pParent) | ||
14 | bi.hwndOwner=pParent->GetSafeHwnd(); | ||
15 | CString rv; | ||
16 | bi.pszDisplayName=rv.GetBuffer(MAX_PATH); | ||
17 | bi.lpszTitle=title; | ||
18 | bi.ulFlags=BIF_RETURNONLYFSDIRS; | ||
19 | LPITEMIDLIST lpidl = SHBrowseForFolder(&bi); | ||
20 | if(lpidl){ | ||
21 | SHGetPathFromIDList(lpidl,bi.pszDisplayName); | ||
22 | SHFree(lpidl); | ||
23 | rv.ReleaseBuffer(); | ||
24 | folder=rv; | ||
25 | return TRUE; | ||
26 | } | ||
27 | rv.ReleaseBuffer(); | ||
28 | return FALSE; | ||
29 | } | ||
30 | inline BOOL BrowseForFolder(CString& folder,UINT idTitle,CWnd* pParent=NULL) { | ||
31 | CString title; | ||
32 | VERIFY(title.LoadString(idTitle)); | ||
33 | return BrowseForFolder(folder,title,pParent); | ||
34 | } | ||
35 | inline CString GluePathAndFile(LPCTSTR path,LPCTSTR file) { | ||
36 | CString rv = path; | ||
37 | while((!rv.IsEmpty()) && rv[rv.GetLength()-1]=='\\') | ||
38 | rv=rv.Left(rv.GetLength()-1); | ||
39 | rv+='\\'; | ||
40 | while(*file && *file=='\\') | ||
41 | file++; | ||
42 | rv+=file; | ||
43 | return rv; | ||
44 | } | ||
45 | inline UINT TokenizeString(CStringList& rv,LPCTSTR string,LPCTSTR delimiter) { | ||
46 | CString s = string; | ||
47 | int found; | ||
48 | int delength = strlen(delimiter); | ||
49 | int rvc = 0; | ||
50 | while((found=s.Find(delimiter))>=0){ | ||
51 | rv.AddTail(s.Left(found)); | ||
52 | rvc++; | ||
53 | s=s.Mid(found+delength); | ||
54 | } | ||
55 | if(!s.IsEmpty()){ | ||
56 | rv.AddTail(s); | ||
57 | rvc++; | ||
58 | } | ||
59 | return rvc; | ||
60 | } | ||
61 | inline BOOL LogRecord(LPCTSTR logFile,LPCTSTR logRecord) { | ||
62 | try{ | ||
63 | CFile f(logFile,CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite|CFile::shareDenyWrite); | ||
64 | f.SeekToEnd(); | ||
65 | CString s = CTime::GetCurrentTime().Format("[%c] ")+logRecord+"\r\n"; | ||
66 | f.Write((LPCTSTR)s,s.GetLength()); | ||
67 | }catch(CException* e){ | ||
68 | e->Delete(); | ||
69 | return FALSE; | ||
70 | } | ||
71 | return TRUE; | ||
72 | } | ||
73 | inline BOOL ReadString(CFile* file,CString& rv) { | ||
74 | rv.Empty(); | ||
75 | int nBuffer = 256; | ||
76 | TCHAR* ch = rv.GetBuffer(nBuffer); | ||
77 | int nPos = 0; | ||
78 | BOOL bRV = FALSE; | ||
79 | for(;;){ | ||
80 | TCHAR c; | ||
81 | try{ | ||
82 | if(file->Read(&c,sizeof(c))!=sizeof(c)) | ||
83 | break; | ||
84 | bRV=TRUE; | ||
85 | }catch(CException* e){ | ||
86 | e->Delete(); | ||
87 | TRACE0("Exception in ReadString\n"); | ||
88 | return FALSE; | ||
89 | } | ||
90 | if(nPos>=(nBuffer-1)){ | ||
91 | rv.ReleaseBuffer(); | ||
92 | ch = rv.GetBuffer(nBuffer=nBuffer+256); | ||
93 | ASSERT(ch); | ||
94 | } | ||
95 | if(c=='\n') | ||
96 | break; | ||
97 | ch[nPos++]=c; | ||
98 | } | ||
99 | ch[nPos]=0; | ||
100 | for(;;){ | ||
101 | nPos--; | ||
102 | if(nPos<0) | ||
103 | break; | ||
104 | if(ch[nPos]!='\r') | ||
105 | break; | ||
106 | ch[nPos]=0; | ||
107 | } | ||
108 | rv.ReleaseBuffer(); | ||
109 | rv.FreeExtra(); | ||
110 | return bRV; | ||
111 | } | ||
112 | |||
113 | inline int LoadStringList(CStringList& list,LPCTSTR section) { | ||
114 | CString n; | ||
115 | list.RemoveAll(); | ||
116 | CWinApp* app = AfxGetApp(); | ||
117 | ASSERT(app); | ||
118 | for(int tmp=0;;tmp++){ | ||
119 | n.Format("%d",tmp); | ||
120 | CString str = app->GetProfileString(section,n,NULL); | ||
121 | if(str.IsEmpty()) | ||
122 | break; | ||
123 | list.AddTail(str); | ||
124 | } | ||
125 | return tmp; | ||
126 | } | ||
127 | inline int SaveStringList(CStringList& list,LPCTSTR section) { | ||
128 | CString n; | ||
129 | CWinApp* app = AfxGetApp(); | ||
130 | ASSERT(app); | ||
131 | POSITION p = list.GetHeadPosition(); | ||
132 | for(int tmp=0;p;tmp++){ | ||
133 | n.Format("%d",tmp); | ||
134 | app->WriteProfileString(section,n,list.GetNext(p)); | ||
135 | } | ||
136 | n.Format("%d",tmp); | ||
137 | app->WriteProfileString(section,n,NULL); | ||
138 | return tmp; | ||
139 | } | ||
140 | |||
141 | inline BOOL WriteProfileString(LPCTSTR section,LPCTSTR entry,LPCTSTR str) { | ||
142 | CWinApp* app = AfxGetApp(); | ||
143 | return app->WriteProfileBinary(section,entry,(LPBYTE)str,strlen(str)+1); | ||
144 | } | ||
145 | inline CString GetProfileString(LPCTSTR section,LPCTSTR entry,LPCTSTR defval) { | ||
146 | CWinApp* app = AfxGetApp(); | ||
147 | LPBYTE pData; | ||
148 | UINT nCount; | ||
149 | CString rv = defval; | ||
150 | if(app->GetProfileBinary(section,entry,&pData,&nCount)){ | ||
151 | rv = (LPCTSTR)pData; | ||
152 | delete pData; | ||
153 | } | ||
154 | return rv; | ||
155 | } | ||
156 | |||
157 | }; | ||
158 | |||
159 | #endif // __KHELPERS_H | ||
diff --git a/shared-code/kICMP.cpp b/shared-code/kICMP.cpp new file mode 100644 index 0000000..09a8f94 --- a/dev/null +++ b/shared-code/kICMP.cpp | |||
@@ -0,0 +1,300 @@ | |||
1 | #include "../stdafx.h" | ||
2 | #include "kICMP.h" | ||
3 | |||
4 | CICMP::_mechanismus CICMP::m_mechanismus = CICMP::_icmpUndetermined; | ||
5 | |||
6 | BOOL CICMPDll::Initialize() | ||
7 | { | ||
8 | if(m_hICMP!=INVALID_HANDLE_VALUE || m_hICMPDLL) | ||
9 | Deinitialize(); | ||
10 | m_hICMPDLL = ::LoadLibraryEx("ICMP",NULL,0); | ||
11 | if(!m_hICMPDLL) | ||
12 | return FALSE; | ||
13 | *(FARPROC*)&m_icmpCF = ::GetProcAddress(m_hICMPDLL,"IcmpCreateFile"); | ||
14 | *(FARPROC*)&m_icmpSE = ::GetProcAddress(m_hICMPDLL,"IcmpSendEcho"); | ||
15 | *(FARPROC*)&m_icmpCH = ::GetProcAddress(m_hICMPDLL,"IcmpCloseHandle"); | ||
16 | if(!(m_icmpCF && m_icmpSE && m_icmpCH)){ | ||
17 | Deinitialize(); return FALSE; | ||
18 | } | ||
19 | m_hICMP = (*m_icmpCF)(); | ||
20 | if(m_hICMP==INVALID_HANDLE_VALUE){ | ||
21 | Deinitialize(); return FALSE; | ||
22 | } | ||
23 | TRACE0("ICMP-DLL Initialized\n"); | ||
24 | return TRUE; | ||
25 | } | ||
26 | void CICMPDll::Deinitialize() | ||
27 | { | ||
28 | if(m_hICMPDLL){ | ||
29 | if(m_hICMP!=INVALID_HANDLE_VALUE && m_icmpCH) | ||
30 | (*m_icmpCH)(m_hICMP); | ||
31 | ::FreeLibrary(m_hICMPDLL); m_hICMPDLL = NULL; | ||
32 | m_icmpCF = NULL; | ||
33 | m_icmpSE = NULL; | ||
34 | m_icmpCH = NULL; | ||
35 | } | ||
36 | m_hICMP=INVALID_HANDLE_VALUE; | ||
37 | if(m_sizeOut && m_bsOut){ | ||
38 | delete m_bsOut; | ||
39 | m_bsOut = NULL; m_sizeOut = 0; | ||
40 | } | ||
41 | if(m_sizeIn && m_bsIn){ | ||
42 | delete m_bsIn; | ||
43 | m_bsIn = NULL; m_sizeIn = 0; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | LONG CICMPDll::Ping(const in_addr host,const UINT packetSize, | ||
48 | const UINT timeOut,LPINT pStatus) | ||
49 | { | ||
50 | if(!(m_hICMP && m_hICMPDLL && m_icmpSE)){ | ||
51 | if(pStatus) | ||
52 | (*pStatus) = icmpNotInitialized; | ||
53 | return -1; | ||
54 | } | ||
55 | VERIFY(AdjustBuffers(packetSize)); | ||
56 | IPINFO ipi; | ||
57 | memset(&ipi,0,sizeof(ipi)); | ||
58 | ipi.Ttl = 30; | ||
59 | for(UINT tmp=0;tmp<packetSize;tmp++) | ||
60 | m_bsOut[tmp]=tmp&0xFF; | ||
61 | LPICMPECHO pRep = (LPICMPECHO)m_bsIn; | ||
62 | pRep->Status = 0xFFFFFFFFl; | ||
63 | if((*m_icmpSE)(m_hICMP,host.s_addr,m_bsOut,packetSize, | ||
64 | &ipi,pRep,m_sizeIn,timeOut)) | ||
65 | TRACE0("ICMP-SendEcho succeeded\n"); | ||
66 | else | ||
67 | TRACE0("ICMP-SendEcho failed\n"); | ||
68 | LONG lrv = -1; | ||
69 | INT rv = ipUnknown; | ||
70 | switch(pRep->Status){ | ||
71 | case IP_SUCCESS: | ||
72 | lrv = pRep->RTTime; rv = ipSuccess; | ||
73 | break; | ||
74 | case IP_BUF_TOO_SMALL: rv = ipBuffTooSmall; break; | ||
75 | case IP_DEST_NET_UNREACHABLE: rv = ipDestNetUnreachable; break; | ||
76 | case IP_DEST_HOST_UNREACHABLE: rv = ipDestHostUnreachable; break; | ||
77 | case IP_DEST_PROT_UNREACHABLE: rv = ipDestProtUnreachable; break; | ||
78 | case IP_DEST_PORT_UNREACHABLE: rv = ipDestPortUnreachable; break; | ||
79 | case IP_NO_RESOURCES: rv = ipNoResources; break; | ||
80 | case IP_BAD_OPTION: rv = ipBadOption; break; | ||
81 | case IP_HW_ERROR: rv = ipHWError; break; | ||
82 | case IP_PACKET_TOO_BIG: rv = ipPacketTooBig; break; | ||
83 | case IP_REQ_TIMED_OUT: rv = ipTimeOut; break; | ||
84 | case IP_BAD_REQ: rv = ipBadRequest; break; | ||
85 | case IP_BAD_ROUTE: rv = ipBadRoute; break; | ||
86 | case IP_TTL_EXPIRED_TRANSIT: rv = ipTTLExpiredInTransit; break; | ||
87 | case IP_TTL_EXPIRED_REASSEM: rv = ipTTLExpiredInReasm; break; | ||
88 | case IP_PARAM_PROBLEM: rv = ipParamProblem; break; | ||
89 | case IP_SOURCE_QUENCH: rv = ipSourceQuench; break; | ||
90 | case IP_OPTION_TOO_BIG: rv = ipOptionTooBig; break; | ||
91 | case IP_BAD_DESTINATION: rv = ipBadDest; break; | ||
92 | } | ||
93 | if(pStatus) | ||
94 | (*pStatus)=rv; | ||
95 | return lrv; | ||
96 | } | ||
97 | |||
98 | BOOL CICMPDll::AdjustBuffers(UINT packetSize) | ||
99 | { | ||
100 | if(!packetSize) | ||
101 | packetSize=1; | ||
102 | if(packetSize>m_sizeOut){ | ||
103 | if(m_sizeOut && m_bsOut) | ||
104 | delete m_bsOut; | ||
105 | m_bsOut = new BYTE[m_sizeOut=packetSize]; | ||
106 | if(!m_bsOut) | ||
107 | return FALSE; | ||
108 | } | ||
109 | UINT sin = sizeof(ICMPECHO)+SIZE_ICMP_HDR+packetSize; | ||
110 | if(sin>m_sizeIn){ | ||
111 | if(m_sizeIn && m_bsIn) | ||
112 | delete m_bsIn; | ||
113 | m_bsIn = new BYTE[m_sizeIn=sin]; | ||
114 | if(!m_bsIn) | ||
115 | return FALSE; | ||
116 | } | ||
117 | return TRUE; | ||
118 | } | ||
119 | |||
120 | |||
121 | WORD CICMPWS::m_icmpSeq = 0; | ||
122 | |||
123 | BOOL CICMPWS::Initialize() | ||
124 | { | ||
125 | if(m_socket!=INVALID_SOCKET) | ||
126 | Deinitialize(); | ||
127 | m_socket = socket(AF_INET,SOCK_RAW,1/*ICMP*/); | ||
128 | if(m_socket==INVALID_SOCKET) | ||
129 | return FALSE; | ||
130 | TRACE0("ICMP-WS Initialized\n"); | ||
131 | return TRUE; | ||
132 | } | ||
133 | void CICMPWS::Deinitialize() | ||
134 | { | ||
135 | if(m_socket!=INVALID_SOCKET){ | ||
136 | closesocket(m_socket); | ||
137 | m_socket=INVALID_SOCKET; | ||
138 | } | ||
139 | if(m_sizeOut && m_bsOut){ | ||
140 | delete m_bsOut; | ||
141 | m_bsOut = NULL; m_sizeOut = 0; | ||
142 | } | ||
143 | if(m_sizeIn && m_bsIn){ | ||
144 | delete m_bsIn; | ||
145 | m_bsIn = NULL; m_sizeIn = 0; | ||
146 | } | ||
147 | } | ||
148 | LONG CICMPWS::Ping(const in_addr host,const UINT packetSize, | ||
149 | const UINT timeOut,LPINT pStatus) | ||
150 | { | ||
151 | if(m_socket==INVALID_SOCKET){ | ||
152 | if(pStatus) | ||
153 | (*pStatus)=icmpNotInitialized; | ||
154 | } | ||
155 | VERIFY(AdjustBuffers(packetSize)); | ||
156 | icmp* pPacket = (icmp*)m_bsOut; | ||
157 | memset(pPacket,0,m_sizeOut); | ||
158 | pPacket->icmp_type = ICMP_ECHO; | ||
159 | pPacket->icmp_seq = m_icmpSeq++; | ||
160 | pPacket->icmp_id = (WORD)(::GetCurrentThreadId()&0xFFFF); | ||
161 | for(UINT tmp=0;tmp<packetSize;tmp++) | ||
162 | pPacket->icmp_data[tmp]=tmp&0xFF; | ||
163 | pPacket->icmp_cksum = cksum(pPacket,SIZE_ICMP_HDR+packetSize); | ||
164 | sockaddr_in to; | ||
165 | memset(&to,0,sizeof(to)); | ||
166 | to.sin_addr.s_addr = host.s_addr; | ||
167 | to.sin_family = AF_INET; | ||
168 | if(sendto(m_socket,(char*)pPacket,SIZE_ICMP_HDR+packetSize,0, | ||
169 | (SOCKADDR*)&to,sizeof(to)) != (int)(SIZE_ICMP_HDR+packetSize)){ | ||
170 | TRACE1("sendto: %lu\n",WSAGetLastError()); | ||
171 | if(pStatus) | ||
172 | (*pStatus)=icmpSocketError; | ||
173 | return -1; | ||
174 | } | ||
175 | DWORD sentTime = ::GetTickCount(); | ||
176 | sockaddr_in from; | ||
177 | memset(&from,0,sizeof(from)); | ||
178 | from.sin_family=AF_INET; | ||
179 | from.sin_addr.s_addr=INADDR_ANY; | ||
180 | fd_set fds; | ||
181 | FD_ZERO(&fds); | ||
182 | FD_SET(m_socket,&fds); | ||
183 | long lrv = -1; | ||
184 | INT rv = ipTimeOut; | ||
185 | for(;;){ | ||
186 | DWORD ct = ::GetTickCount(); | ||
187 | if((ct-sentTime)>=timeOut){ | ||
188 | TRACE0("Timeout\n"); | ||
189 | break; | ||
190 | } | ||
191 | timeval tv = { | ||
192 | (timeOut-ct+sentTime)/1000, | ||
193 | (timeOut-ct+sentTime)%1000 | ||
194 | };// tv_sec, tv_usec (secs,microsecs) | ||
195 | if(!select(m_socket,&fds,NULL,NULL,&tv)){ | ||
196 | TRACE1("select: %d\n",WSAGetLastError()); | ||
197 | break; | ||
198 | } | ||
199 | DWORD rtime = ::GetTickCount(); | ||
200 | ASSERT(FD_ISSET(m_socket,&fds)); | ||
201 | int fl = sizeof(from); | ||
202 | int rb = recvfrom(m_socket,(char*)m_bsIn,m_sizeIn,0,(SOCKADDR*)&from,&fl); | ||
203 | ip* pIP = (ip*)m_bsIn; | ||
204 | icmp* pICMP = (icmp*)&m_bsIn[sizeof(ip)]; | ||
205 | if(pICMP->icmp_id!=pPacket->icmp_id) | ||
206 | continue; | ||
207 | if(pICMP->icmp_seq!=pPacket->icmp_seq) | ||
208 | continue; | ||
209 | if(from.sin_addr.s_addr!=host.s_addr) | ||
210 | continue; | ||
211 | if(pICMP->icmp_type==ICMP_ECHOREPLY){ | ||
212 | lrv=rtime-sentTime; | ||
213 | rv=ipSuccess; | ||
214 | break; | ||
215 | } | ||
216 | rv = ipUnknown;// *** | ||
217 | break; | ||
218 | } | ||
219 | if(pStatus) | ||
220 | (*pStatus)=rv; | ||
221 | return lrv; | ||
222 | } | ||
223 | |||
224 | BOOL CICMPWS::AdjustBuffers(UINT packetSize) | ||
225 | { | ||
226 | if(!packetSize) | ||
227 | packetSize=0; | ||
228 | UINT osize = packetSize+SIZE_ICMP_HDR; | ||
229 | if(m_sizeOut<osize){ | ||
230 | if(m_sizeOut && m_bsOut) | ||
231 | delete m_bsOut; | ||
232 | m_bsOut = new BYTE[m_sizeOut=osize]; | ||
233 | if(!m_bsOut) | ||
234 | return FALSE; | ||
235 | } | ||
236 | UINT isize = osize+sizeof(ip); | ||
237 | if(m_sizeIn<isize){ | ||
238 | if(m_sizeIn && m_bsIn) | ||
239 | delete m_bsIn; | ||
240 | m_bsIn = new BYTE[m_sizeIn=isize]; | ||
241 | if(!m_bsIn) | ||
242 | return FALSE; | ||
243 | } | ||
244 | return TRUE; | ||
245 | } | ||
246 | |||
247 | WORD CICMPWS::cksum(LPVOID data,int count) | ||
248 | { | ||
249 | long lSum = 0; | ||
250 | WORD *pData = (WORD*)data; | ||
251 | while(count>0){ | ||
252 | if(count>1){ | ||
253 | lSum+=*(pData++); | ||
254 | count-=2; | ||
255 | }else{ | ||
256 | lSum+=((WORD)*(BYTE*)pData)&0xFF; | ||
257 | count--; | ||
258 | } | ||
259 | } | ||
260 | lSum = (lSum&0xFFFF)+(lSum>>16); | ||
261 | lSum += (lSum>>16); | ||
262 | return (~lSum)&0xFFFF; | ||
263 | } | ||
264 | |||
265 | CICMP* CICMP::CreateICMP() | ||
266 | { | ||
267 | if(m_mechanismus==_icmpUndetermined) | ||
268 | GuessMechanismus(); | ||
269 | switch(m_mechanismus){ | ||
270 | case _icmpWinsock: | ||
271 | return new CICMPWS; | ||
272 | break; | ||
273 | case _icmpDLL: | ||
274 | return new CICMPDll; | ||
275 | break; | ||
276 | } | ||
277 | return NULL; | ||
278 | } | ||
279 | |||
280 | void CICMP::GuessMechanismus() | ||
281 | { | ||
282 | m_mechanismus=_icmpUndetermined; | ||
283 | SOCKET testSocket = socket(AF_INET,SOCK_RAW,1); | ||
284 | if(testSocket!=INVALID_SOCKET){ | ||
285 | closesocket(testSocket); | ||
286 | m_mechanismus=_icmpWinsock; | ||
287 | }else{ | ||
288 | HINSTANCE hICMP = ::LoadLibraryEx("ICMP",NULL,0); | ||
289 | if(!hICMP) | ||
290 | return; | ||
291 | BOOL isThere = ( | ||
292 | ::GetProcAddress(hICMP,"IcmpCreateFile") | ||
293 | && ::GetProcAddress(hICMP,"IcmpSendEcho") | ||
294 | && ::GetProcAddress(hICMP,"IcmpCloseHandle") | ||
295 | ); | ||
296 | ::FreeLibrary(hICMP); | ||
297 | if(isThere) | ||
298 | m_mechanismus=_icmpDLL; | ||
299 | } | ||
300 | } \ No newline at end of file | ||
diff --git a/shared-code/kICMP.h b/shared-code/kICMP.h new file mode 100644 index 0000000..7a5ceaa --- a/dev/null +++ b/shared-code/kICMP.h | |||
@@ -0,0 +1,80 @@ | |||
1 | #ifndef__KICMP_H | ||
2 | #define __KICMP_H | ||
3 | |||
4 | class CICMP { | ||
5 | enum _mechanismus { | ||
6 | _icmpUndetermined = -1, | ||
7 | _icmpWinsock = 0, _icmpDLL | ||
8 | }; | ||
9 | static _mechanismus m_mechanismus; | ||
10 | static void GuessMechanismus(); | ||
11 | public: | ||
12 | static | ||
13 | CICMP* CreateICMP(); | ||
14 | |||
15 | enum { | ||
16 | ipSuccess = 0, | ||
17 | ipBuffTooSmall, ipDestNetUnreachable, ipDestHostUnreachable, | ||
18 | ipDestProtUnreachable, ipDestPortUnreachable, ipNoResources, | ||
19 | ipBadOption, ipHWError, ipPacketTooBig, ipTimeOut, ipBadRequest, | ||
20 | ipBadRoute, ipTTLExpiredInTransit, ipTTLExpiredInReasm, | ||
21 | ipParamProblem, ipSourceQuench, ipOptionTooBig, ipBadDest, | ||
22 | ipUnknown = -1, | ||
23 | icmpNotInitialized = -2, | ||
24 | icmpSocketError = -3 | ||
25 | }; | ||
26 | |||
27 | virtual BOOL Initialize() = 0; | ||
28 | virtual void Deinitialize() = 0; | ||
29 | |||
30 | virtual LONG Ping(const in_addr host,const UINT packetSize=0, | ||
31 | const UINT timeOut=10000,LPINT pStatus=NULL) = 0; | ||
32 | }; | ||
33 | |||
34 | class CICMPDll : public CICMP { | ||
35 | HANDLE(WINAPI *m_icmpCF)(VOID); | ||
36 | BOOL(WINAPI *m_icmpSE)(HANDLE,ULONG,LPVOID,WORD, | ||
37 | PIPINFO,LPVOID,DWORD,DWORD); | ||
38 | BOOL(WINAPI *m_icmpCH)(HANDLE); | ||
39 | public: | ||
40 | HINSTANCE m_hICMPDLL; | ||
41 | HANDLE m_hICMP; | ||
42 | LPBYTE m_bsIn, m_bsOut; | ||
43 | UINT m_sizeIn, m_sizeOut; | ||
44 | |||
45 | CICMPDll() : m_hICMP(INVALID_HANDLE_VALUE), m_hICMPDLL(NULL), | ||
46 | m_bsIn(NULL), m_bsOut(NULL), m_sizeIn(0), m_sizeOut(0) {} | ||
47 | virtual ~CICMPDll() { Deinitialize(); } | ||
48 | |||
49 | virtual BOOL Initialize(); | ||
50 | virtual void Deinitialize(); | ||
51 | |||
52 | virtual LONG Ping(const in_addr host,const UINT packetSize=0, | ||
53 | const UINT timeOut=10000,LPINT pStatus=NULL); | ||
54 | |||
55 | BOOL AdjustBuffers(UINT packetSize=0); | ||
56 | }; | ||
57 | |||
58 | class CICMPWS : public CICMP { | ||
59 | static | ||
60 | WORD m_icmpSeq; | ||
61 | public: | ||
62 | SOCKET m_socket; | ||
63 | LPBYTE m_bsIn, m_bsOut; | ||
64 | UINT m_sizeIn, m_sizeOut; | ||
65 | |||
66 | CICMPWS() : m_socket(INVALID_SOCKET), m_bsIn(NULL), m_bsOut(NULL), | ||
67 | m_sizeIn(0), m_sizeOut(0) {} | ||
68 | virtual ~CICMPWS() { Deinitialize(); } | ||
69 | |||
70 | virtual BOOL Initialize(); | ||
71 | virtual void Deinitialize(); | ||
72 | |||
73 | virtual LONG Ping(const in_addr host,const UINT packetSize=0, | ||
74 | const UINT timeOut=10000,LPINT pStatus=NULL); | ||
75 | |||
76 | BOOL AdjustBuffers(UINT packetSize=0); | ||
77 | WORD cksum(LPVOID data,int count); | ||
78 | }; | ||
79 | |||
80 | #endif // __KICMP_H \ No newline at end of file | ||
diff --git a/shared-code/kinhelp.xsl b/shared-code/kinhelp.xsl new file mode 100644 index 0000000..0bb384a --- a/dev/null +++ b/shared-code/kinhelp.xsl | |||
@@ -0,0 +1,250 @@ | |||
1 | <?xml version="1.0"?> | ||
2 | <xsl:stylesheet version="1.0" | ||
3 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
4 | > | ||
5 | <xsl:output | ||
6 | method="text" | ||
7 | encoding="us-ascii"/> | ||
8 | <xsl:strip-space elements="*"/> | ||
9 | |||
10 | <xsl:template match="winhelp"> | ||
11 | <xsl:text>{\rtf1\ansi</xsl:text> | ||
12 | <xsl:text>
@{\footnote</xsl:text> | ||
13 | <xsl:text>
THIS FILE WAS AUTOMATICALLY GENERATED FROM XML DOCUMENT.</xsl:text> | ||
14 | <xsl:text>
DO NOT MODIFY THIS FILE DIRECTLY. EDIT XML DOCUMENT INSTEAD</xsl:text> | ||
15 | <xsl:text>
}
</xsl:text> | ||
16 | <xsl:call-template name="fonttbl"/> | ||
17 | <xsl:call-template name="colortbl"/> | ||
18 | <xsl:apply-templates/> | ||
19 | <xsl:text>}</xsl:text> | ||
20 | </xsl:template> | ||
21 | |||
22 | <xsl:template match="topic"> | ||
23 | <xsl:text>
\pard\plain</xsl:text> | ||
24 | <xsl:if test="descendant::*[ (@scroll='no') and | ||
25 | count(preceding-sibling::*[not(@scroll='no') and (name()!='a' and @name)])=0] "> | ||
26 | <xsl:text>\keepn</xsl:text> | ||
27 | </xsl:if> | ||
28 | <xsl:if test="@id"> | ||
29 | <xsl:text>
#{\footnote </xsl:text> | ||
30 | <xsl:value-of select="@id"/> | ||
31 | <xsl:text>}</xsl:text> | ||
32 | </xsl:if> | ||
33 | <xsl:if test="@title"> | ||
34 | <xsl:text>
${\footnote </xsl:text> | ||
35 | <xsl:value-of select="@title"/> | ||
36 | <xsl:text>}</xsl:text> | ||
37 | </xsl:if> | ||
38 | <xsl:if test="@keywords"> | ||
39 | <xsl:text>
K{\footnote </xsl:text> | ||
40 | <xsl:value-of select="@keywords"/> | ||
41 | <xsl:text>}</xsl:text> | ||
42 | </xsl:if> | ||
43 | <xsl:apply-templates/> | ||
44 | <xsl:text>
\page
</xsl:text> | ||
45 | </xsl:template> | ||
46 | |||
47 | <xsl:template match="a[@name]"> | ||
48 | <xsl:text>{#{\footnote </xsl:text> | ||
49 | <xsl:value-of select="@name"/> | ||
50 | <xsl:text>}}</xsl:text> | ||
51 | </xsl:template> | ||
52 | <xsl:template match="a[@href]"> | ||
53 | <xsl:call-template name="hyperref"> | ||
54 | <xsl:with-param name="href" select="@href"/> | ||
55 | <xsl:with-param name="inset"><xsl:apply-templates/></xsl:with-param> | ||
56 | </xsl:call-template> | ||
57 | </xsl:template> | ||
58 | <xsl:template name="hyperref"> | ||
59 | <xsl:param name="href"/> | ||
60 | <xsl:param name="inset"/> | ||
61 | <xsl:choose> | ||
62 | <xsl:when test="starts-with($href,'http:') or starts-with($href,'mailto:') or | ||
63 | starts-with($href,'ftp:')"> | ||
64 | <xsl:text>{\uldb </xsl:text> | ||
65 | <xsl:value-of select="$inset"/> | ||
66 | <xsl:text>}{\v %!ExecFile("</xsl:text> | ||
67 | <xsl:value-of select="$href"/> | ||
68 | <xsl:text>")}</xsl:text> | ||
69 | </xsl:when> | ||
70 | <xsl:when test="starts-with($href,'#')"> | ||
71 | <xsl:text>{\uldb </xsl:text> | ||
72 | <xsl:value-of select="$inset"/> | ||
73 | <xsl:text>}{\v </xsl:text> | ||
74 | <xsl:value-of select="substring($href,2)"/> | ||
75 | <xsl:text>}</xsl:text> | ||
76 | </xsl:when> | ||
77 | <xsl:otherwise> | ||
78 | <xsl:message>Warining: Unqualified hyper-reference. Using as help-internal</xsl:message> | ||
79 | <xsl:text>{\uldb </xsl:text> | ||
80 | <xsl:value-of select="$inset"/> | ||
81 | <xsl:text>}{\v </xsl:text> | ||
82 | <xsl:value-of select="$href"/> | ||
83 | <xsl:text>}</xsl:text> | ||
84 | </xsl:otherwise> | ||
85 | </xsl:choose> | ||
86 | </xsl:template> | ||
87 | |||
88 | <xsl:template match="heading"> | ||
89 | <xsl:text>
</xsl:text> | ||
90 | <xsl:if test="@scroll!='no'"> | ||
91 | <xsl:text>\pard </xsl:text> | ||
92 | </xsl:if> | ||
93 | <xsl:text>{ \f1\fs18\b\sb120 </xsl:text> | ||
94 | <xsl:apply-templates/> | ||
95 | <xsl:text>}</xsl:text> | ||
96 | </xsl:template> | ||
97 | |||
98 | <xsl:template match="p"> | ||
99 | <xsl:text>
\par\sa120\sb120\qj</xsl:text> | ||
100 | <xsl:if test="@scroll!='no'"> | ||
101 | <xsl:text>\pard</xsl:text> | ||
102 | </xsl:if> | ||
103 | <xsl:text> \f1\fs18\sb120 </xsl:text> | ||
104 | <xsl:apply-templates/> | ||
105 | </xsl:template> | ||
106 | |||
107 | <xsl:template match="note"> | ||
108 | <xsl:text>
\par\sa120\sb120\qj\f1\fs16 </xsl:text> | ||
109 | <xsl:apply-templates/> | ||
110 | </xsl:template> | ||
111 | |||
112 | <xsl:template match="dedication"> | ||
113 | <xsl:text>
\par\sa120\sb120\qr\f1\fs16 </xsl:text> | ||
114 | <xsl:apply-templates/> | ||
115 | </xsl:template> | ||
116 | |||
117 | <xsl:template match="image"> | ||
118 | <xsl:text>\{bmct </xsl:text> | ||
119 | <xsl:value-of select="@source"/> | ||
120 | <xsl:text>\}</xsl:text> | ||
121 | </xsl:template> | ||
122 | |||
123 | <xsl:template match="newsfor"> | ||
124 | <xsl:text>
\par\pard\plain\f1\fs24\qc\cf2\b </xsl:text> | ||
125 | <xsl:value-of select="@version"/> | ||
126 | <xsl:text> - </xsl:text> | ||
127 | <xsl:value-of select="@date"/> | ||
128 | <xsl:apply-templates/> | ||
129 | </xsl:template> | ||
130 | <xsl:template match="ni"> | ||
131 | <xsl:text>
\par\pard\plain\fi0\li0\f1\fs18 \bullet </xsl:text> | ||
132 | <xsl:apply-templates/> | ||
133 | </xsl:template> | ||
134 | |||
135 | <xsl:template match="b"> | ||
136 | <xsl:text>{\b </xsl:text> | ||
137 | <xsl:apply-templates/> | ||
138 | <xsl:text>}</xsl:text> | ||
139 | </xsl:template> | ||
140 | <xsl:template match="i"> | ||
141 | <xsl:text>{\i </xsl:text> | ||
142 | <xsl:apply-templates/> | ||
143 | <xsl:text>}</xsl:text> | ||
144 | </xsl:template> | ||
145 | <xsl:template match="u"> | ||
146 | <xsl:text>{\ul </xsl:text> | ||
147 | <xsl:apply-templates/> | ||
148 | <xsl:text>}</xsl:text> | ||
149 | </xsl:template> | ||
150 | <xsl:template match="strike"> | ||
151 | <xsl:text>{\strike </xsl:text> | ||
152 | <xsl:apply-templates/> | ||
153 | <xsl:text>}</xsl:text> | ||
154 | </xsl:template> | ||
155 | |||
156 | <xsl:template match="kin"> | ||
157 | <xsl:choose> | ||
158 | <xsl:when test="@href"> | ||
159 | <xsl:call-template name="hyperref"> | ||
160 | <xsl:with-param name="href" select="@href"/> | ||
161 | <xsl:with-param name="inset"><xsl:text>{\b </xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></xsl:with-param> | ||
162 | </xsl:call-template> | ||
163 | </xsl:when> | ||
164 | <xsl:otherwise> | ||
165 | <xsl:text>{\b </xsl:text> | ||
166 | <xsl:apply-templates/> | ||
167 | <xsl:text>}</xsl:text> | ||
168 | </xsl:otherwise> | ||
169 | </xsl:choose> | ||
170 | </xsl:template> | ||
171 | <xsl:template match="product"> | ||
172 | <xsl:choose> | ||
173 | <xsl:when test="@href"> | ||
174 | <xsl:call-template name="hyperref"> | ||
175 | <xsl:with-param name="href" select="@href"/> | ||
176 | <xsl:with-param name="inset"><xsl:text>{\b\cf6 </xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></xsl:with-param> | ||
177 | </xsl:call-template> | ||
178 | </xsl:when> | ||
179 | <xsl:otherwise> | ||
180 | <xsl:text>{\b\cf6 </xsl:text> | ||
181 | <xsl:apply-templates/> | ||
182 | <xsl:text>}</xsl:text> | ||
183 | </xsl:otherwise> | ||
184 | </xsl:choose> | ||
185 | </xsl:template> | ||
186 | <xsl:template match="term"> | ||
187 | <xsl:text>{\i </xsl:text> | ||
188 | <xsl:apply-templates/> | ||
189 | <xsl:text>}</xsl:text> | ||
190 | </xsl:template> | ||
191 | |||
192 | <xsl:template match="rfc"> | ||
193 | <xsl:call-template name="hyperref"> | ||
194 | <xsl:with-param name="href" select="concat('http://www.rfc-editor.org/rfc/rfc',@num,'.txt')"/> | ||
195 | <xsl:with-param name="inset" select="concat('{\b RFC',@num,'}')"/> | ||
196 | </xsl:call-template> | ||
197 | </xsl:template> | ||
198 | |||
199 | <xsl:template match="license"> | ||
200 | <xsl:text>
{</xsl:text> | ||
201 | <xsl:text>
\par\pard\plain\sb360\sa120 \f1\fs16 Copyright (c) </xsl:text> | ||
202 | <xsl:value-of select="@years"/> | ||
203 | <xsl:text> {\uldb\cf0 Klever Group (http://www.klever.net/)}{\v %!ExecFile("http://www.klever.net/")}</xsl:text> | ||
204 | <xsl:text>
\par\qj\sb120\sa120</xsl:text> | ||
205 | <xsl:text>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</xsl:text> | ||
206 | <xsl:text>
\par The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</xsl:text> | ||
207 | <xsl:text>
\par \sa360 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</xsl:text> | ||
208 | <xsl:text>
}</xsl:text> | ||
209 | </xsl:template> | ||
210 | <xsl:template match="credits"> | ||
211 | <xsl:text>
\par \sa0\sb120\ql \f1\fs16 Author: {\b\uldb\cf11 Michael Krelin ({\i hacker@klever.net})}{\v %!ExecFile("mailto:hacker@klever.net")}</xsl:text> | ||
212 | <xsl:text>
\par \sa0\sb0 Fan mail send to {\i\uldb gefilte@klever.net}{\v %!ExecFile("mailto:gefilte@klever.net")}</xsl:text> | ||
213 | </xsl:template> | ||
214 | |||
215 | <xsl:template match="ul"> | ||
216 | <xsl:text>\pard</xsl:text> | ||
217 | <xsl:apply-templates/> | ||
218 | <xsl:text>\pard</xsl:text> | ||
219 | </xsl:template> | ||
220 | <xsl:template match="li"> | ||
221 | <!-- TODO: could be done better, but you never know with winhelp.. --> | ||
222 | <xsl:variable name="li" select=" count(ancestor::ul) "/> | ||
223 | <xsl:text>
\par \fi0\li</xsl:text><xsl:value-of | ||
224 | select="0"/><xsl:text> \bullet </xsl:text> | ||
225 | <xsl:apply-templates/> | ||
226 | </xsl:template> | ||
227 | |||
228 | <xsl:template match="topic/text()"> | ||
229 | <!-- maybe only omit spaces? --> | ||
230 | </xsl:template> | ||
231 | <xsl:template match="ul/text()"> | ||
232 | </xsl:template> | ||
233 | |||
234 | <xsl:template name="colortbl"> | ||
235 | <xsl:text>{\colortbl; | ||
236 | \red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0; | ||
237 | \red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255; | ||
238 | \red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128; | ||
239 | \red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;} | ||
240 | </xsl:text> | ||
241 | </xsl:template> | ||
242 | <xsl:template name="fonttbl"> | ||
243 | <xsl:text>{\fonttbl</xsl:text> | ||
244 | <xsl:text>{\f0\froman Times New Roman;}</xsl:text> | ||
245 | <xsl:text>{\f1\fswiss Arial;}</xsl:text> | ||
246 | <xsl:text>{\f3\froman Symbol;}</xsl:text> | ||
247 | <xsl:text>}</xsl:text> | ||
248 | </xsl:template> | ||
249 | |||
250 | </xsl:stylesheet> | ||
diff --git a/shared-code/ms_icmp.h b/shared-code/ms_icmp.h new file mode 100644 index 0000000..32d97f5 --- a/dev/null +++ b/shared-code/ms_icmp.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /*------------------------------------------------------------------ | ||
2 | * Filename: MS_ICMP.H | ||
3 | * | ||
4 | * Description: Prototypes of Microsoft's ICMP.DLL functions for | ||
5 | * access to Internet Control Message Protocol (their stacks do | ||
6 | * not support the standard Berkeley Sockets raw socket API). | ||
7 | * Use this to do "ping" or "traceroute," although beware that | ||
8 | * Microsoft discourages its use. | ||
9 | */ | ||
10 | |||
11 | |||
12 | /* Note 2: For the most part, you can refer to RFC 791 for detials on | ||
13 | * how to fill in values for the IP option information structure. */ | ||
14 | typedef struct ip_option_information { | ||
15 | u_char Ttl; /* Time To Live (used for traceroute) */ | ||
16 | u_char Tos; /* Type Of Service (usually 0) */ | ||
17 | u_char Flags; /* IP header flags (usually 0) */ | ||
18 | u_char OptionsSize; /* Size of options data (usually 0, max 40) */ | ||
19 | u_char FAR *OptionsData;/* Options data buffer */ | ||
20 | }IPINFO, *PIPINFO, FAR *LPIPINFO; | ||
21 | |||
22 | /* Note 1: The Reply Buffer will have an array of ICMP_ECHO_REPLY | ||
23 | * structures, followed by options and the data in ICMP echo reply | ||
24 | * datagram received. You must have room for at least one ICMP | ||
25 | * echo reply structure, plus 8 bytes for an ICMP header. */ | ||
26 | typedef struct icmp_echo_reply { | ||
27 | u_long Address; /* source address */ | ||
28 | u_long Status; /* IP status value (see below) */ | ||
29 | u_long RTTime; /* Round Trip Time in milliseconds */ | ||
30 | u_short DataSize; /* reply data size */ | ||
31 | u_short Reserved; /* */ | ||
32 | void FAR *Data; /* reply data buffer */ | ||
33 | typedef struct ip_option_information Options; /* reply options */ | ||
34 | }ICMPECHO, *PICMPECHO, FAR *LPICMPECHO; | ||
35 | |||
36 | #define IP_STATUS_BASE 11000 | ||
37 | #define IP_SUCCESS 0 | ||
38 | #define IP_BUF_TOO_SMALL (IP_STATUS_BASE + 1) | ||
39 | #define IP_DEST_NET_UNREACHABLE (IP_STATUS_BASE + 2) | ||
40 | #define IP_DEST_HOST_UNREACHABLE (IP_STATUS_BASE + 3) | ||
41 | #define IP_DEST_PROT_UNREACHABLE (IP_STATUS_BASE + 4) | ||
42 | #define IP_DEST_PORT_UNREACHABLE (IP_STATUS_BASE + 5) | ||
43 | #define IP_NO_RESOURCES (IP_STATUS_BASE + 6) | ||
44 | #define IP_BAD_OPTION (IP_STATUS_BASE + 7) | ||
45 | #define IP_HW_ERROR (IP_STATUS_BASE + 8) | ||
46 | #define IP_PACKET_TOO_BIG (IP_STATUS_BASE + 9) | ||
47 | #define IP_REQ_TIMED_OUT (IP_STATUS_BASE + 10) | ||
48 | #define IP_BAD_REQ (IP_STATUS_BASE + 11) | ||
49 | #define IP_BAD_ROUTE (IP_STATUS_BASE + 12) | ||
50 | #define IP_TTL_EXPIRED_TRANSIT (IP_STATUS_BASE + 13) | ||
51 | #define IP_TTL_EXPIRED_REASSEM (IP_STATUS_BASE + 14) | ||
52 | #define IP_PARAM_PROBLEM (IP_STATUS_BASE + 15) | ||
53 | #define IP_SOURCE_QUENCH (IP_STATUS_BASE + 16) | ||
54 | #define IP_OPTION_TOO_BIG (IP_STATUS_BASE + 17) | ||
55 | #define IP_BAD_DESTINATION (IP_STATUS_BASE + 18) | ||
56 | #define IP_ADDR_DELETED (IP_STATUS_BASE + 19) | ||
57 | #define IP_SPEC_MTU_CHANGE (IP_STATUS_BASE + 20) | ||
58 | #define IP_MTU_CHANGE (IP_STATUS_BASE + 21) | ||
59 | #define IP_UNLOAD (IP_STATUS_BASE + 22) | ||
60 | #define IP_GENERAL_FAILURE (IP_STATUS_BASE + 50) | ||
61 | #define MAX_IP_STATUS IP_GENERAL_FAILURE | ||
62 | #define IP_PENDING (IP_STATUS_BASE + 255) | ||
63 | |||
64 | |||
65 | HANDLE WINAPI PASCAL IcmpCreateFile(VOID); /* INVALID_HANDLE_VALUE on error */ | ||
66 | BOOL WINAPI PASCAL IcmpCloseHandle(HANDLE IcmpHandle); /* FALSE on error */ | ||
67 | DWORD WINAPI PASCAL IcmpSendEcho( | ||
68 | HANDLE IcmpHandle, /* handle returned from IcmpCreateFile() */ | ||
69 | u_long DestAddress, /* destination IP address (in network order) */ | ||
70 | LPVOID RequestData, /* pointer to buffer to send */ | ||
71 | WORD RequestSize, /* length of data in buffer */ | ||
72 | LPIPINFO RequestOptns, /* see Note 2 below */ | ||
73 | LPVOID ReplyBuffer, /* see Note 1 below */ | ||
74 | DWORD ReplySize, /* length of reply (must allow at least 1 reply) */ | ||
75 | DWORD Timeout /* time in milliseconds to wait for reply */ | ||
76 | ); | ||
77 | |||
diff --git a/shared-data/browse-icon.ico b/shared-data/browse-icon.ico new file mode 100644 index 0000000..d2d1b3c --- a/dev/null +++ b/shared-data/browse-icon.ico | |||
Binary files differ | |||
diff --git a/shared-data/install-icon.ico b/shared-data/install-icon.ico new file mode 100644 index 0000000..23e86a6 --- a/dev/null +++ b/shared-data/install-icon.ico | |||
Binary files differ | |||
diff --git a/shared-data/klever-background.bmp b/shared-data/klever-background.bmp new file mode 100644 index 0000000..e4d87ec --- a/dev/null +++ b/shared-data/klever-background.bmp | |||
Binary files differ | |||
diff --git a/shared-data/play-icon.ico b/shared-data/play-icon.ico new file mode 100644 index 0000000..3d2a11e --- a/dev/null +++ b/shared-data/play-icon.ico | |||
Binary files differ | |||
diff --git a/stdafx.cpp b/stdafx.cpp new file mode 100644 index 0000000..560a1b0 --- a/dev/null +++ b/stdafx.cpp | |||
@@ -0,0 +1,6 @@ | |||
1 | // stdafx.cpp : source file that includes just the standard includes | ||
2 | //T42.pch will be the pre-compiled header | ||
3 | //stdafx.obj will contain the pre-compiled type information | ||
4 | |||
5 | #include "stdafx.h" | ||
6 | |||
diff --git a/stdafx.h b/stdafx.h new file mode 100644 index 0000000..6c6a53e --- a/dev/null +++ b/stdafx.h | |||
@@ -0,0 +1,70 @@ | |||
1 | // stdafx.h : include file for standard system include files, | ||
2 | // or project specific include files that are used frequently, but | ||
3 | // are changed infrequently | ||
4 | // | ||
5 | |||
6 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers | ||
7 | |||
8 | #include <afxwin.h> // MFC core and standard components | ||
9 | #include <afxext.h> // MFC extensions | ||
10 | #ifndef _AFX_NO_AFXCMN_SUPPORT | ||
11 | #include <afxcmn.h> // MFC support for Windows Common Controls | ||
12 | #endif // _AFX_NO_AFXCMN_SUPPORT | ||
13 | |||
14 | #include <afxrich.h> | ||
15 | #include <afxtempl.h> | ||
16 | |||
17 | #include <afxsock.h> // MFC socket extensions | ||
18 | |||
19 | #pragma warning(disable: 4786) | ||
20 | |||
21 | #include "shared-code/FindIFace.h" | ||
22 | #include "shared-code/kHelpers.h" | ||
23 | #include "shared-code/BTreendex.h" | ||
24 | #include "shared-code/BitSet.h" | ||
25 | |||
26 | #define REFS2PTS16 | ||
27 | |||
28 | struct osockaddr{ | ||
29 | u_short sa_family;// Address family | ||
30 | charsa_data[14];// Up to 14 bytes of direct address | ||
31 | |||
32 | osockaddr& operator=(sockaddr_in& src) { Copy(src); return *this; } | ||
33 | void Copy(sockaddr_in& src) { | ||
34 | sa_family = htons(src.sin_family); | ||
35 | memmove(sa_data,((sockaddr*)&src)->sa_data,sizeof(((sockaddr*)&src)->sa_data)); | ||
36 | } | ||
37 | }; | ||
38 | |||
39 | #include "talkd.h" | ||
40 | |||
41 | #include "T42CallLog.h" | ||
42 | |||
43 | enum{ | ||
44 | WM_INITIATETALK = WM_USER+16, | ||
45 | WM_TARGETRESOLVED, | ||
46 | WM_SOURCERESOLVED, | ||
47 | WM_LOOKUP_SUCCESS, WM_LOOKUP_FAILURE, | ||
48 | WM_ANNOUNCE_SUCCESS, WM_ANNOUNCE_FAILURE, | ||
49 | WM_LEAVEINVITE_SUCCESS, WM_LEAVEINVITE_FAILURE, | ||
50 | WM_LOCAL_REMOVE_SUCCESS, WM_LOCAL_REMOVE_FAILURE, | ||
51 | WM_REMOTE_REMOVE_SUCCESS, WM_REMOTE_REMOVE_FAILURE, | ||
52 | WM_TALKACCEPT, | ||
53 | WM_CTLTRANSACT, | ||
54 | WM_TALK, | ||
55 | WM_TALKCHAR, | ||
56 | WM_SPLITTERBDOWN, | ||
57 | WM_TALKCONNECT, | ||
58 | WM_NAMERESOLVED, WM_IPRESOLVED, | ||
59 | |||
60 | WM_TRAYICON, | ||
61 | WM_DAEMON, | ||
62 | WM_UPDATEPREVIEW, | ||
63 | |||
64 | timerTransact = 1, | ||
65 | timerTimeout, | ||
66 | timerMinutes | ||
67 | }; | ||
68 | #include <MMSystem.h> | ||
69 | // CG: The following line was added by the Windows Multimedia component. | ||
70 | #pragma comment(lib, "winmm.lib") | ||
@@ -0,0 +1,47 @@ | |||
1 | |||
2 | // Client->Server request message | ||
3 | struct TalkCtlMessage{ | ||
4 | u_char m_Version;// Protocol Version | ||
5 | u_char m_Type; // Request type | ||
6 | u_char m_Answer;// Unused | ||
7 | u_char m_Pad; | ||
8 | u_long m_ID; // Request ID | ||
9 | osockaddrm_Addr; | ||
10 | osockaddrm_ctlAddr; | ||
11 | long m_PID; // Caller's process id | ||
12 | char m_LName[12];// Caller's name (local) | ||
13 | char m_RName[12];// Callee's name (remote) | ||
14 | char m_RTTY[16];// Callee's tty name | ||
15 | |||
16 | }; | ||
17 | |||
18 | // Server->Client response message | ||
19 | struct TalkCtlResponse{ | ||
20 | u_char m_Version;// Protocol Version | ||
21 | u_char m_Type; // Request type | ||
22 | u_char m_Answer;// Response itself | ||
23 | u_char m_Pad; | ||
24 | u_long m_ID; // Request ID | ||
25 | osockaddr m_Addr; // Adress for establishing communication | ||
26 | }; | ||
27 | |||
28 | enum{ | ||
29 | talkCtlVersion = 1, | ||
30 | // Message Types | ||
31 | talkCtlReqLeaveInvite = 0,// Leave an invitation with server | ||
32 | talkCtlReqLookUp = 1,// Check for invitation by callee | ||
33 | talkCtlReqDelete = 2,// Delete invitation by caller | ||
34 | talkCtlReqAnnounce = 3,// Announce invitation by caller | ||
35 | // Answers | ||
36 | talkCtlSuccess = 0,// Operation completed properly | ||
37 | talkCtlNotHere = 1,// Callee not logged in | ||
38 | talkCtlFailed = 2,// Failed for unexplained reason | ||
39 | talkCtlMachineUnknown = 3,// Caller's machine name unknown | ||
40 | talkCtlPermissionDenied = 4,// Callee's tty doesn't permit announce | ||
41 | talkCtlUnknownRequest = 5,// Request has invalid type | ||
42 | talkCtlBadVersion = 6,// Request has invalid protocol version | ||
43 | talkCtlBadAddr = 7,// Request has invalid addr value | ||
44 | talkCtlBadCtlAddr = 8,// Request has invalid ctlAddr value | ||
45 | |||
46 | talkCtlReserved = 255// Internal use | ||
47 | }; \ No newline at end of file | ||