* Fixed crash at cancelation.
* Simplified class LprSetupDlg using DialogWindow. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33561 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2,6 +2,7 @@ SubDir HAIKU_TOP src add-ons print transports lpr ;
|
|||||||
|
|
||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
|
SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ;
|
||||||
SubDirHdrs [ FDirName $(HAIKU_TOP) src add-ons print transports shared ] ;
|
SubDirHdrs [ FDirName $(HAIKU_TOP) src add-ons print transports shared ] ;
|
||||||
|
|
||||||
Addon LPR :
|
Addon LPR :
|
||||||
@@ -13,7 +14,11 @@ Addon LPR :
|
|||||||
Socket.o
|
Socket.o
|
||||||
SocketStream.o
|
SocketStream.o
|
||||||
DbgMsg.o
|
DbgMsg.o
|
||||||
: be $(TARGET_NETWORK_LIBS) $(TARGET_LIBSTDC++)
|
:
|
||||||
|
be
|
||||||
|
libprint.a
|
||||||
|
$(TARGET_NETWORK_LIBS)
|
||||||
|
$(TARGET_LIBSTDC++)
|
||||||
;
|
;
|
||||||
|
|
||||||
ObjectReferences
|
ObjectReferences
|
||||||
|
|||||||
@@ -146,12 +146,15 @@ LprSetupView::UpdateViewData()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fDir->WriteAttr(LPR_SERVER_NAME, B_STRING_TYPE, 0, fServer->Text(), strlen(fServer->Text()) + 1);
|
fDir->WriteAttr(LPR_SERVER_NAME, B_STRING_TYPE, 0, fServer->Text(),
|
||||||
fDir->WriteAttr(LPR_QUEUE_NAME, B_STRING_TYPE, 0, fQueue->Text(), strlen(fQueue->Text()) + 1);
|
strlen(fServer->Text()) + 1);
|
||||||
|
fDir->WriteAttr(LPR_QUEUE_NAME, B_STRING_TYPE, 0, fQueue->Text(),
|
||||||
|
strlen(fQueue->Text()) + 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BAlert *alert = new BAlert("", "please input parameters.", "OK");
|
BAlert *alert = new BAlert("", "Please enter server address and printer"
|
||||||
|
"queue name.", "OK");
|
||||||
alert->Go();
|
alert->Go();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -159,66 +162,32 @@ LprSetupView::UpdateViewData()
|
|||||||
|
|
||||||
LprSetupDlg::LprSetupDlg(BDirectory *dir)
|
LprSetupDlg::LprSetupDlg(BDirectory *dir)
|
||||||
:
|
:
|
||||||
BWindow(BRect(100, 100, 100 + DLG_WIDTH, 100 + DLG_HEIGHT),
|
DialogWindow(BRect(100, 100, 100 + DLG_WIDTH, 100 + DLG_HEIGHT),
|
||||||
"LPR Setup", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
|
"LPR Setup", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
|
||||||
B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE)
|
B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE)
|
||||||
{
|
{
|
||||||
fResult = 0;
|
fSetupView = new LprSetupView(Bounds(), dir);
|
||||||
|
AddChild(fSetupView);
|
||||||
Lock();
|
|
||||||
LprSetupView *view = new LprSetupView(Bounds(), dir);
|
|
||||||
AddChild(view);
|
|
||||||
Unlock();
|
|
||||||
|
|
||||||
fExitSemaphore = create_sem(0, "lprSetupSem");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
LprSetupDlg::QuitRequested()
|
|
||||||
{
|
|
||||||
fResult = B_ERROR;
|
|
||||||
release_sem(fExitSemaphore);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LprSetupDlg::MessageReceived(BMessage *msg)
|
LprSetupDlg::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
bool success;
|
|
||||||
|
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case M_OK:
|
case M_OK:
|
||||||
Lock();
|
if (fSetupView->UpdateViewData()) {
|
||||||
success = ((LprSetupView *)ChildAt(0))->UpdateViewData();
|
SetResult(B_OK);
|
||||||
Unlock();
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
if (success) {
|
|
||||||
fResult = B_NO_ERROR;
|
|
||||||
release_sem(fExitSemaphore);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M_CANCEL:
|
case M_CANCEL:
|
||||||
fResult = B_ERROR;
|
SetResult(B_ERROR);
|
||||||
release_sem(fExitSemaphore);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(msg);
|
DialogWindow::MessageReceived(msg);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
LprSetupDlg::Go()
|
|
||||||
{
|
|
||||||
Show();
|
|
||||||
acquire_sem(fExitSemaphore);
|
|
||||||
delete_sem(fExitSemaphore);
|
|
||||||
int value = fResult;
|
|
||||||
Lock();
|
|
||||||
Quit();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,19 +6,20 @@
|
|||||||
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
class BDirectory;
|
#include "DialogWindow.h"
|
||||||
|
|
||||||
class LprSetupDlg : public BWindow {
|
class BDirectory;
|
||||||
|
class LprSetupView;
|
||||||
|
|
||||||
|
|
||||||
|
class LprSetupDlg : public DialogWindow {
|
||||||
public:
|
public:
|
||||||
LprSetupDlg(BDirectory *);
|
LprSetupDlg(BDirectory *);
|
||||||
~LprSetupDlg() {}
|
~LprSetupDlg() {}
|
||||||
virtual bool QuitRequested();
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
int Go();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int fResult;
|
LprSetupView* fSetupView;
|
||||||
sem_id fExitSemaphore;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __LprSetupDlg_H
|
#endif // __LprSetupDlg_H
|
||||||
|
|||||||
@@ -76,9 +76,21 @@ LprTransport::LprTransport(BMessage *msg)
|
|||||||
|
|
||||||
|
|
||||||
LprTransport::~LprTransport()
|
LprTransport::~LprTransport()
|
||||||
|
{
|
||||||
|
if (!fError)
|
||||||
|
_SendFile();
|
||||||
|
|
||||||
|
if (fFile[0] != '\0')
|
||||||
|
unlink(fFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LprTransport::_SendFile()
|
||||||
{
|
{
|
||||||
char hostname[128];
|
char hostname[128];
|
||||||
gethostname(hostname, sizeof(hostname));
|
if (gethostname(hostname, sizeof(hostname)) != B_OK)
|
||||||
|
strcpy(hostname, "localhost");
|
||||||
|
|
||||||
ostringstream cfname;
|
ostringstream cfname;
|
||||||
cfname << "cfA" << setw(3) << setfill('0') << fJobId << hostname;
|
cfname << "cfA" << setw(3) << setfill('0') << fJobId << hostname;
|
||||||
@@ -116,8 +128,6 @@ LprTransport::~LprTransport()
|
|||||||
BAlert *alert = new BAlert("", err.what(), "OK");
|
BAlert *alert = new BAlert("", err.what(), "OK");
|
||||||
alert->Go();
|
alert->Go();
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink(fFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public:
|
|||||||
bool fail() const;
|
bool fail() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void _SendFile();
|
||||||
|
|
||||||
char fServer[256];
|
char fServer[256];
|
||||||
char fQueue[256];
|
char fQueue[256];
|
||||||
char fFile[256];
|
char fFile[256];
|
||||||
|
|||||||
Reference in New Issue
Block a user