pans
2016-12-15 87e3ee273b2f84081ac45926be9d8e5be3166eaa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
 
#include <QMessageBox>
 
#include "cnfsparams.h"
#include "publicfuc.h"
 
CNfsParams::CNfsParams(QWidget *parent)
    : QDialog(parent)
{
    ui.setupUi(this);
 
    memset(&m_NFSParams, 0, sizeof(NET_DVR_NFSCFG));
    m_lUserID = -1;
    m_lChannel = 1;
    m_bGetInfo = 0;
 
    QStringList strings;
    strings<<"1"<<"2"<<"3"<<"4"<<"5"<<"6"<<"7"<<"8";
    ui.comboDiskNum->addItems(strings);
 
    connect(ui.comboDiskNum, SIGNAL(activated(int)), this, SLOT(comboChanged (int)));
    connect(ui.btnSave,  SIGNAL(clicked()), this, SLOT(clickSave()));
    connect(ui.btnRefresh,  SIGNAL(clicked()), this, SLOT(clickRefresh()));
}
 
CNfsParams::~CNfsParams()
{
 
}
 
void  CNfsParams::clickSave()
{
    if(m_lUserID < 0)
    {
        return;
    }
    setNFSInfo();
 
}
void  CNfsParams::clickRefresh()
{
    if(m_lUserID < 0)
    {
        return;
    }
    getNFSInfo();
 
}
 
void CNfsParams::on_btnExit_clicked()
{
    close();
}
 
 
void CNfsParams::comboChanged ( int index )
{
    //QMessageBox::information(this, tr("Change!"), tr("Change"));
    if(m_bGetInfo)
    {
        ui.editServerIP->setText(m_NFSParams.struNfsDiskParam[index].sNfsHostIPAddr);
                ui.editFilePath->setText((char *)m_NFSParams.struNfsDiskParam[index].sNfsDirectory);
    }
    else
    {
        QMessageBox::information(this, tr("Please check"), tr("Get params error, please click update"));
    }
}
 
 
void CNfsParams::showEvent ( QShowEvent * event )
{
    //disable warning
    if(event == NULL)
    {
    }
    if(m_lUserID < 0)
    {
        //QMessageBox::information(this, tr("Please login firstly!"), tr("Please login firstly!."));
        return;
    }
    else
    {
        getNFSInfo();
         // ui.comboDiskNum->setCurrentIndex(1);
    }
}
int CNfsParams::getNFSInfo()
{
    //define nfs variable
    DWORD uiReturn;
    int iRet;
 
    iRet = NET_DVR_GetDVRConfig(m_lUserID, NET_DVR_GET_NFSCFG, m_lChannel,  &m_NFSParams, sizeof(NET_DVR_NFSCFG), &uiReturn);
    if(iRet == 0)
    {
        KIT_DisplayErrorInfo("Get NFS", KIT_ERRPR_DIS_TYPE);
        //QMessageBox::information(this, tr("Please check!"), tr(".Get NFS information unsuccessfully!"));
        return HPR_ERROR;
    }
    m_bGetInfo = 1; //get information successfully.
    ui.comboDiskNum->setCurrentIndex(0);
    ui.editServerIP->setText(m_NFSParams.struNfsDiskParam[0].sNfsHostIPAddr);
    ui.editFilePath->setText((char *)m_NFSParams.struNfsDiskParam[0].sNfsDirectory);
 
    return HPR_OK;
}
 
int CNfsParams::setNFSInfo()
{
    int iComboIndex;
    int iRet;
    if(m_bGetInfo == 1)
    {
        iComboIndex = ui.comboDiskNum->currentIndex();
                KIT_editToIP(ui.editServerIP, (BYTE *)m_NFSParams.struNfsDiskParam[iComboIndex].sNfsHostIPAddr, 16);
        KIT_editToStr(ui.editFilePath, m_NFSParams.struNfsDiskParam[iComboIndex].sNfsDirectory, PATHNAME_LEN);
 
        iRet = NET_DVR_SetDVRConfig(m_lUserID, NET_DVR_SET_NFSCFG, m_lChannel,  &m_NFSParams, sizeof(NET_DVR_NFSCFG));
        if(iRet == 0)
        {
             iRet = NET_DVR_GetLastError();
             QMessageBox::information(this, tr("Set NFS fail!"), tr("Set NFS fail. \"%1\"").arg(iRet));
            return HPR_ERROR;
        }
    }
    else
    {
        QMessageBox::information(this, tr("Please check"), tr("Get params error, please click update"));
        return HPR_ERROR;
    }
 
    return HPR_OK;
}
 
int CNfsParams::setUserIDAndChannel(long lUserID, long lChannel)
{
    m_lUserID = lUserID;
    m_lChannel = lChannel;
 
    return HPR_OK;
}