Added the BeServed sources into our repository. They are licensed under the

terms of the MIT license.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25176 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-04-26 11:46:00 +00:00
parent d6e065401f
commit 5b89ed13fd
323 changed files with 60852 additions and 0 deletions

View File

@ -0,0 +1,189 @@
/* blowfish.c */
#include "BlowFish.h"
#include "BlowFishTable.h"
#define N 16
#define noErr 0
#define DATAERROR -1
#define KEYBYTES 8
unsigned long F(blf_ctx *bc, unsigned long x)
{
unsigned long a;
unsigned long b;
unsigned long c;
unsigned long d;
unsigned long y;
d = x & 0x00FF;
x >>= 8;
c = x & 0x00FF;
x >>= 8;
b = x & 0x00FF;
x >>= 8;
a = x & 0x00FF;
y = bc->S[0][a] + bc->S[1][b];
y = y ^ bc->S[2][c];
y = y + bc->S[3][d];
return y;
}
void Blowfish_encipher(blf_ctx *bc, unsigned long *xl, unsigned long *xr)
{
unsigned long Xl;
unsigned long Xr;
unsigned long temp;
short i;
Xl = *xl;
Xr = *xr;
for (i = 0; i < N; ++i)
{
Xl = Xl ^ bc->P[i];
Xr = F(bc, Xl) ^ Xr;
temp = Xl;
Xl = Xr;
Xr = temp;
}
temp = Xl;
Xl = Xr;
Xr = temp;
Xr = Xr ^ bc->P[N];
Xl = Xl ^ bc->P[N + 1];
*xl = Xl;
*xr = Xr;
}
void Blowfish_decipher(blf_ctx *bc, unsigned long *xl, unsigned long *xr)
{
unsigned long Xl;
unsigned long Xr;
unsigned long temp;
short i;
Xl = *xl;
Xr = *xr;
for (i = N + 1; i > 1; --i)
{
Xl = Xl ^ bc->P[i];
Xr = F(bc, Xl) ^ Xr;
/* Exchange Xl and Xr */
temp = Xl;
Xl = Xr;
Xr = temp;
}
/* Exchange Xl and Xr */
temp = Xl;
Xl = Xr;
Xr = temp;
Xr = Xr ^ bc->P[1];
Xl = Xl ^ bc->P[0];
*xl = Xl;
*xr = Xr;
}
short InitializeBlowfish(blf_ctx *bc, unsigned char key[], int keybytes)
{
short i;
short j;
short k;
unsigned long data;
unsigned long datal;
unsigned long datar;
/* initialise p & s-boxes without file read */
for (i = 0; i < N+2; i++)
{
bc->P[i] = bfp[i];
}
for (i = 0; i < 256; i++)
{
bc->S[0][i] = ks0[i];
bc->S[1][i] = ks1[i];
bc->S[2][i] = ks2[i];
bc->S[3][i] = ks3[i];
}
j = 0;
for (i = 0; i < N + 2; ++i)
{
data = 0x00000000;
for (k = 0; k < 4; ++k)
{
data = (data << 8) | key[j];
j = j + 1;
if (j >= keybytes)
{
j = 0;
}
}
bc->P[i] = bc->P[i] ^ data;
}
datal = 0x00000000;
datar = 0x00000000;
for (i = 0; i < N + 2; i += 2)
{
Blowfish_encipher(bc, &datal, &datar);
bc->P[i] = datal;
bc->P[i + 1] = datar;
}
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 256; j += 2)
{
Blowfish_encipher(bc, &datal, &datar);
bc->S[i][j] = datal;
bc->S[i][j + 1] = datar;
}
}
return 0;
}
void blf_key (blf_ctx *c, unsigned char *k, int len)
{
InitializeBlowfish(c, k, len);
}
void blf_enc(blf_ctx *c, unsigned long *data, int blocks)
{
unsigned long *d;
int i;
d = data;
for (i = 0; i < blocks; i++)
{
Blowfish_encipher(c, d, d+1);
d += 2;
}
}
void blf_dec(blf_ctx *c, unsigned long *data, int blocks)
{
unsigned long *d;
int i;
d = data;
for (i = 0; i < blocks; i++)
{
Blowfish_decipher(c, d, d+1);
d += 2;
}
}

View File

@ -0,0 +1,35 @@
/* blowfish.h */
#ifdef _BUILDING_BESURE_
#define _IMPEXP_BESURE __declspec(dllexport)
#else
#define _IMPEXP_BESURE __declspec(dllimport)
#endif
#define UWORD32 unsigned long
#define UBYTE08 unsigned char
#define MAXKEYBYTES 56 /* 448 bits */
typedef struct
{
unsigned long S[4][256], P[18];
} blf_ctx;
unsigned long F(blf_ctx *, unsigned long x);
void Blowfish_encipher(blf_ctx *, unsigned long *xl, unsigned long *xr);
void Blowfish_decipher(blf_ctx *, unsigned long *xl, unsigned long *xr);
short InitializeBlowfish(blf_ctx *, unsigned char key[], int keybytes);
#ifdef __cplusplus
extern "C"
{
#endif
_IMPEXP_BESURE void blf_enc(blf_ctx *c, unsigned long *data, int blocks);
_IMPEXP_BESURE void blf_dec(blf_ctx *c, unsigned long *data, int blocks);
_IMPEXP_BESURE void blf_key(blf_ctx *c, unsigned char *key, int len);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,280 @@
/* bf_tab.h: Blowfish P-box and S-box tables */
static UWORD32 bfp[] =
{
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
0x9216d5d9, 0x8979fb1b,
};
static UWORD32 ks0[] =
{
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a
};
static UWORD32 ks1[]=
{
0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7
};
static UWORD32 ks2[] =
{
0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0
};
static UWORD32 ks3[] =
{
0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
};

View File

@ -0,0 +1,907 @@
#define _BUILDING_BESURE_
#include "FindDirectory.h"
#include "betalk.h"
#include "sysdepdefs.h"
#include "besure_auth.h"
#include "md5.h"
#include "netdb.h"
#include "utime.h"
#include "ctype.h"
#include "time.h"
#include "signal.h"
#include "stdlib.h"
#include "errno.h"
#include "socket.h"
#include "signal.h"
#include "stdio.h"
typedef struct
{
char *key;
char *value;
int valLength;
} key_value;
static uint32 genUniqueId(char *str);
static void strlwr(char *str);
static void removeFiles(char *folder, char *file);
static void recvAlarm(int signal);
static key_value *GetNextKey(FILE *fp);
static void FreeKeyValue(key_value *kv);
static int32 queryServers(void *data);
bool addUserToGroup(char *user, char *group)
{
char userPath[B_PATH_NAME_LENGTH], groupPath[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, userPath, sizeof(userPath));
strcpy(groupPath, userPath);
strcat(userPath, "/domains/default/users/");
strcat(userPath, user);
strcat(groupPath, "/domains/default/groups/");
strcat(groupPath, group);
strcat(groupPath, "/");
strcat(groupPath, user);
strlwr(userPath);
strlwr(groupPath);
if (symlink(userPath, groupPath) == -1)
return false;
return true;
}
bool removeUserFromGroup(char *user, char *group)
{
char userPath[B_PATH_NAME_LENGTH];
strlwr(user);
strlwr(group);
// You can't remove someone from the group "everyone" -- sorry.
if (strcmp(group, "everyone") == 0)
return false;
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, userPath, sizeof(userPath));
strcat(userPath, "/domains/default/groups/");
strcat(userPath, group);
strcat(userPath, "/");
strcat(userPath, user);
remove(userPath);
return true;
}
bool isUserInGroup(char *user, char *group)
{
char userPath[B_PATH_NAME_LENGTH];
strlwr(user);
strlwr(group);
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, userPath, sizeof(userPath));
strcat(userPath, "/domains/default/groups/");
strcat(userPath, group);
strcat(userPath, "/");
strcat(userPath, user);
return (access(userPath, 0) == 0);
}
bool createUser(char *user, char *password)
{
char path[B_PATH_NAME_LENGTH];
uint32 userID;
// All usernames are saved in lowercase.
strlwr(user);
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
// Generate a user ID.
userID = genUniqueId(user);
SetKeyValue(path, "Password", password);
SetKeyInt(path, "Flags", 0);
SetKeyValue(path, "Home", "/boot/home");
SetKeyValue(path, "Group", "everyone");
SetKeyInt(path, "UID", userID);
// fs_write_attr(file, "BEOS:TYPE", B_STRING_TYPE, 0, BT_MIME_USER, strlen(BT_MIME_USER));
// Add the user to the everyone group.
addUserToGroup(user, "everyone");
return true;
}
bool createGroup(char *group)
{
char path[B_PATH_NAME_LENGTH];
uint32 groupID;
// All usernames are saved in lowercase.
strlwr(group);
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/groups/");
strcat(path, group);
// Generate a group ID.
groupID = genUniqueId(group);
if (mkdir(path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) == -1)
return false;
strcat(path, "/.attrib");
SetKeyInt(path, "GID", groupID);
// fs_write_attr(file, "BEOS:TYPE", B_STRING_TYPE, 0, BT_MIME_GROUP, strlen(BT_MIME_GROUP));
return true;
}
bool removeUser(char *user)
{
DIR *dir;
struct dirent *dirInfo;
char path[B_PATH_NAME_LENGTH], groupPath[B_PATH_NAME_LENGTH];
// All usernames are saved in lowercase.
strlwr(user);
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
// Remove the user file.
remove(path);
// Now remove all instances of this user from any groups to which
// it belonged.
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/groups");
// Scan the list of groups. For each group, use removeFiles() to remove
// the user file from the that directory.
dir = opendir(path);
if (dir)
{
while ((dirInfo = readdir(dir)) != NULL)
if (strcmp(dirInfo->d_name, ".") && strcmp(dirInfo->d_name, ".."))
{
sprintf(groupPath, "%s/%s", path, dirInfo->d_name);
removeFiles(groupPath, user);
}
closedir(dir);
}
return true;
}
bool removeGroup(char *group)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/groups/");
strcat(path, group);
strlwr(path);
removeFiles(path, NULL);
remove(path);
return true;
}
bool setUserFullName(char *user, char *fullName)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return SetKeyValue(path, "FullName", fullName);
}
bool setUserDesc(char *user, char *desc)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return SetKeyValue(path, "Description", desc);
}
bool setUserPassword(char *user, char *password)
{
char path[B_PATH_NAME_LENGTH], code[35];
// Encrypt the password using MD5.
md5EncodeString(password, code);
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return SetKeyValue(path, "Password", code);
}
bool setUserFlags(char *user, uint32 flags)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return SetKeyInt(path, "Flags", flags);
}
bool setUserDaysToExpire(char *user, uint32 days)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return SetKeyInt(path, "DaysToExpire", days);
}
bool setUserHome(char *user, char *home)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return SetKeyValue(path, "Home", home);
}
bool setUserGroup(char *user, char *group)
{
char path[B_PATH_NAME_LENGTH];
if (!addUserToGroup(user, group))
return false;
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return SetKeyValue(path, "Group", group);
}
bool setGroupDesc(char *group, char *desc)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/groups/");
strcat(path, group);
strcat(path, "/.attrib");
strlwr(path);
return SetKeyValue(path, "Description", desc);
}
bool getUserFullName(char *user, char *fullName, int bufSize)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return GetKeyValue(path, "FullName", fullName, bufSize);
}
bool getUserDesc(char *user, char *desc, int bufSize)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return GetKeyValue(path, "Description", desc, bufSize);
}
bool getUserPassword(char *user, char *password, int bufSize)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return GetKeyValue(path, "Password", password, bufSize);
}
bool getUserFlags(char *user, uint32 *flags)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return GetKeyInt(path, "Flags", (int *) &flags);
}
bool getUserDaysToExpire(char *user, uint32 *days)
{
char path[B_PATH_NAME_LENGTH];
days = 0;
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return GetKeyInt(path, "DaysToExpire", (int *) &days);
}
bool getUserHome(char *user, char *home, int bufSize)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return GetKeyValue(path, "Home", home, bufSize);
}
bool getUserGroup(char *user, char *group, int bufSize)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users/");
strcat(path, user);
strlwr(path);
return GetKeyValue(path, "Group", group, bufSize);
}
bool getGroupDesc(char *group, char *desc, int bufSize)
{
char path[B_PATH_NAME_LENGTH];
// All usernames are saved in lowercase.
strlwr(group);
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/groups/");
strcat(path, group);
strcat(path, "/.attrib");
return GetKeyValue(path, "Description", desc, bufSize);
}
// strlwr()
//
static void strlwr(char *str)
{
char *p;
for (p = str; *p; p++)
*p = tolower(*p);
}
// genUniqueId()
//
// This function generates a unique number based upon a string. Currently,
// is uses the upper-most byte of a 4-byte integer to contain the length.
// This restricts the length of the supplied string to 256 characters. Then,
// the sum of each character multiplied by its position in the string is
// calculated and occupies the remaining 3 bytes.
//
static uint32 genUniqueId(char *str)
{
char *p;
int i;
uint32 value = 0;
for (p = str, i = 0; *p; p++, i++)
value += i * (int) *p;
value = value | (i << 24);
return value;
}
static void removeFiles(char *folder, char *file)
{
DIR *dir;
struct dirent *dirInfo;
char path[B_PATH_NAME_LENGTH];
// If we've only been given one file, then just delete it.
if (file)
{
sprintf(path, "%s/%s", folder, file);
remove(path);
return;
}
// Otherwise, we need to query all files in the directory and
// remove them.
dir = opendir(folder);
if (dir)
{
while ((dirInfo = readdir(dir)) != NULL)
if (strcmp(dirInfo->d_name, ".") && strcmp(dirInfo->d_name, ".."))
{
sprintf(path, "%s/%s", folder, dirInfo->d_name);
remove(path);
}
closedir(dir);
}
}
// OpenUsers()
//
DIR *OpenUsers()
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/users");
return opendir(path);
}
// ReadUser()
//
dirent_t *ReadUser(DIR *dir)
{
struct dirent *dirInfo;
if (dir)
{
while ((dirInfo = readdir(dir)) != NULL)
if (dirInfo->d_name[0] != '.')
return dirInfo;
}
return NULL;
}
// CloseUsers()
//
void CloseUsers(DIR *dir)
{
if (dir)
closedir(dir);
}
// OpenGroups()
//
DIR *OpenGroups()
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/groups");
return opendir(path);
}
// ReadGroup()
//
dirent_t *ReadGroup(DIR *dir)
{
struct dirent *dirInfo;
if (dir)
{
while ((dirInfo = readdir(dir)) != NULL)
if (dirInfo->d_name[0] != '.')
return dirInfo;
}
return NULL;
}
// CloseGroups()
//
void CloseGroups(DIR *dir)
{
if (dir)
closedir(dir);
}
// OpenGroup()
//
DIR *OpenGroup(char *group)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/groups/");
strcat(path, group);
return opendir(path);
}
// ReadGroupMember()
//
dirent_t *ReadGroupMember(DIR *dir)
{
struct dirent *dirInfo;
if (dir)
{
while ((dirInfo = readdir(dir)) != NULL)
if (dirInfo->d_name[0] != '.')
return dirInfo;
}
return NULL;
}
// CloseGroup()
//
void CloseGroup(DIR *dir)
{
if (dir)
closedir(dir);
}
// isServerRecordingLogins()
//
bool isServerRecordingLogins(char *server)
{
char path[B_PATH_NAME_LENGTH];
char buffer[20];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/servers/");
strcat(path, server);
strlwr(path);
GetKeyValue(path, "RecordLogins", buffer, sizeof(buffer));
return strcasecmp(buffer, "Yes") == 0;
}
// setServerRecordingLogins()
//
bool setServerRecordingLogins(char *server, bool recording)
{
char path[B_PATH_NAME_LENGTH];
find_directory(B_COMMON_SYSTEM_DIRECTORY, 0, false, path, sizeof(path));
strcat(path, "/domains/default/servers/");
strcat(path, server);
strlwr(path);
return SetKeyValue(path, "RecordLogins", recording ? "Yes" : "No");
}
// MakeServerKey()
//
void MakeServerKey(char *server, char *key)
{
struct hostent *ent;
char str[256];
srand(time(NULL));
sprintf(str, "%s-%x-", server, rand() * 0xFFFFFFFF);
ent = gethostbyname(server);
strcat(str, ent ? ent->h_name : "Unknown");
md5EncodeString(str, key);
}
// GetServerList()
//
int GetServerList(recordServerFunc recServ)
{
thread_id queryThread = spawn_thread(queryServers, "Server Query", B_NORMAL_PRIORITY, recServ);
resume_thread(queryThread);
return 0;
}
int32 queryServers(void *data)
{
bt_request request;
recordServerFunc recServ = (recordServerFunc) data;
struct sockaddr_in ourAddr, toAddr, fromAddr;
struct hostent *ent;
char response[256], hostname[B_FILE_NAME_LENGTH];
int sock, addrLen, bytes;
#ifdef SO_BROADCAST
int on = 1;
#endif
memset(&toAddr, 0, sizeof(toAddr));
toAddr.sin_family = AF_INET;
toAddr.sin_port = htons(BT_QUERYHOST_PORT);
toAddr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sock == INVALID_SOCKET)
return -1;
memset(&ourAddr, 0, sizeof(ourAddr));
ourAddr.sin_family = AF_INET;
ourAddr.sin_port = htons(BT_QUERYHOST_PORT);
ourAddr.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(sock, (struct sockaddr *) &ourAddr, sizeof(ourAddr)))
if (errno != EADDRINUSE)
return -1;
// Normally, a setsockopt() call is necessary to turn broadcast mode on
// explicitly, although some versions of Unix don't care. BeOS doesn't
// currently even define SO_BROADCAST, unless you have BONE installed.
#ifdef SO_BROADCAST
if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)) < 0)
{
closesocket(sock);
return -1;
}
#endif
signal(SIGALRM, recvAlarm);
strcpy(request.signature, BT_RPC_SIGNATURE);
request.command = BT_REQ_HOST_PROBE;
if (sendto(sock, (char *) &request, sizeof(request), 0, (struct sockaddr *) &toAddr, sizeof(toAddr)) == -1)
{
closesocket(sock);
return -1;
}
memset(response, 0, sizeof(response));
alarm(3);
while (1)
{
addrLen = sizeof(fromAddr);
bytes = recvfrom(sock, response, sizeof(response) - 1, 0, (struct sockaddr *) &fromAddr, &addrLen);
if (bytes < 0)
{
if (errno == EINTR)
break;
}
if (strncmp(response, BT_RPC_SIGNATURE, strlen(BT_RPC_SIGNATURE)) != 0)
{
struct sockaddr_in *sin = (struct sockaddr_in *) &fromAddr;
ent = gethostbyaddr((char *) &sin->sin_addr, sizeof(sin->sin_addr), AF_INET);
if (ent)
(*recServ)(ent->h_name, *((uint32 *) &sin->sin_addr));
else
{
uint8 *p = (uint8 *) &sin->sin_addr;
sprintf(hostname, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
(*recServ)(hostname, *((uint32 *) &sin->sin_addr));
}
}
}
alarm(0);
signal(SIGALRM, SIG_DFL);
closesocket(sock);
return 0;
}
static void recvAlarm(int signal)
{
return;
}
// ----- Key-Value Implementation ------------------------------------------------
bool GetKeyInt(const char *fileName, const char *key, int *value)
{
char num[50];
*value = 0;
if (GetKeyValue(fileName, key, num, sizeof(num)))
{
*value = atoi(num);
return true;
}
return false;
}
bool GetKeyValue(const char *fileName, const char *key, char *value, int bufSize)
{
FILE *fp;
key_value *kv;
int length;
value[0] = 0;
fp = fopen(fileName, "r");
if (!fp)
return false;
while ((kv = GetNextKey(fp)) != NULL)
if (strcasecmp(kv->key, key) == 0)
{
length = min(bufSize - 1, kv->valLength);
strncpy(value, kv->value, length);
value[length] = 0;
FreeKeyValue(kv);
break;
}
else FreeKeyValue(kv);
fclose(fp);
return (*value != 0);
}
bool SetKeyInt(const char *fileName, const char *key, int value)
{
char num[50];
sprintf(num, "%d", value);
return SetKeyValue(fileName, key, num);
}
bool SetKeyValue(const char *fileName, const char *key, const char *value)
{
key_value *kv[100];
FILE *fp;
int i, j, length;
bool found = false;
i = 0;
found = false;
length = value ? strlen(value) : 0;
fp = fopen(fileName, "r");
if (fp)
{
while ((kv[i] = GetNextKey(fp)) != NULL)
{
if (strcasecmp(kv[i]->key, key) == 0)
{
found = true;
free(kv[i]->value);
kv[i]->value = (char *) malloc(strlen(value) + 1);
if (kv[i]->value)
if (length)
strcpy(kv[i]->value, value);
else
kv[i]->value[0] = 0;
kv[i]->valLength = length;
}
i++;
}
fclose(fp);
}
fp = fopen(fileName, "w");
if (fp)
{
for (j = 0; j < i; j++)
if (kv[j] && kv[j]->value && kv[j]->valLength)
{
fprintf(fp, "%s = %s\n", kv[j]->key, kv[j]->value);
FreeKeyValue(kv[j]);
}
if (!found && length)
fprintf(fp, "%s = %s\n", key, value);
fclose(fp);
}
return true;
}
key_value *GetNextKey(FILE *fp)
{
key_value *kv;
char buffer[4096], key[35], *ch;
int i, length;
if (!fgets(buffer, sizeof(buffer), fp))
return NULL;
// The minimum length for a valid line is one character for the key, plus the
// equal sign, plus one character for the value, or 3 characters.
length = strlen(buffer);
if (length < 3)
return NULL;
// Trim off any linefeed character.
if (buffer[length - 1] == '\n')
buffer[--length] = 0;
// Now skip spaces before the key.
ch = buffer;
while (*ch && (*ch == ' ' || *ch == '\t'))
ch++;
for (i = 0; *ch && *ch != ' ' && *ch != '\t' && *ch != '='; i++, ch++)
if (i < sizeof(key) - 1)
key[i] = *ch;
key[i] = 0;
if (i == 0)
return NULL;
kv = (key_value *) malloc(sizeof(key_value));
if (!kv)
return NULL;
kv->key = (char *) malloc(i + 1);
if (!kv->key)
{
free(kv);
return NULL;
}
strcpy(kv->key, key);
// Skip to the equal sign.
while (*ch && *ch != '=')
ch++;
if (*ch != '=')
{
free(kv->key);
free(kv);
return NULL;
}
ch++;
while (*ch && (*ch == ' ' || *ch == '\t'))
ch++;
kv->valLength = buffer + length - ch;
kv->value = (char *) malloc(kv->valLength + 1);
if (!kv->value)
{
free(kv->key);
free(kv);
return NULL;
}
strcpy(kv->value, ch);
return kv;
}
void FreeKeyValue(key_value *kv)
{
if (kv->key)
free(kv->key);
if (kv->value)
free(kv->value);
free(kv);
}

View File

@ -0,0 +1,75 @@
#ifndef _BESURE_AUTH_H_
#define _BESURE_AUTH_H_
#include <dirent.h>
#define USER_FLAG_DISABLED 0x00000001
#define USER_FLAG_INIT_EXPIRE 0x00000002
#define USER_FLAG_DAYS_EXPIRE 0x00000004
#define USER_FLAG_PW_LOCKED 0x00000008
#ifdef _BUILDING_BESURE_
#define _IMPEXP_BESURE __declspec(dllexport)
#else
#define _IMPEXP_BESURE __declspec(dllimport)
#endif
typedef void (*recordServerFunc)(char *name, uint32 addr);
#ifdef __cplusplus
extern "C"
{
#endif
_IMPEXP_BESURE bool createUser(char *user, char *password);
_IMPEXP_BESURE bool createGroup(char *group);
_IMPEXP_BESURE bool removeUser(char *user);
_IMPEXP_BESURE bool removeGroup(char *group);
_IMPEXP_BESURE bool addUserToGroup(char *user, char *group);
_IMPEXP_BESURE bool removeUserFromGroup(char *user, char *group);
_IMPEXP_BESURE bool isUserInGroup(char *user, char *group);
_IMPEXP_BESURE bool setUserFullName(char *user, char *fullName);
_IMPEXP_BESURE bool setUserDesc(char *user, char *desc);
_IMPEXP_BESURE bool setUserPassword(char *user, char *password);
_IMPEXP_BESURE bool setUserFlags(char *user, uint32 flags);
_IMPEXP_BESURE bool setUserDaysToExpire(char *user, uint32 days);
_IMPEXP_BESURE bool setUserHome(char *user, char *home);
_IMPEXP_BESURE bool setUserGroup(char *user, char *group);
_IMPEXP_BESURE bool setGroupDesc(char *group, char *desc);
_IMPEXP_BESURE bool getUserFullName(char *user, char *fullName, int bufSize);
_IMPEXP_BESURE bool getUserDesc(char *user, char *desc, int bufSize);
_IMPEXP_BESURE bool getUserPassword(char *user, char *password, int bufSize);
_IMPEXP_BESURE bool getUserFlags(char *user, uint32 *flags);
_IMPEXP_BESURE bool getUserDaysToExpire(char *user, uint32 *days);
_IMPEXP_BESURE bool getUserHome(char *user, char *home, int bufSize);
_IMPEXP_BESURE bool getUserGroup(char *user, char *group, int bufSize);
_IMPEXP_BESURE bool getGroupDesc(char *group, char *desc, int bufSize);
_IMPEXP_BESURE bool isServerRecordingLogins(char *server);
_IMPEXP_BESURE bool setServerRecordingLogins(char *server, bool recording);
_IMPEXP_BESURE void MakeServerKey(char *server, char *key);
_IMPEXP_BESURE DIR *OpenUsers();
_IMPEXP_BESURE dirent_t *ReadUser(DIR *dir);
_IMPEXP_BESURE void CloseUsers(DIR *dir);
_IMPEXP_BESURE DIR *OpenGroups();
_IMPEXP_BESURE dirent_t *ReadGroup(DIR *dir);
_IMPEXP_BESURE void CloseGroups(DIR *dir);
_IMPEXP_BESURE DIR *OpenGroup(char *group);
_IMPEXP_BESURE dirent_t *ReadGroupMember(DIR *dir);
_IMPEXP_BESURE void CloseGroup(DIR *dir);
_IMPEXP_BESURE int GetServerList(recordServerFunc recServ);
_IMPEXP_BESURE bool GetKeyValue(const char *fileName, const char *key, char *value, int bufSize);
_IMPEXP_BESURE bool GetKeyInt(const char *fileName, const char *key, int *value);
_IMPEXP_BESURE bool SetKeyValue(const char *fileName, const char *key, const char *value);
_IMPEXP_BESURE bool SetKeyInt(const char *fileName, const char *key, int value);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,252 @@
#ifndef _BETALK_H_
#define _BETALK_H_
// BeOS-specific includes
#include "TypeConstants.h"
#include "Errors.h"
#include "OS.h"
#include "fs_attr.h"
#include "fs_query.h"
#include "fs_index.h"
#include "Mime.h"
#include "netdb.h"
// POSIX includes
#include "stdio.h"
#include "dirent.h"
#include "malloc.h"
#include "string.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "errno.h"
#include "socket.h"
#include "ctype.h"
#ifndef NULL
#define NULL 0L
#endif
#ifndef INVALID_SOCKET
#define INVALID_SOCKET (int)(~0)
#endif
#define BT_TCPIP_PORT 9092
#define BT_QUERYHOST_PORT 9093
#define BT_BESURE_PORT 9094
#define BT_CMD_TERMINATOR 13
#define BT_CMD_PREMOUNT 0
#define BT_CMD_MOUNT 1
#define BT_CMD_FSINFO 2
#define BT_CMD_LOOKUP 3
#define BT_CMD_STAT 4
#define BT_CMD_READDIR 5
#define BT_CMD_READ 6
#define BT_CMD_WRITE 7
#define BT_CMD_CREATE 8
#define BT_CMD_TRUNCATE 9
#define BT_CMD_MKDIR 10
#define BT_CMD_RMDIR 11
#define BT_CMD_RENAME 12
#define BT_CMD_UNLINK 13
#define BT_CMD_READLINK 14
#define BT_CMD_SYMLINK 15
#define BT_CMD_WSTAT 16
#define BT_CMD_READATTRIB 50
#define BT_CMD_WRITEATTRIB 51
#define BT_CMD_READATTRIBDIR 52
#define BT_CMD_REMOVEATTRIB 53
#define BT_CMD_STATATTRIB 54
#define BT_CMD_READINDEXDIR 60
#define BT_CMD_CREATEINDEX 61
#define BT_CMD_REMOVEINDEX 62
#define BT_CMD_STATINDEX 63
#define BT_CMD_READQUERY 70
#define BT_CMD_COMMIT 80
#define BT_CMD_PRINTJOB_NEW 200
#define BT_CMD_PRINTJOB_DATA 201
#define BT_CMD_PRINTJOB_COMMIT 202
#define BT_CMD_AUTHENTICATE 210
#define BT_CMD_QUIT 255
#define BT_CMD_AUTH 1
#define BT_CMD_READUSERS 2
#define BT_CMD_READGROUPS 3
#define BT_CMD_WHICHGROUPS 4
#define BT_REQ_HOST_PROBE 1
#define BT_REQ_SHARE_PROBE 2
#define BT_REQ_HOST_INFO 3
#define BT_REQ_HOST_USERS 4
#define BT_REQ_AUTH_TYPES 5
// The different types of network resources supported by BeServed.
#define BT_SHARED_NULL 0
#define BT_SHARED_FOLDER 1
#define BT_SHARED_PRINTER 2
#define BT_PRINTER_PCL3 0
#define BT_PRINTER_POSTSCRIPT 1
#define BT_PRITNER_INKJET 2
#define BT_AUTH_REQ_CONNECT 1
#define BT_AUTH_REQ_USERS 2
#define BT_AUTH_NONE 0
#define BT_AUTH_BESURE 1
#define BT_RIGHTS_READ 0x00000001
#define BT_RIGHTS_WRITE 0x00000002
#define BT_RIGHTS_PRINT 0x00000004
#define BT_RPC_SIGNATURE "btRPC"
#define BT_RPC_VERSION_HI 0
#define BT_RPC_VERSION_LO 1
#define BT_MAX_IO_BUFFER 32768
#define BT_MAX_ATTR_BUFFER 256
#define BT_RPC_MIN_PACKET_SIZE 128
#define BT_RPC_MAX_PACKET_SIZE (BT_MAX_IO_BUFFER + 1024)
#define BT_TOKEN_SHARE 1
#define BT_TOKEN_AS 2
#define BT_TOKEN_SET 3
#define BT_TOKEN_READ 4
#define BT_TOKEN_WRITE 5
#define BT_TOKEN_READWRITE 6
#define BT_TOKEN_PROMISCUOUS 7
#define BT_TOKEN_ON 8
#define BT_TOKEN_TO 9
#define BT_TOKEN_AUTHENTICATE 10
#define BT_TOKEN_WITH 11
#define BT_TOKEN_GROUP 12
#define BT_TOKEN_PRINTER 13
#define BT_TOKEN_PRINT 14
#define BT_TOKEN_IS 15
#define BT_TOKEN_SPOOLED 16
#define BT_TOKEN_DEVICE 17
#define BT_TOKEN_TYPE 18
#define BT_TOKEN_COMMA 200
#define BT_TOKEN_QUOTE 201
#define BT_TOKEN_STRING 202
#define BT_TOKEN_NUMBER 203
#define BT_TOKEN_ERROR 255
#define isValid(c) ((c)=='.' || (c)=='_' || (c)=='-' || (c)=='/' || (c)=='\\' || (c)==':' || (c)=='&' || (c)=='\'')
#define MAX_COMMAND_ARGS 10
#define MAX_NAME_LENGTH 32
#define MAX_KEY_LENGTH MAX_NAME_LENGTH
#define MAX_USERNAME_LENGTH MAX_NAME_LENGTH
#define MAX_GROUPNAME_LENGTH MAX_NAME_LENGTH
#define BT_AUTH_TOKEN_LENGTH (B_FILE_NAME_LENGTH + MAX_USERNAME_LENGTH)
#define MAX_DESC_LENGTH 64
#define MAX_GROUPS_PER_USER 80
typedef struct
{
char signature[6];
uint8 command;
char share[MAX_NAME_LENGTH + 1];
} bt_request;
typedef struct
{
uint32 type;
uint32 subType;
char name[B_FILE_NAME_LENGTH + 1];
} bt_resource;
typedef struct
{
char system[B_FILE_NAME_LENGTH];
char beServed[B_FILE_NAME_LENGTH];
char platform[B_FILE_NAME_LENGTH];
int cpus;
int connections;
int maxConnections;
} bt_hostinfo;
typedef struct
{
unsigned int blockSize;
unsigned int totalBlocks;
unsigned int freeBlocks;
} bt_fsinfo;
typedef struct
{
unsigned int size;
unsigned int length;
char *buffer;
} bt_outPacket;
typedef struct
{
unsigned int length;
unsigned int offset;
char *buffer;
} bt_inPacket;
typedef struct rpcCall
{
unsigned int nsid;
unsigned int xid;
sem_id sem;
bt_inPacket *inPacket;
bool finished;
struct rpcCall *next;
struct rpcCall *prev;
} bt_rpccall;
typedef struct rpcInfo
{
thread_id rpcThread;
int32 quitXID;
uint32 serverIP;
int32 serverPort;
int s;
} bt_rpcinfo;
#define BT_COOKIE_SIZE 4
typedef struct btCookie
{
char opaque[BT_COOKIE_SIZE];
bt_inPacket inPacket;
bool lpbCache;
bool eof;
} btCookie;
typedef struct btQueryCookie
{
char opaque[BT_COOKIE_SIZE];
char *query;
} btQueryCookie;
// RPC Operations
unsigned char btRPCGetChar(bt_inPacket *packet);
unsigned int btRPCGetInt32(bt_inPacket *packet);
int64 btRPCGetInt64(bt_inPacket *packet);
char * btRPCGetNewString(bt_inPacket *packet);
int btRPCGetString(bt_inPacket *packet, char *buffer, int length);
int btRPCGetStat(bt_inPacket *packet, struct stat *st);
bt_outPacket * btRPCPutHeader(unsigned char command, unsigned char argc, int32 length);
void btRPCPutArg(bt_outPacket *packet, unsigned int type, void *data, int length);
void btRPCPutChar(bt_outPacket *packet, char value);
void btRPCPutInt32(bt_outPacket *packet, int32 value);
void btRPCPutInt64(bt_outPacket *packet, int64 value);
void btRPCPutString(bt_outPacket *packet, char *buffer, int length);
void btRPCPutBinary(bt_outPacket *packet, void *buffer, int length);
void btRPCPutStat(bt_outPacket *packet, struct stat *st);
void btRPCCreateAck(bt_outPacket *packet, unsigned int xid, int error);
void btRPCSendAck(int client, bt_outPacket *packet);
int btRecv(int sock, void *data, int dataLen, int flags);
int btSend(int sock, void *data, int dataLen, int flags);
int btRecvMsg(int sock, void *data, int dataLen, int flags);
int btSendMsg(int sock, void *data, int dataLen, int flags);
#endif

View File

@ -0,0 +1,408 @@
/*
Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
L. Peter Deutsch
ghost@aladdin.com
*/
/*$Id: md5.c $ */
/*
Independent implementation of MD5 (RFC 1321).
This code implements the MD5 Algorithm defined in RFC 1321.
It is derived directly from the text of the RFC and not from the
reference implementation.
The original and principal author of md5.c is L. Peter Deutsch
<ghost@aladdin.com>. Other authors are noted in the change history
that follows (in reverse chronological order):
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5).
1999-05-03 lpd Original version.
*/
#include "stdio.h"
#include "md5.h"
#ifdef TEST
/*
* Compile with -DTEST to create a self-contained executable test program.
* The test program should print out the same values as given in section
* A.5 of RFC 1321, reproduced below.
*/
#include <string.h>
main()
{
static const char *const test[7] = {
"", /*d41d8cd98f00b204e9800998ecf8427e*/
"a", /*0cc175b9c0f1b6a831c399e269772661*/
"abc", /*900150983cd24fb0d6963f7d28e17f72*/
"message digest", /*f96b697d7cb7938d525a2f31aaf161d0*/
"abcdefghijklmnopqrstuvwxyz", /*c3fcd3d76192e4007dfb496cca67e13b*/
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
/*d174ab98d277d9f5a5611c2c9f419d9f*/
"12345678901234567890123456789012345678901234567890123456789012345678901234567890" /*57edf4a22be3c955ac49da2e2107b67a*/
};
int i;
for (i = 0; i < 7; ++i) {
md5_state_t state;
md5_byte_t digest[16];
int di;
md5_init(&state);
md5_append(&state, (const md5_byte_t *)test[i], strlen(test[i]));
md5_finish(&state, digest);
printf("MD5 (\"%s\") = ", test[i]);
for (di = 0; di < 16; ++di)
printf("%02x", digest[di]);
printf("\n");
}
return 0;
}
#endif /* TEST */
/*
* For reference, here is the program that computed the T values.
*/
#if 0
#include <math.h>
main()
{
int i;
for (i = 1; i <= 64; ++i) {
unsigned long v = (unsigned long)(4294967296.0 * fabs(sin((double)i)));
printf("#define T%d 0x%08lx\n", i, v);
}
return 0;
}
#endif
void md5EncodeString(const char *source, char *dest)
{
md5_state_t state;
md5_byte_t digest[16];
int i;
md5_init(&state);
md5_append(&state, (const md5_byte_t *) source, strlen(source));
md5_finish(&state, digest);
for (i = 0; i < 16; i++)
sprintf(dest + (i * 2), "%02x", digest[i]);
}
/*
* End of T computation program.
*/
#define T1 0xd76aa478
#define T2 0xe8c7b756
#define T3 0x242070db
#define T4 0xc1bdceee
#define T5 0xf57c0faf
#define T6 0x4787c62a
#define T7 0xa8304613
#define T8 0xfd469501
#define T9 0x698098d8
#define T10 0x8b44f7af
#define T11 0xffff5bb1
#define T12 0x895cd7be
#define T13 0x6b901122
#define T14 0xfd987193
#define T15 0xa679438e
#define T16 0x49b40821
#define T17 0xf61e2562
#define T18 0xc040b340
#define T19 0x265e5a51
#define T20 0xe9b6c7aa
#define T21 0xd62f105d
#define T22 0x02441453
#define T23 0xd8a1e681
#define T24 0xe7d3fbc8
#define T25 0x21e1cde6
#define T26 0xc33707d6
#define T27 0xf4d50d87
#define T28 0x455a14ed
#define T29 0xa9e3e905
#define T30 0xfcefa3f8
#define T31 0x676f02d9
#define T32 0x8d2a4c8a
#define T33 0xfffa3942
#define T34 0x8771f681
#define T35 0x6d9d6122
#define T36 0xfde5380c
#define T37 0xa4beea44
#define T38 0x4bdecfa9
#define T39 0xf6bb4b60
#define T40 0xbebfbc70
#define T41 0x289b7ec6
#define T42 0xeaa127fa
#define T43 0xd4ef3085
#define T44 0x04881d05
#define T45 0xd9d4d039
#define T46 0xe6db99e5
#define T47 0x1fa27cf8
#define T48 0xc4ac5665
#define T49 0xf4292244
#define T50 0x432aff97
#define T51 0xab9423a7
#define T52 0xfc93a039
#define T53 0x655b59c3
#define T54 0x8f0ccc92
#define T55 0xffeff47d
#define T56 0x85845dd1
#define T57 0x6fa87e4f
#define T58 0xfe2ce6e0
#define T59 0xa3014314
#define T60 0x4e0811a1
#define T61 0xf7537e82
#define T62 0xbd3af235
#define T63 0x2ad7d2bb
#define T64 0xeb86d391
static void
md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
{
md5_word_t
a = pms->abcd[0], b = pms->abcd[1],
c = pms->abcd[2], d = pms->abcd[3];
md5_word_t t;
#ifndef ARCH_IS_BIG_ENDIAN
# define ARCH_IS_BIG_ENDIAN 1 /* slower, default implementation */
#endif
#if ARCH_IS_BIG_ENDIAN
/*
* On big-endian machines, we must arrange the bytes in the right
* order. (This also works on machines of unknown byte order.)
*/
md5_word_t X[16];
const md5_byte_t *xp = data;
int i;
for (i = 0; i < 16; ++i, xp += 4)
X[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
#else /* !ARCH_IS_BIG_ENDIAN */
/*
* On little-endian machines, we can process properly aligned data
* without copying it.
*/
md5_word_t xbuf[16];
const md5_word_t *X;
if (!((data - (const md5_byte_t *)0) & 3)) {
/* data are properly aligned */
X = (const md5_word_t *)data;
} else {
/* not aligned */
memcpy(xbuf, data, 64);
X = xbuf;
}
#endif
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
/* Round 1. */
/* Let [abcd k s i] denote the operation
a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + F(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 0, 7, T1);
SET(d, a, b, c, 1, 12, T2);
SET(c, d, a, b, 2, 17, T3);
SET(b, c, d, a, 3, 22, T4);
SET(a, b, c, d, 4, 7, T5);
SET(d, a, b, c, 5, 12, T6);
SET(c, d, a, b, 6, 17, T7);
SET(b, c, d, a, 7, 22, T8);
SET(a, b, c, d, 8, 7, T9);
SET(d, a, b, c, 9, 12, T10);
SET(c, d, a, b, 10, 17, T11);
SET(b, c, d, a, 11, 22, T12);
SET(a, b, c, d, 12, 7, T13);
SET(d, a, b, c, 13, 12, T14);
SET(c, d, a, b, 14, 17, T15);
SET(b, c, d, a, 15, 22, T16);
#undef SET
/* Round 2. */
/* Let [abcd k s i] denote the operation
a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + G(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 1, 5, T17);
SET(d, a, b, c, 6, 9, T18);
SET(c, d, a, b, 11, 14, T19);
SET(b, c, d, a, 0, 20, T20);
SET(a, b, c, d, 5, 5, T21);
SET(d, a, b, c, 10, 9, T22);
SET(c, d, a, b, 15, 14, T23);
SET(b, c, d, a, 4, 20, T24);
SET(a, b, c, d, 9, 5, T25);
SET(d, a, b, c, 14, 9, T26);
SET(c, d, a, b, 3, 14, T27);
SET(b, c, d, a, 8, 20, T28);
SET(a, b, c, d, 13, 5, T29);
SET(d, a, b, c, 2, 9, T30);
SET(c, d, a, b, 7, 14, T31);
SET(b, c, d, a, 12, 20, T32);
#undef SET
/* Round 3. */
/* Let [abcd k s t] denote the operation
a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define SET(a, b, c, d, k, s, Ti)\
t = a + H(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 5, 4, T33);
SET(d, a, b, c, 8, 11, T34);
SET(c, d, a, b, 11, 16, T35);
SET(b, c, d, a, 14, 23, T36);
SET(a, b, c, d, 1, 4, T37);
SET(d, a, b, c, 4, 11, T38);
SET(c, d, a, b, 7, 16, T39);
SET(b, c, d, a, 10, 23, T40);
SET(a, b, c, d, 13, 4, T41);
SET(d, a, b, c, 0, 11, T42);
SET(c, d, a, b, 3, 16, T43);
SET(b, c, d, a, 6, 23, T44);
SET(a, b, c, d, 9, 4, T45);
SET(d, a, b, c, 12, 11, T46);
SET(c, d, a, b, 15, 16, T47);
SET(b, c, d, a, 2, 23, T48);
#undef SET
/* Round 4. */
/* Let [abcd k s t] denote the operation
a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + I(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 0, 6, T49);
SET(d, a, b, c, 7, 10, T50);
SET(c, d, a, b, 14, 15, T51);
SET(b, c, d, a, 5, 21, T52);
SET(a, b, c, d, 12, 6, T53);
SET(d, a, b, c, 3, 10, T54);
SET(c, d, a, b, 10, 15, T55);
SET(b, c, d, a, 1, 21, T56);
SET(a, b, c, d, 8, 6, T57);
SET(d, a, b, c, 15, 10, T58);
SET(c, d, a, b, 6, 15, T59);
SET(b, c, d, a, 13, 21, T60);
SET(a, b, c, d, 4, 6, T61);
SET(d, a, b, c, 11, 10, T62);
SET(c, d, a, b, 2, 15, T63);
SET(b, c, d, a, 9, 21, T64);
#undef SET
/* Then perform the following additions. (That is increment each
of the four registers by the value it had before this block
was started.) */
pms->abcd[0] += a;
pms->abcd[1] += b;
pms->abcd[2] += c;
pms->abcd[3] += d;
}
void
md5_init(md5_state_t *pms)
{
pms->count[0] = pms->count[1] = 0;
pms->abcd[0] = 0x67452301;
pms->abcd[1] = 0xefcdab89;
pms->abcd[2] = 0x98badcfe;
pms->abcd[3] = 0x10325476;
}
void
md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
{
const md5_byte_t *p = data;
int left = nbytes;
int offset = (pms->count[0] >> 3) & 63;
md5_word_t nbits = (md5_word_t)(nbytes << 3);
if (nbytes <= 0)
return;
/* Update the message length. */
pms->count[1] += nbytes >> 29;
pms->count[0] += nbits;
if (pms->count[0] < nbits)
pms->count[1]++;
/* Process an initial partial block. */
if (offset) {
int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
memcpy(pms->buf + offset, p, copy);
if (offset + copy < 64)
return;
p += copy;
left -= copy;
md5_process(pms, pms->buf);
}
/* Process full blocks. */
for (; left >= 64; p += 64, left -= 64)
md5_process(pms, p);
/* Process a final partial block. */
if (left)
memcpy(pms->buf, p, left);
}
void
md5_finish(md5_state_t *pms, md5_byte_t digest[16])
{
static const md5_byte_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
md5_byte_t data[8];
int i;
/* Save the length before padding. */
for (i = 0; i < 8; ++i)
data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
/* Pad to 56 bytes mod 64. */
md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
md5_append(pms, data, 8);
for (i = 0; i < 16; ++i)
digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
}

View File

@ -0,0 +1,102 @@
/*
Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
L. Peter Deutsch
ghost@aladdin.com
*/
/*$Id: md5.h $ */
/*
Independent implementation of MD5 (RFC 1321).
This code implements the MD5 Algorithm defined in RFC 1321.
It is derived directly from the text of the RFC and not from the
reference implementation.
The original and principal author of md5.h is L. Peter Deutsch
<ghost@aladdin.com>. Other authors are noted in the change history
that follows (in reverse chronological order):
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
added conditionalization for C++ compilation from Martin
Purschke <purschke@bnl.gov>.
1999-05-03 lpd Original version.
*/
#ifndef md5_INCLUDED
# define md5_INCLUDED
/*
* This code has some adaptations for the Ghostscript environment, but it
* will compile and run correctly in any environment with 8-bit chars and
* 32-bit ints. Specifically, it assumes that if the following are
* defined, they have the same meaning as in Ghostscript: P1, P2, P3,
* ARCH_IS_BIG_ENDIAN.
*/
#ifdef _BUILDING_BESURE_
#define _IMPEXP_BESURE __declspec(dllexport)
#else
#define _IMPEXP_BESURE __declspec(dllimport)
#endif
typedef unsigned char md5_byte_t; /* 8-bit byte */
typedef unsigned int md5_word_t; /* 32-bit word */
/* Define the state of the MD5 Algorithm. */
typedef struct md5_state_s {
md5_word_t count[2]; /* message length in bits, lsw first */
md5_word_t abcd[4]; /* digest buffer */
md5_byte_t buf[64]; /* accumulate block */
} md5_state_t;
#ifdef __cplusplus
extern "C"
{
#endif
_IMPEXP_BESURE void md5EncodeString(const char *source, char *dest);
/* Initialize the algorithm. */
#ifdef P1
void md5_init(P1(md5_state_t *pms));
#else
void md5_init(md5_state_t *pms);
#endif
/* Append a string to the message. */
#ifdef P3
void md5_append(P3(md5_state_t *pms, const md5_byte_t *data, int nbytes));
#else
void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
#endif
/* Finish the message and return the digest. */
#ifdef P2
void md5_finish(P2(md5_state_t *pms, md5_byte_t digest[16]));
#else
void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
#endif
#ifdef __cplusplus
} /* end extern "C" */
#endif
#endif /* md5_INCLUDED */

View File

@ -0,0 +1,10 @@
#ifndef _SYSDEPDEFS_H_
#define _SYSDEPDEFS_H_
#ifdef BONE_VERSION
#define closesocket(s) close(s)
#endif
#endif

View File

@ -0,0 +1,246 @@
#include <Application.h>
#include <Resources.h>
#include <Window.h>
#include <Region.h>
#include <Alert.h>
#include <Button.h>
#include "Mime.h"
#include "FindDirectory.h"
#include <string.h>
#include <dirent.h>
#include <stdlib.h>
#include <stdio.h>
#include "ColumnListView.h"
#include "CLVColumn.h"
#include "CLVListItem.h"
#include "CLVEasyItem.h"
#include "NewStrings.h"
#include "ConsoleHeaderView.h"
#include "UserProperties.h"
#include "TreeControl.h"
#include "ListControl.h"
#include "Users.h"
#include "Groups.h"
#include "Servers.h"
#include "Icons.h"
const int32 MSG_ITEM_SELECT = 'ISel';
const int32 MSG_ITEM_INVOKE = 'IInv';
const int32 MSG_LIST_DESELECT = 'CLV0';
// ----- GenericWindow --------------------------------------------
class GenericWindow : public BWindow
{
public:
GenericWindow() :
BWindow(BRect(40, 40, 630, 430), "Domain Management Console", B_DOCUMENT_WINDOW, 0)
{
BRect r = Bounds();
r.bottom = 82;
headerView = new ConsoleHeaderView(r);
AddChild(headerView);
r = Bounds();
r.top = 85;
r.right = 160;
// r.bottom -= B_H_SCROLL_BAR_HEIGHT;
CLVContainerView *treeContView, *listContView;
treeView = new SmartTreeListView(r, &treeContView, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE, B_SINGLE_SELECTION_LIST,
true, true, true, false, B_FANCY_BORDER);
treeView->AddColumn(new CLVColumn(NULL, 20.0, CLV_EXPANDER | CLV_LOCK_AT_BEGINNING | CLV_NOT_MOVABLE, 20.0));
treeView->AddColumn(new CLVColumn(NULL, 16.0, CLV_LOCK_AT_BEGINNING | CLV_NOT_MOVABLE |
CLV_NOT_RESIZABLE | CLV_PUSH_PASS | CLV_MERGE_WITH_RIGHT, 16.0));
treeView->AddColumn(new CLVColumn("Snap-ins", 125.0, CLV_SORT_KEYABLE, 50.0));
treeView->SetSortFunction(TreeItem::MyCompare);
r = Bounds();
r.top = 85;
r.left = 165 + B_V_SCROLL_BAR_WIDTH;
r.right -= B_V_SCROLL_BAR_WIDTH;
listView = new SmartColumnListView(r, &listContView, NULL, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE, B_SINGLE_SELECTION_LIST,
false, true, true, false, B_FANCY_BORDER);
listView->SetSelectionMessage(new BMessage(MSG_ITEM_SELECT));
listView->SetInvocationMessage(new BMessage(MSG_ITEM_INVOKE));
AddTreeItems(treeView);
AddChild(treeContView);
AddChild(listContView);
SetSizeLimits(300, 2000, 150, 2000);
Show();
}
~GenericWindow()
{
be_app->PostMessage(B_QUIT_REQUESTED);
}
// MessageReceived()
//
void MessageReceived(BMessage *msg)
{
TreeItem *treeItem = NULL;
ListItem *listItem = NULL;
int32 curTreeItem = treeView->CurrentSelection();
int32 curListItem = listView->CurrentSelection();
if (curTreeItem >= 0)
treeItem = (TreeItem *) treeView->ItemAt(curTreeItem);
if (curListItem >= 0)
listItem = (ListItem *) listView->ItemAt(curListItem);
switch (msg->what)
{
case MSG_ITEM_INVOKE:
if (listItem)
if (listItem->ItemInvoked())
if (treeItem)
treeItem->ListItemUpdated(curListItem, listItem);
break;
case MSG_ITEM_SELECT:
if (treeItem)
treeItem->ListItemSelected();
if (listItem)
listItem->ItemSelected();
break;
case MSG_LIST_DESELECT:
if (treeItem)
treeItem->ListItemDeselected();
if (listItem)
listItem->ItemDeselected();
break;
// If we get here, this may be a message we don't handle, or it may be one
// that comes from the header view and needs to be processed by the associated
// tree node.
default:
if (treeItem)
if (treeItem->HeaderMessageReceived(msg))
break;
BWindow::MessageReceived(msg);
break;
}
}
void Quit()
{
TreeItem *item;
do
{
item = (TreeItem *) treeView->RemoveItem(int32(0));
if (item)
delete item;
} while(item);
BWindow::Quit();
}
private:
void AddTreeItems(ColumnListView* treeView)
{
treeView->AddItem(new TreeItem(0, true, true, ICON_NETADMIN_SMALL, headerView, listView, "Network Administration"));
treeView->AddItem(new TreeItem(1, true, true, ICON_DOMAIN_SMALL, headerView, listView, "Domains"));
treeView->AddItem(new TreeItem(2, true, true, ICON_DOMAIN_SMALL, headerView, listView, "default"));
treeView->AddItem(new GroupsItem(3, false, false, ICON_GROUP_SMALL, headerView, listView, "Groups"));
treeView->AddItem(new ServersItem(3, false, false, ICON_HOST_SMALL, headerView, listView, "Servers"));
treeView->AddItem(new UsersItem(3, false, false, ICON_USER_SMALL, headerView, listView, "Users"));
treeView->AddItem(new TreeItem(1, false, false, ICON_SERVICES_SMALL, headerView, listView, "Services"));
}
ConsoleHeaderView *headerView;
SmartTreeListView *treeView;
SmartColumnListView *listView;
};
// ----- GenericApp ---------------------------------------------------
class GenericApp : public BApplication
{
public:
GenericApp() : BApplication("application/x-vnd.Teldar-DomainManager")
{
checkMimeTypes();
new GenericWindow;
}
~GenericApp()
{
}
private:
void checkMimeTypes()
{
BMimeType mime;
mime.SetTo("application/x-vnd.BeServed-DomainManager");
if (!mime.IsInstalled())
{
mime.Install();
mime.SetShortDescription("DomainManager");
mime.SetLongDescription("BeServed Domain Management Console 1.2.6");
setMimeIcon(&mime, ICON_BMC_LARGE, B_LARGE_ICON);
setMimeIcon(&mime, ICON_BMC_SMALL, B_MINI_ICON);
}
mime.SetTo("application/x-vnd.Teldar-User");
if (!mime.IsInstalled())
{
mime.Install();
mime.SetShortDescription("User");
mime.SetLongDescription("BeSure User Account");
setMimeIcon(&mime, ICON_USER_LARGE, B_LARGE_ICON);
setMimeIcon(&mime, ICON_USER_SMALL, B_MINI_ICON);
}
mime.SetTo("application/x-vnd.Teldar-Group");
if (!mime.IsInstalled())
{
mime.Install();
mime.SetShortDescription("User Group");
mime.SetLongDescription("BeSure Group Account");
setMimeIcon(&mime, ICON_GROUP_LARGE, B_LARGE_ICON);
setMimeIcon(&mime, ICON_GROUP_SMALL, B_MINI_ICON);
}
}
bool setMimeIcon(BMimeType *mime, int32 resourceID, icon_size which)
{
BMessage archive;
size_t size;
char *bits = (char *) be_app->AppResources()->LoadResource(type_code('BBMP'), resourceID, &size);
if (bits)
if (archive.Unflatten(bits) == B_OK)
{
BBitmap *icon = new BBitmap(&archive);
mime->SetIcon(icon, which);
return true;
}
return false;
}
};
#include "besure_auth.h"
int main()
{
new GenericApp;
be_app->Run();
delete be_app;
}

View File

@ -0,0 +1,60 @@
#include "View.h"
#include "Mime.h"
#include "TypeConstants.h"
#include "Application.h"
#include "InterfaceDefs.h"
#include "Bitmap.h"
#include "TranslationUtils.h"
#include "Alert.h"
#include "Button.h"
#include "Errors.h"
#include "ConsoleHeaderView.h"
// ----- ConsoleHeaderView ---------------------------------------------------------------
ConsoleHeaderView::ConsoleHeaderView(BRect rect)
: BView(rect, "ConsoleHeaderView", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW)
{
rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(gray);
BRect bmpRect(0.0, 0.0, 31.0, 31.0);
icon = new BBitmap(bmpRect, B_CMAP8);
BMimeType mime("application/x-vnd.BeServed-DomainManager");
mime.GetIcon(icon, B_LARGE_ICON);
}
ConsoleHeaderView::~ConsoleHeaderView()
{
}
void ConsoleHeaderView::Draw(BRect rect)
{
BRect r = Bounds();
BRect iconRect(13.0, 5.0, 45.0, 37.0);
rgb_color black = { 0, 0, 0, 255 };
rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(gray);
SetLowColor(gray);
FillRect(r, B_SOLID_LOW);
SetHighColor(black);
SetFont(be_bold_font);
SetFontSize(11);
MovePenTo(55, 15);
DrawString("BeServed Domain Management Console");
SetFont(be_plain_font);
SetFontSize(10);
MovePenTo(55, 28);
DrawString("Version 1.2.6");
MovePenTo(55, 40);
DrawString("");
SetDrawingMode(B_OP_ALPHA);
SetHighColor(0, 0, 0, 180);
SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
DrawBitmap(icon, iconRect);
}

View File

@ -0,0 +1,14 @@
class ConsoleHeaderView : public BView
{
public:
ConsoleHeaderView(BRect rect);
~ConsoleHeaderView();
void Draw(BRect rect);
BButton *openBtn;
BButton *hostBtn;
private:
BBitmap *icon;
};

View File

@ -0,0 +1,127 @@
#include <Application.h>
#include <Resources.h>
#include <Window.h>
#include <Region.h>
#include <Alert.h>
#include "Mime.h"
#include "string.h"
#include "stdio.h"
#include "dirent.h"
#include "sys/stat.h"
#include "ColumnListView.h"
#include "CLVColumn.h"
#include "CLVListItem.h"
#include "CLVEasyItem.h"
#include "NewStrings.h"
#include "TreeControl.h"
#include "ListControl.h"
#include "Explorer.h"
#include "Icons.h"
ExplorerFile::ExplorerFile(BView *headerView, const char *text0, const char *text1, const char *text2) :
ListItem(headerView, text0, text1, text2)
{
BBitmap *icon;
BMessage archive;
size_t size;
char *bits = (char *) be_app->AppResources()->LoadResource(type_code('BBMP'), 101, &size);
if (bits)
if (archive.Unflatten(bits) == B_OK)
{
icon = new BBitmap(&archive);
SetColumnContent(0, icon, 2.0);
SetColumnContent(1, text0);
SetColumnContent(2, text1);
SetColumnContent(3, text2);
}
}
ExplorerFile::~ExplorerFile()
{
}
bool ExplorerFile::ItemInvoked()
{
return false;
}
ExplorerFolder::ExplorerFolder(uint32 level, bool superitem, bool expanded, int32 resourceID, BView *headerView, ColumnListView *treeView, ColumnListView *listView, char *text) :
TreeItem(level, superitem, expanded, resourceID, headerView, listView, text)
{
parentTreeView = treeView;
}
void ExplorerFolder::ItemExpanding()
{
DIR *dir;
struct dirent *dirInfo;
struct stat st;
char path[B_PATH_NAME_LENGTH], qualifiedFile[B_PATH_NAME_LENGTH];
ColumnListView *listView = GetAssociatedList();
BView *headerView = GetAssociatedHeader();
strcpy(path, "/boot/home");
dir = opendir(path);
if (dir)
{
while ((dirInfo = readdir(dir)) != NULL)
if (strcmp(dirInfo->d_name, ".") && strcmp(dirInfo->d_name, ".."))
{
sprintf(qualifiedFile, "%s/%s", path, dirInfo->d_name);
if (stat(qualifiedFile, &st) == 0)
if (S_ISDIR(st.st_mode))
{
BAlert *alert = new BAlert("hello", dirInfo->d_name, "OK");
alert->Go();
parentTreeView->AddItem(new ExplorerFolder(OutlineLevel() + 1, true, false, ICON_HOST_SMALL, headerView, parentTreeView, listView, dirInfo->d_name));
}
}
closedir(dir);
}
}
void ExplorerFolder::ItemSelected()
{
DIR *dir;
struct dirent *dirInfo;
struct stat st;
char path[B_PATH_NAME_LENGTH], qualifiedFile[B_PATH_NAME_LENGTH];
PurgeRows();
PurgeColumns();
ColumnListView *listView = GetAssociatedList();
BView *headerView = GetAssociatedHeader();
listView->AddColumn(new CLVColumn(NULL, 20.0, CLV_LOCK_AT_BEGINNING | CLV_NOT_MOVABLE |
CLV_NOT_RESIZABLE | CLV_PUSH_PASS | CLV_MERGE_WITH_RIGHT));
listView->AddColumn(new CLVColumn("File", 85.0, CLV_SORT_KEYABLE, 50.0));
listView->AddColumn(new CLVColumn("Size", 130.0, CLV_SORT_KEYABLE));
listView->AddColumn(new CLVColumn("Date", 150.0, CLV_SORT_KEYABLE));
strcpy(path, "/boot/home");
dir = opendir(path);
if (dir)
{
while ((dirInfo = readdir(dir)) != NULL)
if (strcmp(dirInfo->d_name, ".") && strcmp(dirInfo->d_name, ".."))
{
sprintf(qualifiedFile, "%s/%s", path, dirInfo->d_name);
if (stat(qualifiedFile, &st) == 0)
if (!S_ISDIR(st.st_mode))
listView->AddItem(new ExplorerFile(headerView, dirInfo->d_name, "", ""));
}
closedir(dir);
}
}

View File

@ -0,0 +1,25 @@
// ----- ExplorerFile ----------------------------------------------------------------------
class ExplorerFile : public ListItem
{
public:
ExplorerFile(BView *headerView, const char *text0, const char *text1, const char *text2);
virtual ~ExplorerFile();
bool ItemInvoked();
};
// ----- ExplorerFolder -----------------------------------------------------
class ExplorerFolder : public TreeItem
{
public:
ExplorerFolder(uint32 level, bool superitem, bool expanded, int32 resourceID, BView *headerView, ColumnListView *treeView, ColumnListView *listView, char *text);
void ItemExpanding();
void ItemSelected();
private:
ColumnListView *parentTreeView;
};

View File

@ -0,0 +1,344 @@
#include "Application.h"
#include "Resources.h"
#include "Window.h"
#include "View.h"
#include "Region.h"
#include "Button.h"
#include "CheckBox.h"
#include "TextControl.h"
#include "Bitmap.h"
#include "Mime.h"
#include "FilePanel.h"
#include "Menu.h"
#include "PopUpMenu.h"
#include "MenuItem.h"
#include "MenuField.h"
#include "String.h"
#include "dirent.h"
#include "ColumnListView.h"
#include "CLVColumn.h"
#include "CLVListItem.h"
#include "CLVEasyItem.h"
#include "NewStrings.h"
#include "ListControl.h"
#include "PickUser.h"
#include "GroupProperties.h"
#include "Icons.h"
#include "besure_auth.h"
const int32 MSG_GROUP_OK = 'GOky';
const int32 MSG_GROUP_CANCEL = 'GCan';
const int32 MSG_GROUP_REFRESH = 'GRef';
const int32 MSG_GROUP_ADD = 'GAdd';
const int32 MSG_GROUP_REMOVE = 'GRem';
const int32 MSG_MEMBER_SELECT = 'MSel';
// ----- MemberItem ------------------------------------------------------------
MemberItem::MemberItem(BView *headerView, const char *text0, const char *text1, const char *text2) :
ListItem(headerView, text0, text1, text2)
{
BBitmap *icon;
BMessage archive;
size_t size;
char *bits = (char *) be_app->AppResources()->LoadResource(type_code('BBMP'), ICON_USER_SMALL, &size);
if (bits)
if (archive.Unflatten(bits) == B_OK)
{
icon = new BBitmap(&archive);
SetAssociatedHeader(headerView);
SetColumnContent(0, icon, 2.0);
SetColumnContent(1, text0);
SetColumnContent(2, text1);
SetColumnContent(3, text2);
}
}
MemberItem::~MemberItem()
{
}
void MemberItem::ItemSelected()
{
GroupPropertiesView *view = (GroupPropertiesView *) GetAssociatedHeader();
view->GetRemoveButton()->SetEnabled(true);
}
void MemberItem::ItemDeselected()
{
GroupPropertiesView *view = (GroupPropertiesView *) GetAssociatedHeader();
view->GetRemoveButton()->SetEnabled(false);
}
// ----- GroupPropertiesView -----------------------------------------------------
GroupPropertiesView::GroupPropertiesView(BRect rect, const char *name) :
BView(rect, "GroupInfoView", B_FOLLOW_ALL, B_WILL_DRAW)
{
newGroup = name == NULL;
strcpy(group, newGroup ? "unknown" : name);
getGroupDesc(group, desc, sizeof(desc));
rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(gray);
BRect bmpRect(0.0, 0.0, 31.0, 31.0);
icon = new BBitmap(bmpRect, B_CMAP8);
BMimeType mime("application/x-vnd.Teldar-Group");
mime.GetIcon(icon, B_LARGE_ICON);
BRect r(10, 52, 200, 72);
editName = new BTextControl(r, "GroupName", "Name:", group, NULL);
editName->SetDivider(70);
editName->SetEnabled(newGroup);
AddChild(editName);
r.Set(10, 77, 250, 97);
editDesc = new BTextControl(r, "Description", "Description:", desc, NULL);
editDesc->SetDivider(70);
AddChild(editDesc);
r.Set(205, 320, 275, 340);
BButton *okBtn = new BButton(r, "OkayBtn", "OK", new BMessage(MSG_GROUP_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
okBtn->MakeDefault(true);
AddChild(okBtn);
r.Set(285, 320, 360, 340);
AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_GROUP_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));
r.Set(285, 125, 360, 145);
AddChild(new BButton(r, "AddUserBtn", "Add", new BMessage(MSG_GROUP_ADD), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));
r.Set(285, 155, 360, 175);
removeBtn = new BButton(r, "RemoveBtn", "Remove", new BMessage(MSG_GROUP_REMOVE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
removeBtn->SetEnabled(false);
AddChild(removeBtn);
// Now add the membership list.
CLVContainerView *listContView;
r.Set(13, 125, 280 - B_V_SCROLL_BAR_WIDTH, 305);
listView = new SmartColumnListView(r, &listContView, NULL, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE, B_SINGLE_SELECTION_LIST,
false, false, true, false, B_FANCY_BORDER);
listView->AddColumn(new CLVColumn(NULL, 20.0, CLV_LOCK_AT_BEGINNING | CLV_NOT_MOVABLE |
CLV_NOT_RESIZABLE | CLV_PUSH_PASS | CLV_MERGE_WITH_RIGHT));
listView->AddColumn(new CLVColumn("User", 85.0, CLV_SORT_KEYABLE, 50.0));
listView->AddColumn(new CLVColumn("Full Name", 130.0, CLV_SORT_KEYABLE));
listView->SetSelectionMessage(new BMessage(MSG_MEMBER_SELECT));
listView->SetInvocationMessage(new BMessage(MSG_LIST_DESELECT));
AddGroupMembers(listView);
AddChild(listContView);
}
GroupPropertiesView::~GroupPropertiesView()
{
}
void GroupPropertiesView::Draw(BRect rect)
{
BRect r = Bounds();
BRect iconRect(13.0, 5.0, 45.0, 37.0);
rgb_color black = { 0, 0, 0, 255 };
rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(gray);
SetLowColor(gray);
FillRect(r, B_SOLID_LOW);
SetHighColor(black);
SetFont(be_bold_font);
SetFontSize(11);
MovePenTo(55, 15);
BString string(group);
string += " Properties";
DrawString(string.String());
SetFont(be_plain_font);
SetFontSize(10);
MovePenTo(55, 28);
DrawString("Groups are collections of users that will share certain properties,");
MovePenTo(55, 40);
DrawString("such as access to files or network resources.");
MovePenTo(13, 121);
DrawString("Current Members:");
SetDrawingMode(B_OP_ALPHA);
SetHighColor(0, 0, 0, 180);
SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
DrawBitmap(icon, iconRect);
}
void GroupPropertiesView::UpdateInfo()
{
if (newGroup)
strcpy(group, editName->Text());
strcpy(desc, editDesc->Text());
}
void GroupPropertiesView::AddGroupMembers(ColumnListView* listView)
{
DIR *groupList;
struct dirent *member;
groupList = OpenGroup(group);
if (groupList)
{
while ((member = ReadGroupMember(groupList)) != NULL)
{
char desc[64];
getUserFullName(member->d_name, desc, sizeof(desc));
listView->AddItem(new MemberItem(this, member->d_name, desc, ""));
}
CloseGroup(groupList);
}
}
char *GroupPropertiesView::GetSelectedMember()
{
if (listView)
{
int index = listView->CurrentSelection();
if (index >= 0)
{
MemberItem *item = (MemberItem *) listView->ItemAt(index);
return ((char *) item->GetColumnContentText(1));
}
}
return NULL;
}
void GroupPropertiesView::ItemSelected()
{
removeBtn->SetEnabled(true);
}
void GroupPropertiesView::ItemDeselected()
{
removeBtn->SetEnabled(false);
}
void GroupPropertiesView::AddNewMember(char *user)
{
char desc[64];
addUserToGroup(user, group);
getUserFullName(user, desc, sizeof(desc));
listView->LockLooper();
listView->AddItem(new MemberItem(this, user, desc, ""));
listView->UnlockLooper();
}
void GroupPropertiesView::RemoveSelectedMember()
{
int index = listView->CurrentSelection();
if (index >= 0)
{
MemberItem *item = (MemberItem *) listView->ItemAt(index);
if (item)
{
removeUserFromGroup((char *) item->GetColumnContentText(1), group);
listView->LockLooper();
listView->RemoveItem(item);
listView->UnlockLooper();
}
}
}
// ----- GroupPropertiesPanel ----------------------------------------------------------------------
GroupPropertiesPanel::GroupPropertiesPanel(BRect frame, const char *name, BWindow *parent) :
BWindow(frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
{
newGroup = name == NULL;
if (!newGroup)
strcpy(group, name);
shareWin = parent;
cancelled = true;
BRect r = Bounds();
infoView = new GroupPropertiesView(r, name == NULL ? NULL : group);
AddChild(infoView);
Show();
}
// MessageReceived()
//
void GroupPropertiesPanel::MessageReceived(BMessage *msg)
{
PickUserPanel *picker;
BRect frame;
status_t result;
char *user;
switch (msg->what)
{
case MSG_GROUP_OK:
// relay = new BMessage(MSG_GROUP_REFRESH);
// relay->AddInt32("share", share);
// shareWin->PostMessage(relay);
cancelled = false;
infoView->UpdateInfo();
if (newGroup)
{
strcpy(group, infoView->getGroup());
createGroup(group);
}
strcpy(desc, infoView->getDesc());
setGroupDesc(group, desc);
BWindow::Quit();
break;
case MSG_GROUP_CANCEL:
cancelled = true;
BWindow::Quit();
break;
case MSG_MEMBER_SELECT:
infoView->ItemSelected();
break;
case (int32) 'CLV0': //MSG_LIST_DESELECT:
infoView->ItemDeselected();
break;
case MSG_GROUP_ADD:
frame = Frame();
frame.left += 100;
frame.top += 25;
frame.right = frame.left + 285;
frame.bottom = frame.top + 340;
picker = new PickUserPanel(frame, group);
wait_for_thread(picker->Thread(), &result);
user = picker->GetUser();
if (user)
infoView->AddNewMember(user);
break;
case MSG_GROUP_REMOVE:
infoView->RemoveSelectedMember();
break;
default:
BWindow::MessageReceived(msg);
break;
}
}

View File

@ -0,0 +1,32 @@
GroupProperties.o : \
/boot/home/BeServed/source/BeManager/GroupProperties.cpp \
/boot/develop/headers/be/app/Application.h \
/boot/develop/headers/be/storage/Resources.h \
/boot/develop/headers/be/interface/Window.h \
/boot/develop/headers/be/interface/View.h \
/boot/develop/headers/be/interface/Region.h \
/boot/develop/headers/be/interface/Button.h \
/boot/develop/headers/be/interface/CheckBox.h \
/boot/develop/headers/be/interface/TextControl.h \
/boot/develop/headers/be/interface/Bitmap.h \
/boot/develop/headers/be/storage/Mime.h \
/boot/develop/headers/be/storage/FilePanel.h \
/boot/develop/headers/be/interface/Menu.h \
/boot/develop/headers/be/interface/PopUpMenu.h \
/boot/develop/headers/be/interface/MenuItem.h \
/boot/develop/headers/be/interface/MenuField.h \
/boot/develop/headers/be/support/String.h \
/boot/home/dev/Santas\ gift\ bag/ColumnListView/ColumnListView.h \
/boot/home/dev/Santas\ gift\ bag/Colors.h \
/boot/home/dev/Santas\ gift\ bag/ColumnListView/CLVColumn.h \
/boot/home/dev/Santas\ gift\ bag/PrefilledBitmap/PrefilledBitmap.h \
/boot/home/dev/Santas\ gift\ bag/BetterScrollView/BetterScrollView.h \
/boot/home/dev/Santas\ gift\ bag/ScrollViewCorner/ScrollViewCorner.h \
/boot/home/dev/Santas\ gift\ bag/ColumnListView/CLVListItem.h \
/boot/home/dev/Santas\ gift\ bag/ColumnListView/CLVEasyItem.h \
/boot/home/dev/Santas\ gift\ bag/NewStrings/NewStrings.h \
/boot/home/BeServed/source/BeManager/ListControl.h \
/boot/home/BeServed/source/BeManager/PickUser.h \
/boot/home/BeServed/source/BeManager/GroupProperties.h \
/boot/home/BeServed/source/BeManager/Icons.h \
/boot/home/BeServed/source/BeManager/besure_auth.h

View File

@ -0,0 +1,64 @@
// ----- MemberItem ----------------------------------------------------------------------
class MemberItem : public ListItem
{
public:
MemberItem(BView *headerView, const char *text0, const char *text1, const char *text2);
~MemberItem();
void ItemSelected();
void ItemDeselected();
};
class GroupPropertiesView : public BView
{
public:
GroupPropertiesView(BRect rect, const char *name);
~GroupPropertiesView();
void Draw(BRect rect);
void UpdateInfo();
char *GetSelectedMember();
void ItemSelected();
void ItemDeselected();
void AddNewMember(char *user);
void RemoveSelectedMember();
BButton *GetRemoveButton() { return removeBtn; }
char *getGroup() { return group; }
char *getDesc() { return desc; }
private:
void AddGroupMembers(ColumnListView* listView);
BBitmap *icon;
BTextControl *editName;
BTextControl *editDesc;
SmartColumnListView *listView;
BButton *removeBtn;
char group[33];
char desc[64];
bool newGroup;
};
class GroupPropertiesPanel : public BWindow
{
public:
GroupPropertiesPanel(BRect frame, const char *name, BWindow *parent);
void MessageReceived(BMessage *msg);
char *getGroup() { return group; }
char *getDesc() { return desc; }
bool isCancelled() { return cancelled; }
private:
GroupPropertiesView *infoView;
BWindow *shareWin;
char group[33];
char desc[64];
bool newGroup;
bool cancelled;
};

View File

@ -0,0 +1,222 @@
#include "Application.h"
#include "Resources.h"
#include "Window.h"
#include "View.h"
#include "Region.h"
#include "Alert.h"
#include "Button.h"
#include "FindDirectory.h"
#include "Mime.h"
#include "string.h"
#include "dirent.h"
#include "ColumnListView.h"
#include "CLVColumn.h"
#include "CLVListItem.h"
#include "CLVEasyItem.h"
#include "NewStrings.h"
#include "TreeControl.h"
#include "ListControl.h"
#include "Groups.h"
#include "GroupProperties.h"
#include "Icons.h"
#include "besure_auth.h"
#define WARN_REMOVE_GROUP "Removing this group may prevent access to network resources and may permanently relinquish any rights held by users not specifically granted access by user account or via membership in another group. Are you sure you want to remove this group?"
const int32 MSG_GROUP_NEW = 'GNew';
const int32 MSG_GROUP_EDIT = 'GEdt';
const int32 MSG_GROUP_GONE = 'GGon';
GroupItem::GroupItem(BView *headerView, ColumnListView *listView, const char *text0, const char *text1) :
ListItem(headerView, text0, text1, "")
{
BBitmap *icon;
BMessage archive;
size_t size;
list = listView;
char *bits = (char *) be_app->AppResources()->LoadResource(type_code('BBMP'), ICON_GROUP_SMALL, &size);
if (bits)
if (archive.Unflatten(bits) == B_OK)
{
icon = new BBitmap(&archive);
SetColumnContent(0, icon, 2.0);
SetColumnContent(1, text0);
SetColumnContent(2, text1);
}
}
GroupItem::~GroupItem()
{
}
bool GroupItem::ItemInvoked()
{
BRect r;
BRect frame = GetAssociatedHeader()->Window()->Frame();
status_t exitStatus;
r.Set(frame.left + 150, frame.top + 25, frame.left + 520, frame.top + 375); // 370 x 350
GroupPropertiesPanel *info = new GroupPropertiesPanel(r, GetColumnContentText(1), NULL);
wait_for_thread(info->Thread(), &exitStatus);
return (!info->isCancelled());
}
void GroupItem::ItemSelected()
{
}
void GroupItem::ItemDeselected()
{
}
void GroupItem::ItemDeleted()
{
removeGroup((char *) GetColumnContentText(1));
}
bool GroupItem::IsDeleteable()
{
BAlert *alert = new BAlert("Remove Group?", WARN_REMOVE_GROUP, "Yes", "No");
alert->SetShortcut(1, B_ESCAPE);
alert->SetShortcut(0, 'y');
alert->SetShortcut(1, 'n');
return (alert->Go() == 0);
}
GroupsItem::GroupsItem(uint32 level, bool superitem, bool expanded, int32 resourceID, BView *headerView, ColumnListView *listView, char *text) :
TreeItem(level, superitem, expanded, resourceID, headerView, listView, text)
{
}
void GroupsItem::ItemSelected()
{
DIR *dir;
struct dirent *dirInfo;
ColumnListView *listView;
BView *headerView;
PurgeRows();
PurgeColumns();
PurgeHeader();
BuildHeader();
listView = GetAssociatedList();
headerView = GetAssociatedHeader();
listView->AddColumn(new CLVColumn(NULL, 20.0, CLV_LOCK_AT_BEGINNING | CLV_NOT_MOVABLE |
CLV_NOT_RESIZABLE | CLV_PUSH_PASS | CLV_MERGE_WITH_RIGHT));
listView->AddColumn(new CLVColumn("Group", 85.0, CLV_SORT_KEYABLE, 50.0));
listView->AddColumn(new CLVColumn("Description", 150.0, CLV_SORT_KEYABLE));
dir = OpenGroups();
if (dir)
{
while ((dirInfo = ReadGroup(dir)) != NULL)
{
char desc[64];
getGroupDesc(dirInfo->d_name, desc, sizeof(desc));
listView->AddItem(new GroupItem(headerView, listView, dirInfo->d_name, desc));
}
CloseGroups(dir);
}
}
void GroupsItem::ListItemSelected()
{
btnEdit->SetEnabled(true);
btnRemove->SetEnabled(true);
}
void GroupsItem::ListItemDeselected()
{
btnEdit->SetEnabled(false);
btnRemove->SetEnabled(false);
}
void GroupsItem::ListItemUpdated(int index, ListItem *item)
{
ColumnListView *list = GetAssociatedList();
char desc[64];
getGroupDesc((char *) item->GetColumnContentText(1), desc, sizeof(desc));
list->LockLooper();
item->SetColumnContent(2, desc);
list->InvalidateItem(index);
list->UnlockLooper();
}
void GroupsItem::BuildHeader()
{
BRect r;
BView *headerView = GetAssociatedHeader();
if (headerView)
{
r.Set(10, 55, 90, 75);
headerView->AddChild(new BButton(r, "AddUserBtn", "Add Group", new BMessage(MSG_GROUP_NEW)));
r.Set(100, 55, 180, 75);
btnEdit = new BButton(r, "EditUserBtn", "Edit Group", new BMessage(MSG_GROUP_EDIT));
btnEdit->SetEnabled(false);
headerView->AddChild(btnEdit);
r.Set(190, 55, 280, 75);
btnRemove = new BButton(r, "RemoveUserBtn", "Remove Group", new BMessage(MSG_GROUP_GONE));
btnRemove->SetEnabled(false);
headerView->AddChild(btnRemove);
}
}
bool GroupsItem::HeaderMessageReceived(BMessage *msg)
{
GroupPropertiesPanel *info;
status_t exitStatus;
BRect r;
BRect frame = GetAssociatedHeader()->Window()->Frame();
r.Set(frame.left + 150, frame.top + 25, frame.left + 520, frame.top + 375);
SmartColumnListView *listView = (SmartColumnListView *) GetAssociatedList();
GroupItem *item = NULL;
int index = listView->CurrentSelection();
if (index >= 0)
item = (GroupItem *) listView->ItemAt(index);
switch (msg->what)
{
case MSG_GROUP_NEW:
info = new GroupPropertiesPanel(r, NULL, NULL);
wait_for_thread(info->Thread(), &exitStatus);
if (!info->isCancelled())
{
listView->LockLooper();
listView->AddItem(new GroupItem(GetAssociatedHeader(), listView, info->getGroup(), info->getDesc()));
listView->UnlockLooper();
}
break;
case MSG_GROUP_EDIT:
if (item)
if (item->ItemInvoked())
ListItemUpdated(index, item);
break;
case MSG_GROUP_GONE:
if (item)
listView->DeleteItem(index, item);
break;
default:
return false;
}
return false;
}

View File

@ -0,0 +1,27 @@
Groups.o : /boot/home/BeServed/source/BeManager/Groups.cpp \
/boot/develop/headers/be/app/Application.h \
/boot/develop/headers/be/storage/Resources.h \
/boot/develop/headers/be/interface/Window.h \
/boot/develop/headers/be/interface/View.h \
/boot/develop/headers/be/interface/Region.h \
/boot/develop/headers/be/interface/Alert.h \
/boot/develop/headers/be/interface/Button.h \
/boot/develop/headers/be/storage/FindDirectory.h \
/boot/develop/headers/be/storage/Mime.h \
/boot/develop/headers/posix/string.h \
/boot/develop/headers/posix/dirent.h \
/boot/home/dev/Santas\ gift\ bag/ColumnListView/ColumnListView.h \
/boot/home/dev/Santas\ gift\ bag/Colors.h \
/boot/home/dev/Santas\ gift\ bag/ColumnListView/CLVColumn.h \
/boot/home/dev/Santas\ gift\ bag/PrefilledBitmap/PrefilledBitmap.h \
/boot/home/dev/Santas\ gift\ bag/BetterScrollView/BetterScrollView.h \
/boot/home/dev/Santas\ gift\ bag/ScrollViewCorner/ScrollViewCorner.h \
/boot/home/dev/Santas\ gift\ bag/ColumnListView/CLVListItem.h \
/boot/home/dev/Santas\ gift\ bag/ColumnListView/CLVEasyItem.h \
/boot/home/dev/Santas\ gift\ bag/NewStrings/NewStrings.h \
/boot/home/BeServed/source/BeManager/TreeControl.h \
/boot/home/BeServed/source/BeManager/ListControl.h \
/boot/home/BeServed/source/BeManager/Groups.h \
/boot/home/BeServed/source/BeManager/GroupProperties.h \
/boot/home/BeServed/source/BeManager/Icons.h \
/boot/home/BeServed/source/BeManager/besure_auth.h

View File

@ -0,0 +1,38 @@
// ----- GroupItem ----------------------------------------------------------------------
class GroupItem : public ListItem
{
public:
GroupItem(BView *headerView, ColumnListView *listView, const char *text0, const char *text1);
~GroupItem();
bool ItemInvoked();
void ItemSelected();
void ItemDeselected();
void ItemDeleted();
bool IsDeleteable();
private:
ColumnListView *list;
};
// ----- GroupsItem -----------------------------------------------------
class GroupsItem : public TreeItem
{
public:
GroupsItem(uint32 level, bool superitem, bool expanded, int32 resourceID, BView *headerView, ColumnListView *listView, char *text);
void ItemSelected();
void ListItemSelected();
void ListItemDeselected();
void ListItemUpdated(int index, ListItem *item);
bool HeaderMessageReceived(BMessage *msg);
private:
void BuildHeader();
BButton *btnEdit;
BButton *btnRemove;
};

View File

@ -0,0 +1,18 @@
#define ICON_HOST_LARGE 101
#define ICON_SHARE_LARGE 102
#define ICON_HOST_SMALL 103
#define ICON_SHARE_SMALL 104
#define ICON_INETHOST_LARGE 105
#define ICON_INETHOST_SMALL 106
#define ICON_NETADMIN_LARGE 107
#define ICON_NETADMIN_SMALL 108
#define ICON_DOMAIN_LARGE 109
#define ICON_DOMAIN_SMALL 110
#define ICON_USER_LARGE 111
#define ICON_USER_SMALL 112
#define ICON_BMC_LARGE 113
#define ICON_BMC_SMALL 114
#define ICON_GROUP_LARGE 115
#define ICON_GROUP_SMALL 116
#define ICON_SERVICES_LARGE 117
#define ICON_SERVICES_SMALL 118

View File

@ -0,0 +1,115 @@
#include <Application.h>
#include <Resources.h>
#include <Window.h>
#include <Region.h>
#include <Alert.h>
#include "Mime.h"
#include "string.h"
#include "ColumnListView.h"
#include "CLVColumn.h"
#include "CLVListItem.h"
#include "CLVEasyItem.h"
#include "NewStrings.h"
#include "ListControl.h"
//static rgb_color active = { 155, 155, 255, 255 };
//static rgb_color inactive = { 220, 220, 220, 255 };
ListItem::ListItem(BView *headerView, const char *text0, const char *text1, const char *text2) :
CLVEasyItem(0, false, false, 20.0)
{
SetAssociatedHeader(headerView);
SetColumnContent(1, text0);
SetColumnContent(2, text1);
SetColumnContent(3, text2);
}
ListItem::~ListItem()
{
}
bool ListItem::ItemInvoked()
{
return false;
}
void ListItem::ItemSelected()
{
}
void ListItem::ItemDeselected()
{
}
void ListItem::ItemDeleted()
{
}
bool ListItem::IsDeleteable()
{
return false;
}
// ----- SmartColumnListView ----------------------------------------------------------------
SmartColumnListView::SmartColumnListView(BRect Frame, CLVContainerView** ContainerView,
const char *Name, uint32 ResizingMode, uint32 flags, list_view_type Type,
bool hierarchical, bool horizontal, bool vertical, bool scroll_view_corner,
border_style border, const BFont* LabelFont) :
ColumnListView(Frame, ContainerView, Name, ResizingMode, flags, Type, hierarchical,
horizontal, vertical, scroll_view_corner, border, LabelFont)
{
container = *ContainerView;
// SetItemSelectColor(true, active);
// SetItemSelectColor(false, inactive);
}
SmartColumnListView::~SmartColumnListView()
{
}
void SmartColumnListView::MouseDown(BPoint point)
{
ColumnListView::MouseDown(point);
if (CurrentSelection() < 0)
container->Window()->PostMessage(MSG_LIST_DESELECT);
}
void SmartColumnListView::KeyUp(const char *bytes, int32 numBytes)
{
if (*bytes == B_DELETE)
{
int index = CurrentSelection();
if (index >= 0)
{
ListItem *item = (ListItem *) ItemAt(index);
DeleteItem(index, item);
}
}
}
bool SmartColumnListView::DeleteItem(int index, ListItem *item)
{
if (!item->IsDeleteable())
return true;
LockLooper();
RemoveItem(index);
UnlockLooper();
item->ItemDeleted();
if (CountItems() > 0)
{
Select(max(--index, 0));
return true;
}
return false;
}

View File

@ -0,0 +1,50 @@
#ifndef max
#define max(a,b) ((a)>=(b)?(a):(b))
#endif
class ListItem : public CLVEasyItem
{
public:
ListItem(BView *headerView, const char *text0, const char *text1, const char *text2);
~ListItem();
BView *GetAssociatedHeader() { return assocHeaderView; }
void SetAssociatedHeader(BView *header) { assocHeaderView = header; }
virtual bool ItemInvoked();
virtual void ItemSelected();
virtual void ItemDeselected();
virtual void ItemDeleted();
virtual bool IsDeleteable();
private:
BView *assocHeaderView;
};
class SmartColumnListView : public ColumnListView
{
public:
SmartColumnListView(BRect Frame, CLVContainerView** ContainerView,
const char* Name = NULL, uint32 ResizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE,
list_view_type Type = B_SINGLE_SELECTION_LIST,
bool hierarchical = false, bool horizontal = true, bool vertical = true,
bool scroll_view_corner = true, border_style border = B_NO_BORDER,
const BFont* LabelFont = be_plain_font);
virtual ~SmartColumnListView();
// Event handlers (what makes it "smart").
void MouseDown(BPoint point);
void KeyUp(const char *bytes, int32 numBytes);
// Helper functions.
bool DeleteItem(int index, ListItem *item);
private:
CLVContainerView *container;
};
extern const int32 MSG_LIST_DESELECT;

View File

@ -0,0 +1,232 @@
#include "Application.h"
#include "Resources.h"
#include "Window.h"
#include "View.h"
#include "Region.h"
#include "Button.h"
#include "CheckBox.h"
#include "TextControl.h"
#include "Bitmap.h"
#include "Mime.h"
#include "FilePanel.h"
#include "Menu.h"
#include "PopUpMenu.h"
#include "MenuItem.h"
#include "MenuField.h"
#include "String.h"
#include "dirent.h"
#include "ColumnListView.h"
#include "CLVColumn.h"
#include "CLVListItem.h"
#include "CLVEasyItem.h"
#include "NewStrings.h"
#include "ListControl.h"
#include "GroupProperties.h"
#include "PickUser.h"
#include "Icons.h"
#include "besure_auth.h"
const int32 MSG_PICKUSER_OK = 'GOky';
const int32 MSG_PICKUSER_CANCEL = 'GCan';
const int32 MSG_PICKUSER_SELECT = 'MSel';
// ----- PickUserItem ------------------------------------------------------------
PickUserItem::PickUserItem(BView *headerView, const char *text0, const char *text1) :
ListItem(headerView, text0, text1, "")
{
BBitmap *icon;
BMessage archive;
size_t size;
char *bits = (char *) be_app->AppResources()->LoadResource(type_code('BBMP'), ICON_USER_SMALL, &size);
if (bits)
if (archive.Unflatten(bits) == B_OK)
{
icon = new BBitmap(&archive);
SetAssociatedHeader(headerView);
SetColumnContent(0, icon, 2.0);
SetColumnContent(1, text0);
SetColumnContent(2, text1);
}
}
PickUserItem::~PickUserItem()
{
}
void PickUserItem::ItemSelected()
{
}
void PickUserItem::ItemDeselected()
{
}
// ----- PickUserView -----------------------------------------------------
PickUserView::PickUserView(BRect rect, char *group) :
BView(rect, "PickUserView", B_FOLLOW_ALL, B_WILL_DRAW)
{
strcpy(excludedGroup, group);
rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(gray);
BRect r;
r.Set(125, 310, 195, 330);
okBtn = new BButton(r, "OkayBtn", "OK", new BMessage(MSG_PICKUSER_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
okBtn->MakeDefault(true);
AddChild(okBtn);
r.Set(205, 310, 275, 330);
AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_PICKUSER_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));
// Now add the membership list.
CLVContainerView *listContView;
r.Set(13, 48, 275 - B_V_SCROLL_BAR_WIDTH, 300);
listView = new SmartColumnListView(r, &listContView, NULL, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE, B_SINGLE_SELECTION_LIST,
false, false, true, false, B_FANCY_BORDER);
listView->AddColumn(new CLVColumn(NULL, 20.0, CLV_LOCK_AT_BEGINNING | CLV_NOT_MOVABLE |
CLV_NOT_RESIZABLE | CLV_PUSH_PASS | CLV_MERGE_WITH_RIGHT));
listView->AddColumn(new CLVColumn("User", 85.0, CLV_SORT_KEYABLE, 50.0));
listView->AddColumn(new CLVColumn("Full Name", 130.0, CLV_SORT_KEYABLE));
listView->SetSelectionMessage(new BMessage(MSG_PICKUSER_SELECT));
listView->SetInvocationMessage(new BMessage(MSG_LIST_DESELECT));
AddUserList(listView);
AddChild(listContView);
}
PickUserView::~PickUserView()
{
}
void PickUserView::Draw(BRect rect)
{
BRect r = Bounds();
rgb_color black = { 0, 0, 0, 255 };
rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(gray);
SetLowColor(gray);
FillRect(r, B_SOLID_LOW);
SetHighColor(black);
SetFont(be_plain_font);
SetFontSize(10);
MovePenTo(10, 12);
DrawString("Select a user from the list below, then click the OK button.");
MovePenTo(10, 24);
DrawString("Click the Cancel button to abort the selection.");
MovePenTo(13, 43);
DrawString("Users:");
}
void PickUserView::AddUserList(ColumnListView* listView)
{
DIR *users;
struct dirent *user;
users = OpenUsers();
if (users)
{
while ((user = ReadUser(users)) != NULL)
if (!isUserInGroup(user->d_name, excludedGroup))
{
char desc[64];
getUserFullName(user->d_name, desc, sizeof(desc));
listView->AddItem(new PickUserItem(this, user->d_name, desc));
}
CloseGroup(users);
}
}
char *PickUserView::GetSelectedUser()
{
if (listView)
{
int index = listView->CurrentSelection();
if (index >= 0)
{
PickUserItem *item = (PickUserItem *) listView->ItemAt(index);
return ((char *) item->GetColumnContentText(1));
}
}
return NULL;
}
void PickUserView::ItemSelected()
{
okBtn->SetEnabled(true);
}
void PickUserView::ItemDeselected()
{
okBtn->SetEnabled(false);
}
// ----- PickUserPanel ----------------------------------------------------------------------
PickUserPanel::PickUserPanel(BRect frame, char *group) :
BWindow(frame, "Select User", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
{
BRect r = Bounds();
infoView = new PickUserView(r, group);
AddChild(infoView);
Show();
}
// GetUser()
//
char *PickUserPanel::GetUser()
{
if (user[0])
return user;
return NULL;
}
// MessageReceived()
//
void PickUserPanel::MessageReceived(BMessage *msg)
{
switch (msg->what)
{
case MSG_PICKUSER_OK:
strcpy(user, infoView->GetSelectedUser());
BWindow::Quit();
break;
case MSG_PICKUSER_CANCEL:
user[0] = 0;
BWindow::Quit();
break;
case MSG_PICKUSER_SELECT:
infoView->ItemSelected();
break;
case (int32) 'CLV0': //MSG_LIST_DESELECT:
infoView->ItemDeselected();
break;
default:
BWindow::MessageReceived(msg);
break;
}
}

View File

@ -0,0 +1,44 @@
// ----- PickUserItem ----------------------------------------------------------------------
class PickUserItem : public ListItem
{
public:
PickUserItem(BView *headerView, const char *text0, const char *text1);
~PickUserItem();
void ItemSelected();
void ItemDeselected();
};
class PickUserView : public BView
{
public:
PickUserView(BRect rect, char *group);
~PickUserView();
void Draw(BRect rect);
char *GetSelectedUser();
void ItemSelected();
void ItemDeselected();
private:
void AddUserList(ColumnListView* listView);
SmartColumnListView *listView;
BButton *okBtn;
char excludedGroup[33];
};
class PickUserPanel : public BWindow
{
public:
PickUserPanel(BRect frame, char *group);
void MessageReceived(BMessage *msg);
char *GetUser();
private:
PickUserView *infoView;
char user[33];
};

View File

@ -0,0 +1,159 @@
#include "Application.h"
#include "Resources.h"
#include "Window.h"
#include "View.h"
#include "Region.h"
#include "Button.h"
#include "CheckBox.h"
#include "TextControl.h"
#include "Bitmap.h"
#include "Mime.h"
#include "FilePanel.h"
#include "Menu.h"
#include "PopUpMenu.h"
#include "MenuItem.h"
#include "MenuField.h"
#include "String.h"
#include "dirent.h"
#include "ColumnListView.h"
#include "CLVColumn.h"
#include "CLVListItem.h"
#include "CLVEasyItem.h"
#include "NewStrings.h"
#include "ListControl.h"
#include "PickUser.h"
#include "ServerProperties.h"
#include "Icons.h"
#include "besure_auth.h"
const int32 MSG_SERVER_OK = 'SOky';
const int32 MSG_SERVER_CANCEL = 'SCan';
const int32 MSG_SERVER_NEWKEY = 'SKey';
const int32 MSG_SERVER_JOIN = 'SJon';
// ----- ServerPropertiesView -----------------------------------------------------
ServerPropertiesView::ServerPropertiesView(BRect rect, const char *name) :
BView(rect, "GroupInfoView", B_FOLLOW_ALL, B_WILL_DRAW)
{
strcpy(server, name);
recordLogins = isServerRecordingLogins(server);
rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(gray);
BRect bmpRect(0.0, 0.0, 31.0, 31.0);
icon = new BBitmap(bmpRect, B_CMAP8);
BMimeType mime("application/x-vnd.BeServed-fileserver");
mime.GetIcon(icon, B_LARGE_ICON);
BRect r(10, 64, 250, 84);
chkRecordLogins = new BCheckBox(r, "RecordLogins", "Record all login attempts on this server", new BMessage(MSG_SERVER_JOIN));
chkRecordLogins->SetValue(recordLogins ? B_CONTROL_ON : B_CONTROL_OFF);
AddChild(chkRecordLogins);
r.Set(10, 87, 170, 107);
btnViewLogins = new BButton(r, "ViewLogBtn", "View Login Attempts", new BMessage(MSG_SERVER_NEWKEY), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
btnViewLogins->SetEnabled(recordLogins);
AddChild(btnViewLogins);
r.Set(205, 127, 275, 147);
BButton *okBtn = new BButton(r, "OkayBtn", "OK", new BMessage(MSG_SERVER_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
okBtn->MakeDefault(true);
AddChild(okBtn);
r.Set(285, 127, 360, 147);
AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_SERVER_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));
}
ServerPropertiesView::~ServerPropertiesView()
{
}
void ServerPropertiesView::Draw(BRect rect)
{
BRect r = Bounds();
BRect iconRect(13.0, 5.0, 45.0, 37.0);
rgb_color black = { 0, 0, 0, 255 };
rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(gray);
SetLowColor(gray);
FillRect(r, B_SOLID_LOW);
SetHighColor(black);
SetFont(be_bold_font);
SetFontSize(11);
MovePenTo(55, 15);
BString string(server);
string += " Properties";
DrawString(string.String());
SetFont(be_plain_font);
SetFontSize(10);
MovePenTo(55, 28);
DrawString("This server has certain properties which govern its domain");
MovePenTo(55, 40);
DrawString("membership and allow authentication servers to mitigate access");
MovePenTo(55, 52);
DrawString("to resources which it exports.");
SetDrawingMode(B_OP_ALPHA);
SetHighColor(0, 0, 0, 180);
SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
DrawBitmap(icon, iconRect);
}
void ServerPropertiesView::EnableControls()
{
recordLogins = chkRecordLogins->Value() == B_CONTROL_ON;
btnViewLogins->SetEnabled(recordLogins);
}
// ----- ServerPropertiesPanel ----------------------------------------------------------------------
ServerPropertiesPanel::ServerPropertiesPanel(BRect frame, const char *name, BWindow *parent) :
BWindow(frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
{
strcpy(server, name);
shareWin = parent;
cancelled = true;
BRect r = Bounds();
infoView = new ServerPropertiesView(r, server);
AddChild(infoView);
Show();
}
// MessageReceived()
//
void ServerPropertiesPanel::MessageReceived(BMessage *msg)
{
switch (msg->what)
{
case MSG_SERVER_OK:
cancelled = false;
setServerRecordingLogins(server, infoView->GetRecordingLogins());
BWindow::Quit();
break;
case MSG_SERVER_CANCEL:
cancelled = true;
BWindow::Quit();
break;
case MSG_SERVER_JOIN:
infoView->EnableControls();
break;
default:
BWindow::MessageReceived(msg);
break;
}
}

View File

@ -0,0 +1,35 @@
class ServerPropertiesView : public BView
{
public:
ServerPropertiesView(BRect rect, const char *name);
~ServerPropertiesView();
void Draw(BRect rect);
void EnableControls();
bool GetRecordingLogins() { return recordLogins; }
private:
BBitmap *icon;
BCheckBox *chkRecordLogins;
BButton *btnViewLogins;
char server[B_FILE_NAME_LENGTH];
bool recordLogins;
};
class ServerPropertiesPanel : public BWindow
{
public:
ServerPropertiesPanel(BRect frame, const char *name, BWindow *parent);
void MessageReceived(BMessage *msg);
bool isCancelled() { return cancelled; }
private:
ServerPropertiesView *infoView;
BWindow *shareWin;
char server[B_FILE_NAME_LENGTH];
bool cancelled;
};

View File

@ -0,0 +1,188 @@
#include "Application.h"
#include "Resources.h"
#include "Window.h"
#include "View.h"
#include "Region.h"
#include "Alert.h"
#include "Button.h"
#include "FindDirectory.h"
#include "Mime.h"
#include "string.h"
#include "dirent.h"
#include "ColumnListView.h"
#include "CLVColumn.h"
#include "CLVListItem.h"
#include "CLVEasyItem.h"
#include "NewStrings.h"
#include "TreeControl.h"
#include "ListControl.h"
#include "Servers.h"
#include "ServerProperties.h"
#include "Icons.h"
#include "besure_auth.h"
void recvServerName(char *name, uint32 addr);
const int32 MSG_SERVER_EDIT = 'SEdt';
ColumnListView *globalListView = NULL;
BView *globalHeaderView = NULL;
ServerItem::ServerItem(BView *headerView, ColumnListView *listView, const char *text0) :
ListItem(headerView, text0, "", "")
{
BBitmap *icon;
BMessage archive;
size_t size;
list = listView;
char *bits = (char *) be_app->AppResources()->LoadResource(type_code('BBMP'), ICON_HOST_SMALL, &size);
if (bits)
if (archive.Unflatten(bits) == B_OK)
{
icon = new BBitmap(&archive);
SetColumnContent(0, icon, 2.0);
SetColumnContent(1, text0);
}
}
ServerItem::~ServerItem()
{
}
bool ServerItem::ItemInvoked()
{
BRect r;
BRect frame = GetAssociatedHeader()->Window()->Frame();
// status_t exitStatus;
r.Set(frame.left + 150, frame.top + 25, frame.left + 520, frame.top + 182); // 370 x 350
ServerPropertiesPanel *info = new ServerPropertiesPanel(r, GetColumnContentText(1), NULL);
// wait_for_thread(info->Thread(), &exitStatus);
return true;
// return (!info->isCancelled());
}
void ServerItem::ItemSelected()
{
}
void ServerItem::ItemDeselected()
{
}
void ServerItem::ItemDeleted()
{
}
bool ServerItem::IsDeleteable()
{
return false;
}
ServersItem::ServersItem(uint32 level, bool superitem, bool expanded, int32 resourceID, BView *headerView, ColumnListView *listView, char *text) :
TreeItem(level, superitem, expanded, resourceID, headerView, listView, text)
{
}
void ServersItem::ItemSelected()
{
ColumnListView *listView;
BView *headerView;
PurgeRows();
PurgeColumns();
PurgeHeader();
BuildHeader();
listView = GetAssociatedList();
headerView = GetAssociatedHeader();
listView->AddColumn(new CLVColumn(NULL, 20.0, CLV_LOCK_AT_BEGINNING | CLV_NOT_MOVABLE |
CLV_NOT_RESIZABLE | CLV_PUSH_PASS | CLV_MERGE_WITH_RIGHT));
listView->AddColumn(new CLVColumn("Server", 100.0, CLV_SORT_KEYABLE, 50.0));
globalHeaderView = headerView;
globalListView = listView;
GetServerList(recvServerName);
}
void ServersItem::ListItemSelected()
{
btnEdit->SetEnabled(true);
}
void ServersItem::ListItemDeselected()
{
btnEdit->SetEnabled(false);
}
void ServersItem::ListItemUpdated(int index, ListItem *item)
{
ColumnListView *list = GetAssociatedList();
// getGroupDesc((char *) item->GetColumnContentText(1), desc, sizeof(desc));
list->LockLooper();
// item->SetColumnContent(2, desc);
list->InvalidateItem(index);
list->UnlockLooper();
}
void ServersItem::BuildHeader()
{
BRect r;
BView *headerView = GetAssociatedHeader();
if (headerView)
{
r.Set(10, 55, 90, 75);
btnEdit = new BButton(r, "EditServerBtn", "Properties", new BMessage(MSG_SERVER_EDIT));
btnEdit->SetEnabled(false);
headerView->AddChild(btnEdit);
}
}
bool ServersItem::HeaderMessageReceived(BMessage *msg)
{
BRect r;
BRect frame = GetAssociatedHeader()->Window()->Frame();
r.Set(frame.left + 150, frame.top + 25, frame.left + 520, frame.top + 375);
SmartColumnListView *listView = (SmartColumnListView *) GetAssociatedList();
ServerItem *item = NULL;
int index = listView->CurrentSelection();
if (index >= 0)
item = (ServerItem *) listView->ItemAt(index);
switch (msg->what)
{
case MSG_SERVER_EDIT:
if (item)
if (item->ItemInvoked())
ListItemUpdated(index, item);
break;
default:
return false;
}
return false;
}
void recvServerName(char *name, uint32 addr)
{
if (globalListView)
{
globalListView->LockLooper();
globalListView->AddItem(new ServerItem(globalHeaderView, globalListView, name));
globalListView->UnlockLooper();
}
}

View File

@ -0,0 +1,37 @@
// ----- ServerItem ----------------------------------------------------------------------
class ServerItem : public ListItem
{
public:
ServerItem(BView *headerView, ColumnListView *listView, const char *text0);
~ServerItem();
bool ItemInvoked();
void ItemSelected();
void ItemDeselected();
void ItemDeleted();
bool IsDeleteable();
private:
ColumnListView *list;
};
// ----- ServersItem -----------------------------------------------------
class ServersItem : public TreeItem
{
public:
ServersItem(uint32 level, bool superitem, bool expanded, int32 resourceID, BView *headerView, ColumnListView *listView, char *text);
void ItemSelected();
void ListItemSelected();
void ListItemDeselected();
void ListItemUpdated(int index, ListItem *item);
bool HeaderMessageReceived(BMessage *msg);
private:
void BuildHeader();
BButton *btnEdit;
};

View File

@ -0,0 +1,207 @@
#include <Application.h>
#include <Resources.h>
#include <Window.h>
#include <Region.h>
#include <Alert.h>
#include "Mime.h"
#include "string.h"
#include "ColumnListView.h"
#include "CLVColumn.h"
#include "CLVListItem.h"
#include "CLVEasyItem.h"
#include "NewStrings.h"
#include "TreeControl.h"
//static rgb_color active = { 155, 155, 255, 255 };
//static rgb_color inactive = { 220, 220, 220, 255 };
SmartTreeListView::SmartTreeListView(BRect Frame, CLVContainerView** ContainerView,
const char *Name, uint32 ResizingMode, uint32 flags, list_view_type Type,
bool hierarchical, bool horizontal, bool vertical, bool scroll_view_corner,
border_style border, const BFont* LabelFont) :
ColumnListView(Frame, ContainerView, Name, ResizingMode, flags, Type, hierarchical,
horizontal, vertical, scroll_view_corner, border, LabelFont)
{
container = *ContainerView;
// SetItemSelectColor(true, active);
// SetItemSelectColor(false, inactive);
}
SmartTreeListView::~SmartTreeListView()
{
}
void SmartTreeListView::MouseUp(BPoint point)
{
int curSelection = CurrentSelection();
ColumnListView::MouseUp(point);
if (curSelection >= 0 && curSelection != lastSelection)
{
TreeItem *item = (TreeItem *) ItemAt(curSelection);
item->ItemSelected();
lastSelection = curSelection;
}
}
void SmartTreeListView::Expand(TreeItem *item)
{
ColumnListView::Expand((CLVEasyItem *) item);
item->ItemExpanding();
}
TreeItem::TreeItem(uint32 level, bool superitem, bool expanded, int32 resourceID, BView *headerView, ColumnListView *listView, char *text) :
CLVListItem(level, superitem, expanded, 16.0)
{
SetAssociatedHeader(headerView);
SetAssociatedList(listView);
setIcon(resourceID);
fText = new char[strlen(text) + 1];
strcpy(fText, text);
}
TreeItem::~TreeItem()
{
delete [] fText;
}
void TreeItem::setIcon(int32 resourceID)
{
BMessage archive;
size_t size;
char *bits = (char *) be_app->AppResources()->LoadResource(type_code('BBMP'), resourceID, &size);
if (bits)
if (archive.Unflatten(bits) == B_OK)
fIcon = new BBitmap(&archive);
}
void TreeItem::DrawItemColumn(BView* owner, BRect item_column_rect, int32 column_index, bool complete)
{
rgb_color color;
bool selected = IsSelected();
if (selected)
color = BeListSelectGrey;
else
color = White;
owner->SetLowColor(color);
owner->SetDrawingMode(B_OP_COPY);
if (selected || complete)
{
owner->SetHighColor(color);
owner->FillRect(item_column_rect);
}
BRegion Region;
Region.Include(item_column_rect);
owner->ConstrainClippingRegion(&Region);
owner->SetHighColor(Black);
if (column_index == 1)
{
item_column_rect.left += 2.0;
item_column_rect.right = item_column_rect.left + 15.0;
item_column_rect.top += 2.0;
if (Height() > 20.0)
item_column_rect.top += ceil((Height() - 20.0) / 2.0);
item_column_rect.bottom = item_column_rect.top + 15.0;
owner->SetDrawingMode(B_OP_OVER);
owner->DrawBitmap(fIcon, BRect(0.0, 0.0, 15.0, 15.0), item_column_rect);
owner->SetDrawingMode(B_OP_COPY);
}
else if(column_index == 2)
owner->DrawString(fText,
BPoint(item_column_rect.left + 2.0, item_column_rect.top + fTextOffset));
owner->ConstrainClippingRegion(NULL);
}
void TreeItem::Update(BView *owner, const BFont *font)
{
CLVListItem::Update(owner, font);
font_height FontAttributes;
be_plain_font->GetHeight(&FontAttributes);
float FontHeight = ceil(FontAttributes.ascent) + ceil(FontAttributes.descent);
fTextOffset = ceil(FontAttributes.ascent) + (Height() - FontHeight) / 2.0;
}
int TreeItem::MyCompare(const CLVListItem* a_Item1, const CLVListItem* a_Item2, int32 KeyColumn)
{
char *text1 = ((TreeItem*)a_Item1)->fText;
char *text2 = ((TreeItem*)a_Item2)->fText;
return strcasecmp(text1, text2);
}
void TreeItem::ItemSelected()
{
PurgeRows();
PurgeColumns();
PurgeHeader();
}
void TreeItem::ItemExpanding()
{
}
void TreeItem::ListItemSelected()
{
}
void TreeItem::ListItemDeselected()
{
}
void TreeItem::ListItemUpdated(int index, CLVListItem *item)
{
}
void TreeItem::PurgeHeader()
{
if (assocHeaderView)
{
int children = assocHeaderView->CountChildren();
assocHeaderView->LockLooper();
for (int i = children - 1; i >= 0; i--)
{
BView *child = assocHeaderView->ChildAt(i);
assocHeaderView->RemoveChild(child);
delete child;
}
assocHeaderView->UnlockLooper();
}
}
void TreeItem::PurgeColumns()
{
if (assocListView)
{
int columns = assocListView->CountColumns();
if (columns > 0)
assocListView->RemoveColumns(assocListView->ColumnAt(0), columns);
}
}
void TreeItem::PurgeRows()
{
if (assocListView)
{
int rows = assocListView->CountItems();
if (rows > 0)
assocListView->RemoveItems(0, rows);
}
}
bool TreeItem::HeaderMessageReceived(BMessage *msg)
{
return false;
}

View File

@ -0,0 +1,59 @@
class TreeItem : public CLVListItem
{
public:
TreeItem(uint32 level, bool superitem, bool expanded, int32 resourceID, BView *headerView, ColumnListView *listView, char* text);
~TreeItem();
void DrawItemColumn(BView* owner, BRect item_column_rect, int32 column_index, bool complete);
void Update(BView *owner, const BFont *font);
static int MyCompare(const CLVListItem* a_Item1, const CLVListItem* a_Item2, int32 KeyColumn);
ColumnListView *GetAssociatedList() { return assocListView; }
void SetAssociatedList(ColumnListView *list) { assocListView = list; }
BView *GetAssociatedHeader() { return assocHeaderView; }
void SetAssociatedHeader(BView *header) { assocHeaderView = header; }
virtual void ItemSelected();
virtual void ItemExpanding();
virtual void ListItemSelected();
virtual void ListItemDeselected();
virtual void ListItemUpdated(int index, CLVListItem *item);
virtual bool HeaderMessageReceived(BMessage *msg);
protected:
void PurgeRows();
void PurgeColumns();
void PurgeHeader();
private:
void setIcon(int32 resourceID);
BView *assocHeaderView;
ColumnListView *assocListView;
BBitmap* fIcon;
char *fText;
float fTextOffset;
};
// ----- SmartTreeListView ----------------------------------------------------------------
class SmartTreeListView : public ColumnListView
{
public:
SmartTreeListView(BRect Frame, CLVContainerView** ContainerView,
const char* Name = NULL, uint32 ResizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE,
list_view_type Type = B_SINGLE_SELECTION_LIST,
bool hierarchical = false, bool horizontal = true, bool vertical = true,
bool scroll_view_corner = true, border_style border = B_NO_BORDER,
const BFont* LabelFont = be_plain_font);
virtual ~SmartTreeListView();
void MouseUp(BPoint point);
void Expand(TreeItem *item);
private:
CLVContainerView *container;
int lastSelection;
};

View File

@ -0,0 +1,318 @@
#include "Application.h"
#include "Window.h"
#include "View.h"
#include "Region.h"
#include "Button.h"
#include "CheckBox.h"
#include "TextControl.h"
#include "Bitmap.h"
#include "Mime.h"
#include "FilePanel.h"
#include "Menu.h"
#include "PopUpMenu.h"
#include "MenuItem.h"
#include "MenuField.h"
#include "String.h"
#include "Entry.h"
#include "Path.h"
#include "dirent.h"
#include "stdio.h"
#include "UserProperties.h"
#include "besure_auth.h"
const int32 MSG_USER_OK = 'UOky';
const int32 MSG_USER_CANCEL = 'UCan';
const int32 MSG_USER_BROWSE = 'UBrw';
const int32 MSG_USER_REFRESH = 'URef';
// ----- UserPropertiesView -----------------------------------------------------
UserPropertiesView::UserPropertiesView(BRect rect, const char *name) :
BView(rect, "HostInfoView", B_FOLLOW_ALL, B_WILL_DRAW)
{
BMenuItem *item;
char strDays[10];
days = flags = 0;
newUser = name == NULL;
strcpy(user, newUser ? "unknown" : name);
getUserFullName(user, fullName, sizeof(fullName));
getUserDesc(user, desc, sizeof(desc));
getUserPassword(user, password, sizeof(password));
getUserFlags(user, &flags);
getUserDaysToExpire(user, &days);
getUserHome(user, home, sizeof(home));
getUserGroup(user, group, sizeof(group));
rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(gray);
BRect bmpRect(0.0, 0.0, 31.0, 31.0);
icon = new BBitmap(bmpRect, B_CMAP8);
BMimeType mime("application/x-vnd.Teldar-User");
mime.GetIcon(icon, B_LARGE_ICON);
BRect r(10, 52, 200, 72);
editName = new BTextControl(r, "UserName", "Name:", user, NULL);
editName->SetDivider(75);
editName->SetEnabled(newUser);
AddChild(editName);
r.Set(10, 77, 250, 97);
editFullName = new BTextControl(r, "FullName", "Full Name:", fullName, NULL);
editFullName->SetDivider(75);
AddChild(editFullName);
r.Set(10, 102, 250, 122);
editDesc = new BTextControl(r, "Description", "Description:", desc, NULL);
editDesc->SetDivider(75);
AddChild(editDesc);
r.Set(10, 127, 200, 147);
editPassword = new BTextControl(r, "Password", "Password:", password, NULL);
editPassword->SetDivider(75);
editPassword->TextView()->HideTyping(true);
AddChild(editPassword);
r.top = 157;
r.bottom = r.top + 15;
chkDisabled = new BCheckBox(r, "Disabled", "Account is disabled", NULL);
chkDisabled->SetValue(flags & USER_FLAG_DISABLED ? B_CONTROL_ON : B_CONTROL_OFF);
chkDisabled->SetEnabled(false);
AddChild(chkDisabled);
r.top = 177;
r.bottom = r.top + 15;
chkExpiresFirst = new BCheckBox(r, "Expires", "Password expires on first use", NULL);
chkExpiresFirst->SetValue(flags & USER_FLAG_INIT_EXPIRE ? B_CONTROL_ON : B_CONTROL_OFF);
chkExpiresFirst->SetEnabled(false);
AddChild(chkExpiresFirst);
r.top = 197;
r.bottom = r.top + 15;
chkExpiresEvery = new BCheckBox(r, "ExpireEvery", "Password expires every", NULL);
chkExpiresEvery->SetValue(flags & USER_FLAG_DAYS_EXPIRE ? B_CONTROL_ON : B_CONTROL_OFF);
chkExpiresEvery->SetEnabled(false);
AddChild(chkExpiresEvery);
r.Set(150, 197, 190, 217);
sprintf(strDays, "%lu", days);
editDays = new BTextControl(r, "ExpireDays", "", strDays, NULL);
editDays->SetDivider(0);
editDays->SetEnabled(false);
AddChild(editDays);
r.left = 10;
r.top = 217;
r.bottom = r.top + 15;
chkCantChange = new BCheckBox(r, "CantChange", "User cannot change password", NULL);
chkCantChange->SetValue(flags & USER_FLAG_PW_LOCKED ? B_CONTROL_ON : B_CONTROL_OFF);
chkCantChange->SetEnabled(false);
AddChild(chkCantChange);
r.top = 242;
r.bottom = r.top + 20;
r.right = 270;
editPath = new BTextControl(r, "HomePath", "Home Path:", home, NULL);
editPath->SetDivider(75);
AddChild(editPath);
r.Set(280, 239, 360, 259);
AddChild(new BButton(r, "BrowseBtn", "Browse...", new BMessage(MSG_USER_BROWSE)));
mnuGroups = new BPopUpMenu("");
DIR *groups = OpenGroups();
if (groups)
{
dirent_t *group;
while ((group = ReadGroup(groups)) != NULL)
mnuGroups->AddItem(new BMenuItem(group->d_name, NULL));
CloseGroups(groups);
}
r.Set(10, 270, 200, 290);
mnuDefaultGroup = new BMenuField(r, "DefaultGroup", "Default Group:", mnuGroups);
mnuDefaultGroup->SetDivider(75);
item = mnuGroups->FindItem(group);
if (item)
item->SetMarked(true);
AddChild(mnuDefaultGroup);
r.Set(205, 320, 275, 340);
BButton *okBtn = new BButton(r, "OkayBtn", "OK", new BMessage(MSG_USER_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
okBtn->MakeDefault(true);
AddChild(okBtn);
r.Set(285, 320, 360, 340);
AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_USER_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM));
}
UserPropertiesView::~UserPropertiesView()
{
}
void UserPropertiesView::Draw(BRect rect)
{
BRect r = Bounds();
BRect iconRect(13.0, 5.0, 45.0, 37.0);
rgb_color black = { 0, 0, 0, 255 };
rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
rgb_color disabled = { 120, 120, 120, 255 };
SetViewColor(gray);
SetLowColor(gray);
FillRect(r, B_SOLID_LOW);
SetHighColor(black);
SetFont(be_bold_font);
SetFontSize(11);
MovePenTo(55, 15);
BString string(user);
string += " Properties";
DrawString(string.String());
SetFont(be_plain_font);
SetFontSize(10);
MovePenTo(55, 28);
DrawString("The properties of this user account govern how it is to be used");
MovePenTo(55, 40);
DrawString("and the rules the authentication server applies to its maintenance.");
if (!editDays->IsEnabled())
SetHighColor(disabled);
MovePenTo(202, 210);
DrawString("days");
SetDrawingMode(B_OP_ALPHA);
SetHighColor(0, 0, 0, 180);
SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
DrawBitmap(icon, iconRect);
}
void UserPropertiesView::UpdateInfo()
{
if (newUser)
strcpy(user, editName->Text());
strcpy(fullName, editFullName->Text());
strcpy(desc, editDesc->Text());
strcpy(password, editPassword->Text());
strcpy(home, editPath->Text());
flags = 0;
if (chkDisabled->Value() == B_CONTROL_ON)
flags |= USER_FLAG_DISABLED;
if (chkExpiresFirst->Value() == B_CONTROL_ON)
flags |= USER_FLAG_INIT_EXPIRE;
if (chkExpiresEvery->Value() == B_CONTROL_ON)
flags |= USER_FLAG_DAYS_EXPIRE;
if (chkCantChange->Value() == B_CONTROL_ON)
flags |= USER_FLAG_PW_LOCKED;
BMenuItem *item = mnuGroups->FindMarked();
if (item)
strcpy(group, item->Label());
}
// SetPath()
//
void UserPropertiesView::SetPath(const char *path)
{
if (editPath && path)
{
editPath->LockLooper();
editPath->SetText(path);
editPath->UnlockLooper();
}
}
// ----- UserPropertiesPanel ----------------------------------------------------------------------
UserPropertiesPanel::UserPropertiesPanel(BRect frame, const char *name, BWindow *parent) :
BWindow(frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
{
newUser = name == NULL;
if (!newUser)
strcpy(user, name);
shareWin = parent;
cancelled = true;
BRect r = Bounds();
infoView = new UserPropertiesView(r, name == NULL ? NULL : user);
AddChild(infoView);
myMsgr = new BMessenger(NULL, this, NULL);
Show();
}
// MessageReceived()
//
void UserPropertiesPanel::MessageReceived(BMessage *msg)
{
BFilePanel *filePanel;
entry_ref entryRef;
BPath path;
BEntry entry("/boot/home", false);
entry.GetRef(&entryRef);
switch (msg->what)
{
case MSG_USER_BROWSE:
filePanel = new BFilePanel(B_OPEN_PANEL, myMsgr, &entryRef, B_DIRECTORY_NODE, false);
// filePanel->SetTarget(this);
filePanel->Show();
filePanel->Window()->SetTitle("User Home");
filePanel->SetButtonLabel(B_DEFAULT_BUTTON, "Select");
break;
case B_REFS_RECEIVED:
msg->FindRef("refs", &entryRef);
entry.SetTo(&entryRef, true);
entry.GetPath(&path);
infoView->SetPath(path.Path());
break;
case MSG_USER_OK:
cancelled = false;
infoView->UpdateInfo();
if (newUser)
{
strcpy(user, infoView->getUser());
createUser(user, infoView->getPassword());
setUserGroup(user, infoView->getGroup());
}
else
{
char group[64];
getUserGroup(user, group, sizeof(group));
removeUserFromGroup(user, group);
setUserGroup(user, infoView->getGroup());
}
strcpy(fullName, infoView->getFullName());
strcpy(desc, infoView->getDesc());
setUserFullName(user, infoView->getFullName());
setUserDesc(user, infoView->getDesc());
setUserPassword(user, infoView->getPassword());
setUserHome(user, infoView->getHome());
setUserFlags(user, infoView->getFlags());
BWindow::Quit();
break;
case MSG_USER_CANCEL:
cancelled = true;
BWindow::Quit();
break;
default:
BWindow::MessageReceived(msg);
break;
}
}

View File

@ -0,0 +1,70 @@
class UserPropertiesView : public BView
{
public:
UserPropertiesView(BRect rect, const char *name);
~UserPropertiesView();
void Draw(BRect rect);
void UpdateInfo();
void SetPath(const char *path);
char *getUser() { return user; }
char *getFullName() { return fullName; }
char *getDesc() { return desc; }
char *getPassword() { return password; }
char *getHome() { return home; }
char *getGroup() { return group; }
uint32 getFlags() { return flags; }
uint32 getDays() { return days; }
private:
BBitmap *icon;
BTextControl *editName;
BTextControl *editFullName;
BTextControl *editDesc;
BTextControl *editPassword;
BTextControl *editPath;
BTextControl *editDays;
BCheckBox *chkDisabled;
BCheckBox *chkExpiresFirst;
BCheckBox *chkExpiresEvery;
BCheckBox *chkCantChange;
BMenu *mnuGroups;
BMenuField *mnuDefaultGroup;
char user[33];
char fullName[64];
char desc[64];
char password[33];
char home[B_PATH_NAME_LENGTH];
char group[33];
uint32 flags;
uint32 days;
bool newUser;
};
class UserPropertiesPanel : public BWindow
{
public:
UserPropertiesPanel(BRect frame, const char *name, BWindow *parent);
void MessageReceived(BMessage *msg);
char *getUser() { return user; }
char *getFullName() { return fullName; }
char *getDesc() { return desc; }
bool isCancelled() { return cancelled; }
private:
BMessenger *myMsgr;
UserPropertiesView *infoView;
BWindow *shareWin;
char user[33];
char fullName[64];
char desc[64];
bool newUser;
bool cancelled;
};

View File

@ -0,0 +1,227 @@
#include "Application.h"
#include "Resources.h"
#include "Window.h"
#include "View.h"
#include "Region.h"
#include "Alert.h"
#include "Button.h"
#include "FindDirectory.h"
#include "Mime.h"
#include "string.h"
#include "dirent.h"
#include "ColumnListView.h"
#include "CLVColumn.h"
#include "CLVListItem.h"
#include "CLVEasyItem.h"
#include "NewStrings.h"
#include "TreeControl.h"
#include "ListControl.h"
#include "Users.h"
#include "UserProperties.h"
#include "Icons.h"
#include "besure_auth.h"
#define WARN_REMOVE_USER "Removing this user account may prevent access to network resources and may permanently relinquish any rights held. Are you sure you want to remove this user?"
const int32 MSG_USER_NEW = 'UNew';
const int32 MSG_USER_EDIT = 'UEdt';
const int32 MSG_USER_GONE = 'UGon';
UserItem::UserItem(BView *headerView, const char *text0, const char *text1, const char *text2) :
ListItem(headerView, text0, text1, text2)
{
BBitmap *icon;
BMessage archive;
size_t size;
char *bits = (char *) be_app->AppResources()->LoadResource(type_code('BBMP'), ICON_USER_SMALL, &size);
if (bits)
if (archive.Unflatten(bits) == B_OK)
{
icon = new BBitmap(&archive);
SetAssociatedHeader(headerView);
SetColumnContent(0, icon, 2.0);
SetColumnContent(1, text0);
SetColumnContent(2, text1);
SetColumnContent(3, text2);
}
}
UserItem::~UserItem()
{
}
bool UserItem::ItemInvoked()
{
BRect r;
BRect frame = GetAssociatedHeader()->Window()->Frame();
status_t exitStatus;
r.Set(frame.left + 150, frame.top + 25, frame.left + 520, frame.top + 375); // 370 x 350
UserPropertiesPanel *info = new UserPropertiesPanel(r, GetColumnContentText(1), NULL);
wait_for_thread(info->Thread(), &exitStatus);
return (!info->isCancelled());
}
void UserItem::ItemSelected()
{
}
void UserItem::ItemDeselected()
{
}
void UserItem::ItemDeleted()
{
removeUser((char *) GetColumnContentText(1));
}
bool UserItem::IsDeleteable()
{
BAlert *alert = new BAlert("Remove User?", WARN_REMOVE_USER, "Yes", "No");
alert->SetShortcut(1, B_ESCAPE);
alert->SetShortcut(0, 'y');
alert->SetShortcut(1, 'n');
return (alert->Go() == 0);
}
UsersItem::UsersItem(uint32 level, bool superitem, bool expanded, int32 resourceID, BView *headerView, ColumnListView *listView, char *text) :
TreeItem(level, superitem, expanded, resourceID, headerView, listView, text)
{
}
void UsersItem::ItemSelected()
{
DIR *dir;
struct dirent *dirInfo;
ColumnListView *listView;
BView *headerView;
PurgeRows();
PurgeColumns();
PurgeHeader();
BuildHeader();
listView = GetAssociatedList();
headerView = GetAssociatedHeader();
listView->AddColumn(new CLVColumn(NULL, 20.0, CLV_LOCK_AT_BEGINNING | CLV_NOT_MOVABLE |
CLV_NOT_RESIZABLE | CLV_PUSH_PASS | CLV_MERGE_WITH_RIGHT));
listView->AddColumn(new CLVColumn("User", 85.0, CLV_SORT_KEYABLE, 50.0));
listView->AddColumn(new CLVColumn("Full Name", 130.0, CLV_SORT_KEYABLE));
listView->AddColumn(new CLVColumn("Description", 150.0, CLV_SORT_KEYABLE));
dir = OpenUsers();
if (dir)
{
while ((dirInfo = ReadUser(dir)) != NULL)
{
char fullName[64], desc[64];
getUserFullName(dirInfo->d_name, fullName, sizeof(fullName));
getUserDesc(dirInfo->d_name, desc, sizeof(desc));
listView->AddItem(new UserItem(headerView, dirInfo->d_name, fullName, desc));
}
CloseUsers(dir);
}
}
void UsersItem::ListItemSelected()
{
btnEdit->SetEnabled(true);
btnRemove->SetEnabled(true);
}
void UsersItem::ListItemDeselected()
{
btnEdit->SetEnabled(false);
btnRemove->SetEnabled(false);
}
void UsersItem::ListItemUpdated(int index, ListItem *item)
{
ColumnListView *list = GetAssociatedList();
char *user = (char *) item->GetColumnContentText(1);
char fullName[64], desc[64];
getUserFullName(user, fullName, sizeof(fullName));
getUserDesc(user, desc, sizeof(desc));
list->LockLooper();
item->SetColumnContent(2, fullName);
item->SetColumnContent(3, desc);
list->InvalidateItem(index);
list->UnlockLooper();
}
void UsersItem::BuildHeader()
{
BRect r;
BView *headerView = GetAssociatedHeader();
if (headerView)
{
r.Set(10, 55, 90, 75);
headerView->AddChild(new BButton(r, "AddUserBtn", "Add User", new BMessage(MSG_USER_NEW)));
r.Set(100, 55, 180, 75);
btnEdit = new BButton(r, "EditUserBtn", "Edit User", new BMessage(MSG_USER_EDIT));
btnEdit->SetEnabled(false);
headerView->AddChild(btnEdit);
r.Set(190, 55, 280, 75);
btnRemove = new BButton(r, "RemoveUserBtn", "Remove User", new BMessage(MSG_USER_GONE));
btnRemove->SetEnabled(false);
headerView->AddChild(btnRemove);
}
}
bool UsersItem::HeaderMessageReceived(BMessage *msg)
{
UserPropertiesPanel *info;
status_t exitStatus;
BRect r;
BRect frame = GetAssociatedHeader()->Window()->Frame();
r.Set(frame.left + 150, frame.top + 25, frame.left + 520, frame.top + 375);
SmartColumnListView *listView = (SmartColumnListView *) GetAssociatedList();
UserItem *item = NULL;
int index = listView->CurrentSelection();
if (index >= 0)
item = (UserItem *) listView->ItemAt(index);
switch (msg->what)
{
case MSG_USER_NEW:
info = new UserPropertiesPanel(r, NULL, NULL);
wait_for_thread(info->Thread(), &exitStatus);
if (!info->isCancelled())
{
listView->LockLooper();
listView->AddItem(new UserItem(GetAssociatedHeader(), info->getUser(), info->getFullName(), info->getDesc()));
listView->UnlockLooper();
}
break;
case MSG_USER_EDIT:
if (item)
if (item->ItemInvoked())
ListItemUpdated(index, item);
break;
case MSG_USER_GONE:
if (item)
listView->DeleteItem(index, item);
break;
default:
return false;
}
return false;
}

View File

@ -0,0 +1,35 @@
// ----- UserItem ----------------------------------------------------------------------
class UserItem : public ListItem
{
public:
UserItem(BView *headerView, const char *text0, const char *text1, const char *text2);
~UserItem();
bool ItemInvoked();
void ItemSelected();
void ItemDeselected();
void ItemDeleted();
bool IsDeleteable();
};
// ----- UsersItem -----------------------------------------------------
class UsersItem : public TreeItem
{
public:
UsersItem(uint32 level, bool superitem, bool expanded, int32 resourceID, BView *headerView, ColumnListView *listView, char *text);
void ItemSelected();
void ListItemSelected();
void ListItemDeselected();
void ListItemUpdated(int index, ListItem *item);
bool HeaderMessageReceived(BMessage *msg);
private:
void BuildHeader();
BButton *btnEdit;
BButton *btnRemove;
};

View File

@ -0,0 +1,75 @@
#ifndef _BESURE_AUTH_H_
#define _BESURE_AUTH_H_
#include <dirent.h>
#define USER_FLAG_DISABLED 0x00000001
#define USER_FLAG_INIT_EXPIRE 0x00000002
#define USER_FLAG_DAYS_EXPIRE 0x00000004
#define USER_FLAG_PW_LOCKED 0x00000008
#ifdef _BUILDING_BESURE_
#define _IMPEXP_BESURE __declspec(dllexport)
#else
#define _IMPEXP_BESURE __declspec(dllimport)
#endif
typedef void (*recordServerFunc)(char *name, uint32 addr);
#ifdef __cplusplus
extern "C"
{
#endif
_IMPEXP_BESURE bool createUser(char *user, char *password);
_IMPEXP_BESURE bool createGroup(char *group);
_IMPEXP_BESURE bool removeUser(char *user);
_IMPEXP_BESURE bool removeGroup(char *group);
_IMPEXP_BESURE bool addUserToGroup(char *user, char *group);
_IMPEXP_BESURE bool removeUserFromGroup(char *user, char *group);
_IMPEXP_BESURE bool isUserInGroup(char *user, char *group);
_IMPEXP_BESURE bool setUserFullName(char *user, char *fullName);
_IMPEXP_BESURE bool setUserDesc(char *user, char *desc);
_IMPEXP_BESURE bool setUserPassword(char *user, char *password);
_IMPEXP_BESURE bool setUserFlags(char *user, uint32 flags);
_IMPEXP_BESURE bool setUserDaysToExpire(char *user, uint32 days);
_IMPEXP_BESURE bool setUserHome(char *user, char *home);
_IMPEXP_BESURE bool setUserGroup(char *user, char *group);
_IMPEXP_BESURE bool setGroupDesc(char *group, char *desc);
_IMPEXP_BESURE bool getUserFullName(char *user, char *fullName, int bufSize);
_IMPEXP_BESURE bool getUserDesc(char *user, char *desc, int bufSize);
_IMPEXP_BESURE bool getUserPassword(char *user, char *password, int bufSize);
_IMPEXP_BESURE bool getUserFlags(char *user, uint32 *flags);
_IMPEXP_BESURE bool getUserDaysToExpire(char *user, uint32 *days);
_IMPEXP_BESURE bool getUserHome(char *user, char *home, int bufSize);
_IMPEXP_BESURE bool getUserGroup(char *user, char *group, int bufSize);
_IMPEXP_BESURE bool getGroupDesc(char *group, char *desc, int bufSize);
_IMPEXP_BESURE bool isServerRecordingLogins(char *server);
_IMPEXP_BESURE bool setServerRecordingLogins(char *server, bool recording);
_IMPEXP_BESURE void MakeServerKey(char *server, char *key);
_IMPEXP_BESURE DIR *OpenUsers();
_IMPEXP_BESURE dirent_t *ReadUser(DIR *dir);
_IMPEXP_BESURE void CloseUsers(DIR *dir);
_IMPEXP_BESURE DIR *OpenGroups();
_IMPEXP_BESURE dirent_t *ReadGroup(DIR *dir);
_IMPEXP_BESURE void CloseGroups(DIR *dir);
_IMPEXP_BESURE DIR *OpenGroup(char *group);
_IMPEXP_BESURE dirent_t *ReadGroupMember(DIR *dir);
_IMPEXP_BESURE void CloseGroup(DIR *dir);
_IMPEXP_BESURE int GetServerList(recordServerFunc recServ);
_IMPEXP_BESURE bool GetKeyValue(const char *fileName, const char *key, char *value, int bufSize);
_IMPEXP_BESURE bool GetKeyInt(const char *fileName, const char *key, int *value);
_IMPEXP_BESURE bool SetKeyValue(const char *fileName, const char *key, const char *value);
_IMPEXP_BESURE bool SetKeyInt(const char *fileName, const char *key, int value);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,252 @@
#ifndef _BETALK_H_
#define _BETALK_H_
// BeOS-specific includes
#include "TypeConstants.h"
#include "Errors.h"
#include "OS.h"
#include "fs_attr.h"
#include "fs_query.h"
#include "fs_index.h"
#include "Mime.h"
#include "netdb.h"
// POSIX includes
#include "stdio.h"
#include "dirent.h"
#include "malloc.h"
#include "string.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "errno.h"
#include "socket.h"
#include "ctype.h"
#ifndef NULL
#define NULL 0L
#endif
#ifndef INVALID_SOCKET
#define INVALID_SOCKET (int)(~0)
#endif
#define BT_TCPIP_PORT 9092
#define BT_QUERYHOST_PORT 9093
#define BT_BESURE_PORT 9094
#define BT_CMD_TERMINATOR 13
#define BT_CMD_PREMOUNT 0
#define BT_CMD_MOUNT 1
#define BT_CMD_FSINFO 2
#define BT_CMD_LOOKUP 3
#define BT_CMD_STAT 4
#define BT_CMD_READDIR 5
#define BT_CMD_READ 6
#define BT_CMD_WRITE 7
#define BT_CMD_CREATE 8
#define BT_CMD_TRUNCATE 9
#define BT_CMD_MKDIR 10
#define BT_CMD_RMDIR 11
#define BT_CMD_RENAME 12
#define BT_CMD_UNLINK 13
#define BT_CMD_READLINK 14
#define BT_CMD_SYMLINK 15
#define BT_CMD_WSTAT 16
#define BT_CMD_READATTRIB 50
#define BT_CMD_WRITEATTRIB 51
#define BT_CMD_READATTRIBDIR 52
#define BT_CMD_REMOVEATTRIB 53
#define BT_CMD_STATATTRIB 54
#define BT_CMD_READINDEXDIR 60
#define BT_CMD_CREATEINDEX 61
#define BT_CMD_REMOVEINDEX 62
#define BT_CMD_STATINDEX 63
#define BT_CMD_READQUERY 70
#define BT_CMD_COMMIT 80
#define BT_CMD_PRINTJOB_NEW 200
#define BT_CMD_PRINTJOB_DATA 201
#define BT_CMD_PRINTJOB_COMMIT 202
#define BT_CMD_AUTHENTICATE 210
#define BT_CMD_QUIT 255
#define BT_CMD_AUTH 1
#define BT_CMD_READUSERS 2
#define BT_CMD_READGROUPS 3
#define BT_CMD_WHICHGROUPS 4
#define BT_REQ_HOST_PROBE 1
#define BT_REQ_SHARE_PROBE 2
#define BT_REQ_HOST_INFO 3
#define BT_REQ_HOST_USERS 4
#define BT_REQ_AUTH_TYPES 5
// The different types of network resources supported by BeServed.
#define BT_SHARED_NULL 0
#define BT_SHARED_FOLDER 1
#define BT_SHARED_PRINTER 2
#define BT_PRINTER_PCL3 0
#define BT_PRINTER_POSTSCRIPT 1
#define BT_PRITNER_INKJET 2
#define BT_AUTH_REQ_CONNECT 1
#define BT_AUTH_REQ_USERS 2
#define BT_AUTH_NONE 0
#define BT_AUTH_BESURE 1
#define BT_RIGHTS_READ 0x00000001
#define BT_RIGHTS_WRITE 0x00000002
#define BT_RIGHTS_PRINT 0x00000004
#define BT_RPC_SIGNATURE "btRPC"
#define BT_RPC_VERSION_HI 0
#define BT_RPC_VERSION_LO 1
#define BT_MAX_IO_BUFFER 32768
#define BT_MAX_ATTR_BUFFER 256
#define BT_RPC_MIN_PACKET_SIZE 128
#define BT_RPC_MAX_PACKET_SIZE (BT_MAX_IO_BUFFER + 1024)
#define BT_TOKEN_SHARE 1
#define BT_TOKEN_AS 2
#define BT_TOKEN_SET 3
#define BT_TOKEN_READ 4
#define BT_TOKEN_WRITE 5
#define BT_TOKEN_READWRITE 6
#define BT_TOKEN_PROMISCUOUS 7
#define BT_TOKEN_ON 8
#define BT_TOKEN_TO 9
#define BT_TOKEN_AUTHENTICATE 10
#define BT_TOKEN_WITH 11
#define BT_TOKEN_GROUP 12
#define BT_TOKEN_PRINTER 13
#define BT_TOKEN_PRINT 14
#define BT_TOKEN_IS 15
#define BT_TOKEN_SPOOLED 16
#define BT_TOKEN_DEVICE 17
#define BT_TOKEN_TYPE 18
#define BT_TOKEN_COMMA 200
#define BT_TOKEN_QUOTE 201
#define BT_TOKEN_STRING 202
#define BT_TOKEN_NUMBER 203
#define BT_TOKEN_ERROR 255
#define isValid(c) ((c)=='.' || (c)=='_' || (c)=='-' || (c)=='/' || (c)=='\\' || (c)==':' || (c)=='&' || (c)=='\'')
#define MAX_COMMAND_ARGS 10
#define MAX_NAME_LENGTH 32
#define MAX_KEY_LENGTH MAX_NAME_LENGTH
#define MAX_USERNAME_LENGTH MAX_NAME_LENGTH
#define MAX_GROUPNAME_LENGTH MAX_NAME_LENGTH
#define BT_AUTH_TOKEN_LENGTH (B_FILE_NAME_LENGTH + MAX_USERNAME_LENGTH)
#define MAX_DESC_LENGTH 64
#define MAX_GROUPS_PER_USER 80
typedef struct
{
char signature[6];
uint8 command;
char share[MAX_NAME_LENGTH + 1];
} bt_request;
typedef struct
{
uint32 type;
uint32 subType;
char name[B_FILE_NAME_LENGTH + 1];
} bt_resource;
typedef struct
{
char system[B_FILE_NAME_LENGTH];
char beServed[B_FILE_NAME_LENGTH];
char platform[B_FILE_NAME_LENGTH];
int cpus;
int connections;
int maxConnections;
} bt_hostinfo;
typedef struct
{
unsigned int blockSize;
unsigned int totalBlocks;
unsigned int freeBlocks;
} bt_fsinfo;
typedef struct
{
unsigned int size;
unsigned int length;
char *buffer;
} bt_outPacket;
typedef struct
{
unsigned int length;
unsigned int offset;
char *buffer;
} bt_inPacket;
typedef struct rpcCall
{
unsigned int nsid;
unsigned int xid;
sem_id sem;
bt_inPacket *inPacket;
bool finished;
struct rpcCall *next;
struct rpcCall *prev;
} bt_rpccall;
typedef struct rpcInfo
{
thread_id rpcThread;
int32 quitXID;
uint32 serverIP;
int32 serverPort;
int s;
} bt_rpcinfo;
#define BT_COOKIE_SIZE 4
typedef struct btCookie
{
char opaque[BT_COOKIE_SIZE];
bt_inPacket inPacket;
bool lpbCache;
bool eof;
} btCookie;
typedef struct btQueryCookie
{
char opaque[BT_COOKIE_SIZE];
char *query;
} btQueryCookie;
// RPC Operations
unsigned char btRPCGetChar(bt_inPacket *packet);
unsigned int btRPCGetInt32(bt_inPacket *packet);
int64 btRPCGetInt64(bt_inPacket *packet);
char * btRPCGetNewString(bt_inPacket *packet);
int btRPCGetString(bt_inPacket *packet, char *buffer, int length);
int btRPCGetStat(bt_inPacket *packet, struct stat *st);
bt_outPacket * btRPCPutHeader(unsigned char command, unsigned char argc, int32 length);
void btRPCPutArg(bt_outPacket *packet, unsigned int type, void *data, int length);
void btRPCPutChar(bt_outPacket *packet, char value);
void btRPCPutInt32(bt_outPacket *packet, int32 value);
void btRPCPutInt64(bt_outPacket *packet, int64 value);
void btRPCPutString(bt_outPacket *packet, char *buffer, int length);
void btRPCPutBinary(bt_outPacket *packet, void *buffer, int length);
void btRPCPutStat(bt_outPacket *packet, struct stat *st);
void btRPCCreateAck(bt_outPacket *packet, unsigned int xid, int error);
void btRPCSendAck(int client, bt_outPacket *packet);
int btRecv(int sock, void *data, int dataLen, int flags);
int btSend(int sock, void *data, int dataLen, int flags);
int btRecvMsg(int sock, void *data, int dataLen, int flags);
int btSendMsg(int sock, void *data, int dataLen, int flags);
#endif

View File

@ -0,0 +1,408 @@
/*
Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
L. Peter Deutsch
ghost@aladdin.com
*/
/*$Id: md5.c $ */
/*
Independent implementation of MD5 (RFC 1321).
This code implements the MD5 Algorithm defined in RFC 1321.
It is derived directly from the text of the RFC and not from the
reference implementation.
The original and principal author of md5.c is L. Peter Deutsch
<ghost@aladdin.com>. Other authors are noted in the change history
that follows (in reverse chronological order):
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5).
1999-05-03 lpd Original version.
*/
#include "stdio.h"
#include "md5.h"
#ifdef TEST
/*
* Compile with -DTEST to create a self-contained executable test program.
* The test program should print out the same values as given in section
* A.5 of RFC 1321, reproduced below.
*/
#include <string.h>
main()
{
static const char *const test[7] = {
"", /*d41d8cd98f00b204e9800998ecf8427e*/
"a", /*0cc175b9c0f1b6a831c399e269772661*/
"abc", /*900150983cd24fb0d6963f7d28e17f72*/
"message digest", /*f96b697d7cb7938d525a2f31aaf161d0*/
"abcdefghijklmnopqrstuvwxyz", /*c3fcd3d76192e4007dfb496cca67e13b*/
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
/*d174ab98d277d9f5a5611c2c9f419d9f*/
"12345678901234567890123456789012345678901234567890123456789012345678901234567890" /*57edf4a22be3c955ac49da2e2107b67a*/
};
int i;
for (i = 0; i < 7; ++i) {
md5_state_t state;
md5_byte_t digest[16];
int di;
md5_init(&state);
md5_append(&state, (const md5_byte_t *)test[i], strlen(test[i]));
md5_finish(&state, digest);
printf("MD5 (\"%s\") = ", test[i]);
for (di = 0; di < 16; ++di)
printf("%02x", digest[di]);
printf("\n");
}
return 0;
}
#endif /* TEST */
/*
* For reference, here is the program that computed the T values.
*/
#if 0
#include <math.h>
main()
{
int i;
for (i = 1; i <= 64; ++i) {
unsigned long v = (unsigned long)(4294967296.0 * fabs(sin((double)i)));
printf("#define T%d 0x%08lx\n", i, v);
}
return 0;
}
#endif
void md5EncodeString(const char *source, char *dest)
{
md5_state_t state;
md5_byte_t digest[16];
int i;
md5_init(&state);
md5_append(&state, (const md5_byte_t *) source, strlen(source));
md5_finish(&state, digest);
for (i = 0; i < 16; i++)
sprintf(dest + (i * 2), "%02x", digest[i]);
}
/*
* End of T computation program.
*/
#define T1 0xd76aa478
#define T2 0xe8c7b756
#define T3 0x242070db
#define T4 0xc1bdceee
#define T5 0xf57c0faf
#define T6 0x4787c62a
#define T7 0xa8304613
#define T8 0xfd469501
#define T9 0x698098d8
#define T10 0x8b44f7af
#define T11 0xffff5bb1
#define T12 0x895cd7be
#define T13 0x6b901122
#define T14 0xfd987193
#define T15 0xa679438e
#define T16 0x49b40821
#define T17 0xf61e2562
#define T18 0xc040b340
#define T19 0x265e5a51
#define T20 0xe9b6c7aa
#define T21 0xd62f105d
#define T22 0x02441453
#define T23 0xd8a1e681
#define T24 0xe7d3fbc8
#define T25 0x21e1cde6
#define T26 0xc33707d6
#define T27 0xf4d50d87
#define T28 0x455a14ed
#define T29 0xa9e3e905
#define T30 0xfcefa3f8
#define T31 0x676f02d9
#define T32 0x8d2a4c8a
#define T33 0xfffa3942
#define T34 0x8771f681
#define T35 0x6d9d6122
#define T36 0xfde5380c
#define T37 0xa4beea44
#define T38 0x4bdecfa9
#define T39 0xf6bb4b60
#define T40 0xbebfbc70
#define T41 0x289b7ec6
#define T42 0xeaa127fa
#define T43 0xd4ef3085
#define T44 0x04881d05
#define T45 0xd9d4d039
#define T46 0xe6db99e5
#define T47 0x1fa27cf8
#define T48 0xc4ac5665
#define T49 0xf4292244
#define T50 0x432aff97
#define T51 0xab9423a7
#define T52 0xfc93a039
#define T53 0x655b59c3
#define T54 0x8f0ccc92
#define T55 0xffeff47d
#define T56 0x85845dd1
#define T57 0x6fa87e4f
#define T58 0xfe2ce6e0
#define T59 0xa3014314
#define T60 0x4e0811a1
#define T61 0xf7537e82
#define T62 0xbd3af235
#define T63 0x2ad7d2bb
#define T64 0xeb86d391
static void
md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
{
md5_word_t
a = pms->abcd[0], b = pms->abcd[1],
c = pms->abcd[2], d = pms->abcd[3];
md5_word_t t;
#ifndef ARCH_IS_BIG_ENDIAN
# define ARCH_IS_BIG_ENDIAN 1 /* slower, default implementation */
#endif
#if ARCH_IS_BIG_ENDIAN
/*
* On big-endian machines, we must arrange the bytes in the right
* order. (This also works on machines of unknown byte order.)
*/
md5_word_t X[16];
const md5_byte_t *xp = data;
int i;
for (i = 0; i < 16; ++i, xp += 4)
X[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
#else /* !ARCH_IS_BIG_ENDIAN */
/*
* On little-endian machines, we can process properly aligned data
* without copying it.
*/
md5_word_t xbuf[16];
const md5_word_t *X;
if (!((data - (const md5_byte_t *)0) & 3)) {
/* data are properly aligned */
X = (const md5_word_t *)data;
} else {
/* not aligned */
memcpy(xbuf, data, 64);
X = xbuf;
}
#endif
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
/* Round 1. */
/* Let [abcd k s i] denote the operation
a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + F(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 0, 7, T1);
SET(d, a, b, c, 1, 12, T2);
SET(c, d, a, b, 2, 17, T3);
SET(b, c, d, a, 3, 22, T4);
SET(a, b, c, d, 4, 7, T5);
SET(d, a, b, c, 5, 12, T6);
SET(c, d, a, b, 6, 17, T7);
SET(b, c, d, a, 7, 22, T8);
SET(a, b, c, d, 8, 7, T9);
SET(d, a, b, c, 9, 12, T10);
SET(c, d, a, b, 10, 17, T11);
SET(b, c, d, a, 11, 22, T12);
SET(a, b, c, d, 12, 7, T13);
SET(d, a, b, c, 13, 12, T14);
SET(c, d, a, b, 14, 17, T15);
SET(b, c, d, a, 15, 22, T16);
#undef SET
/* Round 2. */
/* Let [abcd k s i] denote the operation
a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + G(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 1, 5, T17);
SET(d, a, b, c, 6, 9, T18);
SET(c, d, a, b, 11, 14, T19);
SET(b, c, d, a, 0, 20, T20);
SET(a, b, c, d, 5, 5, T21);
SET(d, a, b, c, 10, 9, T22);
SET(c, d, a, b, 15, 14, T23);
SET(b, c, d, a, 4, 20, T24);
SET(a, b, c, d, 9, 5, T25);
SET(d, a, b, c, 14, 9, T26);
SET(c, d, a, b, 3, 14, T27);
SET(b, c, d, a, 8, 20, T28);
SET(a, b, c, d, 13, 5, T29);
SET(d, a, b, c, 2, 9, T30);
SET(c, d, a, b, 7, 14, T31);
SET(b, c, d, a, 12, 20, T32);
#undef SET
/* Round 3. */
/* Let [abcd k s t] denote the operation
a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define SET(a, b, c, d, k, s, Ti)\
t = a + H(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 5, 4, T33);
SET(d, a, b, c, 8, 11, T34);
SET(c, d, a, b, 11, 16, T35);
SET(b, c, d, a, 14, 23, T36);
SET(a, b, c, d, 1, 4, T37);
SET(d, a, b, c, 4, 11, T38);
SET(c, d, a, b, 7, 16, T39);
SET(b, c, d, a, 10, 23, T40);
SET(a, b, c, d, 13, 4, T41);
SET(d, a, b, c, 0, 11, T42);
SET(c, d, a, b, 3, 16, T43);
SET(b, c, d, a, 6, 23, T44);
SET(a, b, c, d, 9, 4, T45);
SET(d, a, b, c, 12, 11, T46);
SET(c, d, a, b, 15, 16, T47);
SET(b, c, d, a, 2, 23, T48);
#undef SET
/* Round 4. */
/* Let [abcd k s t] denote the operation
a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + I(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 0, 6, T49);
SET(d, a, b, c, 7, 10, T50);
SET(c, d, a, b, 14, 15, T51);
SET(b, c, d, a, 5, 21, T52);
SET(a, b, c, d, 12, 6, T53);
SET(d, a, b, c, 3, 10, T54);
SET(c, d, a, b, 10, 15, T55);
SET(b, c, d, a, 1, 21, T56);
SET(a, b, c, d, 8, 6, T57);
SET(d, a, b, c, 15, 10, T58);
SET(c, d, a, b, 6, 15, T59);
SET(b, c, d, a, 13, 21, T60);
SET(a, b, c, d, 4, 6, T61);
SET(d, a, b, c, 11, 10, T62);
SET(c, d, a, b, 2, 15, T63);
SET(b, c, d, a, 9, 21, T64);
#undef SET
/* Then perform the following additions. (That is increment each
of the four registers by the value it had before this block
was started.) */
pms->abcd[0] += a;
pms->abcd[1] += b;
pms->abcd[2] += c;
pms->abcd[3] += d;
}
void
md5_init(md5_state_t *pms)
{
pms->count[0] = pms->count[1] = 0;
pms->abcd[0] = 0x67452301;
pms->abcd[1] = 0xefcdab89;
pms->abcd[2] = 0x98badcfe;
pms->abcd[3] = 0x10325476;
}
void
md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
{
const md5_byte_t *p = data;
int left = nbytes;
int offset = (pms->count[0] >> 3) & 63;
md5_word_t nbits = (md5_word_t)(nbytes << 3);
if (nbytes <= 0)
return;
/* Update the message length. */
pms->count[1] += nbytes >> 29;
pms->count[0] += nbits;
if (pms->count[0] < nbits)
pms->count[1]++;
/* Process an initial partial block. */
if (offset) {
int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
memcpy(pms->buf + offset, p, copy);
if (offset + copy < 64)
return;
p += copy;
left -= copy;
md5_process(pms, pms->buf);
}
/* Process full blocks. */
for (; left >= 64; p += 64, left -= 64)
md5_process(pms, p);
/* Process a final partial block. */
if (left)
memcpy(pms->buf, p, left);
}
void
md5_finish(md5_state_t *pms, md5_byte_t digest[16])
{
static const md5_byte_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
md5_byte_t data[8];
int i;
/* Save the length before padding. */
for (i = 0; i < 8; ++i)
data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
/* Pad to 56 bytes mod 64. */
md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
md5_append(pms, data, 8);
for (i = 0; i < 16; ++i)
digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
}

View File

@ -0,0 +1,96 @@
/*
Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
L. Peter Deutsch
ghost@aladdin.com
*/
/*$Id: md5.h $ */
/*
Independent implementation of MD5 (RFC 1321).
This code implements the MD5 Algorithm defined in RFC 1321.
It is derived directly from the text of the RFC and not from the
reference implementation.
The original and principal author of md5.h is L. Peter Deutsch
<ghost@aladdin.com>. Other authors are noted in the change history
that follows (in reverse chronological order):
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
added conditionalization for C++ compilation from Martin
Purschke <purschke@bnl.gov>.
1999-05-03 lpd Original version.
*/
#ifndef md5_INCLUDED
# define md5_INCLUDED
/*
* This code has some adaptations for the Ghostscript environment, but it
* will compile and run correctly in any environment with 8-bit chars and
* 32-bit ints. Specifically, it assumes that if the following are
* defined, they have the same meaning as in Ghostscript: P1, P2, P3,
* ARCH_IS_BIG_ENDIAN.
*/
typedef unsigned char md5_byte_t; /* 8-bit byte */
typedef unsigned int md5_word_t; /* 32-bit word */
/* Define the state of the MD5 Algorithm. */
typedef struct md5_state_s {
md5_word_t count[2]; /* message length in bits, lsw first */
md5_word_t abcd[4]; /* digest buffer */
md5_byte_t buf[64]; /* accumulate block */
} md5_state_t;
#ifdef __cplusplus
extern "C"
{
#endif
void md5EncodeString(const char *source, char *dest);
/* Initialize the algorithm. */
#ifdef P1
void md5_init(P1(md5_state_t *pms));
#else
void md5_init(md5_state_t *pms);
#endif
/* Append a string to the message. */
#ifdef P3
void md5_append(P3(md5_state_t *pms, const md5_byte_t *data, int nbytes));
#else
void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
#endif
/* Finish the message and return the digest. */
#ifdef P2
void md5_finish(P2(md5_state_t *pms, md5_byte_t digest[16]));
#else
void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
#endif
#ifdef __cplusplus
} /* end extern "C" */
#endif
#endif /* md5_INCLUDED */

View File

@ -0,0 +1,35 @@
/* blowfish.h */
#ifdef _BUILDING_BESURE_
#define _IMPEXP_BESURE __declspec(dllexport)
#else
#define _IMPEXP_BESURE __declspec(dllimport)
#endif
#define UWORD32 unsigned long
#define UBYTE08 unsigned char
#define MAXKEYBYTES 56 /* 448 bits */
typedef struct
{
unsigned long S[4][256], P[18];
} blf_ctx;
unsigned long F(blf_ctx *, unsigned long x);
void Blowfish_encipher(blf_ctx *, unsigned long *xl, unsigned long *xr);
void Blowfish_decipher(blf_ctx *, unsigned long *xl, unsigned long *xr);
short InitializeBlowfish(blf_ctx *, unsigned char key[], int keybytes);
#ifdef __cplusplus
extern "C"
{
#endif
_IMPEXP_BESURE void blf_enc(blf_ctx *c, unsigned long *data, int blocks);
_IMPEXP_BESURE void blf_dec(blf_ctx *c, unsigned long *data, int blocks);
_IMPEXP_BESURE void blf_key(blf_ctx *c, unsigned char *key, int len);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,75 @@
#ifndef _BESURE_AUTH_H_
#define _BESURE_AUTH_H_
#include <dirent.h>
#define USER_FLAG_DISABLED 0x00000001
#define USER_FLAG_INIT_EXPIRE 0x00000002
#define USER_FLAG_DAYS_EXPIRE 0x00000004
#define USER_FLAG_PW_LOCKED 0x00000008
#ifdef _BUILDING_BESURE_
#define _IMPEXP_BESURE __declspec(dllexport)
#else
#define _IMPEXP_BESURE __declspec(dllimport)
#endif
typedef void (*recordServerFunc)(char *name, uint32 addr);
#ifdef __cplusplus
extern "C"
{
#endif
_IMPEXP_BESURE bool createUser(char *user, char *password);
_IMPEXP_BESURE bool createGroup(char *group);
_IMPEXP_BESURE bool removeUser(char *user);
_IMPEXP_BESURE bool removeGroup(char *group);
_IMPEXP_BESURE bool addUserToGroup(char *user, char *group);
_IMPEXP_BESURE bool removeUserFromGroup(char *user, char *group);
_IMPEXP_BESURE bool isUserInGroup(char *user, char *group);
_IMPEXP_BESURE bool setUserFullName(char *user, char *fullName);
_IMPEXP_BESURE bool setUserDesc(char *user, char *desc);
_IMPEXP_BESURE bool setUserPassword(char *user, char *password);
_IMPEXP_BESURE bool setUserFlags(char *user, uint32 flags);
_IMPEXP_BESURE bool setUserDaysToExpire(char *user, uint32 days);
_IMPEXP_BESURE bool setUserHome(char *user, char *home);
_IMPEXP_BESURE bool setUserGroup(char *user, char *group);
_IMPEXP_BESURE bool setGroupDesc(char *group, char *desc);
_IMPEXP_BESURE bool getUserFullName(char *user, char *fullName, int bufSize);
_IMPEXP_BESURE bool getUserDesc(char *user, char *desc, int bufSize);
_IMPEXP_BESURE bool getUserPassword(char *user, char *password, int bufSize);
_IMPEXP_BESURE bool getUserFlags(char *user, uint32 *flags);
_IMPEXP_BESURE bool getUserDaysToExpire(char *user, uint32 *days);
_IMPEXP_BESURE bool getUserHome(char *user, char *home, int bufSize);
_IMPEXP_BESURE bool getUserGroup(char *user, char *group, int bufSize);
_IMPEXP_BESURE bool getGroupDesc(char *group, char *desc, int bufSize);
_IMPEXP_BESURE bool isServerRecordingLogins(char *server);
_IMPEXP_BESURE bool setServerRecordingLogins(char *server, bool recording);
_IMPEXP_BESURE void MakeServerKey(char *server, char *key);
_IMPEXP_BESURE DIR *OpenUsers();
_IMPEXP_BESURE dirent_t *ReadUser(DIR *dir);
_IMPEXP_BESURE void CloseUsers(DIR *dir);
_IMPEXP_BESURE DIR *OpenGroups();
_IMPEXP_BESURE dirent_t *ReadGroup(DIR *dir);
_IMPEXP_BESURE void CloseGroups(DIR *dir);
_IMPEXP_BESURE DIR *OpenGroup(char *group);
_IMPEXP_BESURE dirent_t *ReadGroupMember(DIR *dir);
_IMPEXP_BESURE void CloseGroup(DIR *dir);
_IMPEXP_BESURE int GetServerList(recordServerFunc recServ);
_IMPEXP_BESURE bool GetKeyValue(const char *fileName, const char *key, char *value, int bufSize);
_IMPEXP_BESURE bool GetKeyInt(const char *fileName, const char *key, int *value);
_IMPEXP_BESURE bool SetKeyValue(const char *fileName, const char *key, const char *value);
_IMPEXP_BESURE bool SetKeyInt(const char *fileName, const char *key, int value);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,252 @@
#ifndef _BETALK_H_
#define _BETALK_H_
// BeOS-specific includes
#include "TypeConstants.h"
#include "Errors.h"
#include "OS.h"
#include "fs_attr.h"
#include "fs_query.h"
#include "fs_index.h"
#include "Mime.h"
#include "netdb.h"
// POSIX includes
#include "stdio.h"
#include "dirent.h"
#include "malloc.h"
#include "string.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "errno.h"
#include "socket.h"
#include "ctype.h"
#ifndef NULL
#define NULL 0L
#endif
#ifndef INVALID_SOCKET
#define INVALID_SOCKET (int)(~0)
#endif
#define BT_TCPIP_PORT 9092
#define BT_QUERYHOST_PORT 9093
#define BT_BESURE_PORT 9094
#define BT_CMD_TERMINATOR 13
#define BT_CMD_PREMOUNT 0
#define BT_CMD_MOUNT 1
#define BT_CMD_FSINFO 2
#define BT_CMD_LOOKUP 3
#define BT_CMD_STAT 4
#define BT_CMD_READDIR 5
#define BT_CMD_READ 6
#define BT_CMD_WRITE 7
#define BT_CMD_CREATE 8
#define BT_CMD_TRUNCATE 9
#define BT_CMD_MKDIR 10
#define BT_CMD_RMDIR 11
#define BT_CMD_RENAME 12
#define BT_CMD_UNLINK 13
#define BT_CMD_READLINK 14
#define BT_CMD_SYMLINK 15
#define BT_CMD_WSTAT 16
#define BT_CMD_READATTRIB 50
#define BT_CMD_WRITEATTRIB 51
#define BT_CMD_READATTRIBDIR 52
#define BT_CMD_REMOVEATTRIB 53
#define BT_CMD_STATATTRIB 54
#define BT_CMD_READINDEXDIR 60
#define BT_CMD_CREATEINDEX 61
#define BT_CMD_REMOVEINDEX 62
#define BT_CMD_STATINDEX 63
#define BT_CMD_READQUERY 70
#define BT_CMD_COMMIT 80
#define BT_CMD_PRINTJOB_NEW 200
#define BT_CMD_PRINTJOB_DATA 201
#define BT_CMD_PRINTJOB_COMMIT 202
#define BT_CMD_AUTHENTICATE 210
#define BT_CMD_QUIT 255
#define BT_CMD_AUTH 1
#define BT_CMD_READUSERS 2
#define BT_CMD_READGROUPS 3
#define BT_CMD_WHICHGROUPS 4
#define BT_REQ_HOST_PROBE 1
#define BT_REQ_SHARE_PROBE 2
#define BT_REQ_HOST_INFO 3
#define BT_REQ_HOST_USERS 4
#define BT_REQ_AUTH_TYPES 5
// The different types of network resources supported by BeServed.
#define BT_SHARED_NULL 0
#define BT_SHARED_FOLDER 1
#define BT_SHARED_PRINTER 2
#define BT_PRINTER_PCL3 0
#define BT_PRINTER_POSTSCRIPT 1
#define BT_PRITNER_INKJET 2
#define BT_AUTH_REQ_CONNECT 1
#define BT_AUTH_REQ_USERS 2
#define BT_AUTH_NONE 0
#define BT_AUTH_BESURE 1
#define BT_RIGHTS_READ 0x00000001
#define BT_RIGHTS_WRITE 0x00000002
#define BT_RIGHTS_PRINT 0x00000004
#define BT_RPC_SIGNATURE "btRPC"
#define BT_RPC_VERSION_HI 0
#define BT_RPC_VERSION_LO 1
#define BT_MAX_IO_BUFFER 32768
#define BT_MAX_ATTR_BUFFER 256
#define BT_RPC_MIN_PACKET_SIZE 128
#define BT_RPC_MAX_PACKET_SIZE (BT_MAX_IO_BUFFER + 1024)
#define BT_TOKEN_SHARE 1
#define BT_TOKEN_AS 2
#define BT_TOKEN_SET 3
#define BT_TOKEN_READ 4
#define BT_TOKEN_WRITE 5
#define BT_TOKEN_READWRITE 6
#define BT_TOKEN_PROMISCUOUS 7
#define BT_TOKEN_ON 8
#define BT_TOKEN_TO 9
#define BT_TOKEN_AUTHENTICATE 10
#define BT_TOKEN_WITH 11
#define BT_TOKEN_GROUP 12
#define BT_TOKEN_PRINTER 13
#define BT_TOKEN_PRINT 14
#define BT_TOKEN_IS 15
#define BT_TOKEN_SPOOLED 16
#define BT_TOKEN_DEVICE 17
#define BT_TOKEN_TYPE 18
#define BT_TOKEN_COMMA 200
#define BT_TOKEN_QUOTE 201
#define BT_TOKEN_STRING 202
#define BT_TOKEN_NUMBER 203
#define BT_TOKEN_ERROR 255
#define isValid(c) ((c)=='.' || (c)=='_' || (c)=='-' || (c)=='/' || (c)=='\\' || (c)==':' || (c)=='&' || (c)=='\'')
#define MAX_COMMAND_ARGS 10
#define MAX_NAME_LENGTH 32
#define MAX_KEY_LENGTH MAX_NAME_LENGTH
#define MAX_USERNAME_LENGTH MAX_NAME_LENGTH
#define MAX_GROUPNAME_LENGTH MAX_NAME_LENGTH
#define BT_AUTH_TOKEN_LENGTH (B_FILE_NAME_LENGTH + MAX_USERNAME_LENGTH)
#define MAX_DESC_LENGTH 64
#define MAX_GROUPS_PER_USER 80
typedef struct
{
char signature[6];
uint8 command;
char share[MAX_NAME_LENGTH + 1];
} bt_request;
typedef struct
{
uint32 type;
uint32 subType;
char name[B_FILE_NAME_LENGTH + 1];
} bt_resource;
typedef struct
{
char system[B_FILE_NAME_LENGTH];
char beServed[B_FILE_NAME_LENGTH];
char platform[B_FILE_NAME_LENGTH];
int cpus;
int connections;
int maxConnections;
} bt_hostinfo;
typedef struct
{
unsigned int blockSize;
unsigned int totalBlocks;
unsigned int freeBlocks;
} bt_fsinfo;
typedef struct
{
unsigned int size;
unsigned int length;
char *buffer;
} bt_outPacket;
typedef struct
{
unsigned int length;
unsigned int offset;
char *buffer;
} bt_inPacket;
typedef struct rpcCall
{
unsigned int nsid;
unsigned int xid;
sem_id sem;
bt_inPacket *inPacket;
bool finished;
struct rpcCall *next;
struct rpcCall *prev;
} bt_rpccall;
typedef struct rpcInfo
{
thread_id rpcThread;
int32 quitXID;
uint32 serverIP;
int32 serverPort;
int s;
} bt_rpcinfo;
#define BT_COOKIE_SIZE 4
typedef struct btCookie
{
char opaque[BT_COOKIE_SIZE];
bt_inPacket inPacket;
bool lpbCache;
bool eof;
} btCookie;
typedef struct btQueryCookie
{
char opaque[BT_COOKIE_SIZE];
char *query;
} btQueryCookie;
// RPC Operations
unsigned char btRPCGetChar(bt_inPacket *packet);
unsigned int btRPCGetInt32(bt_inPacket *packet);
int64 btRPCGetInt64(bt_inPacket *packet);
char * btRPCGetNewString(bt_inPacket *packet);
int btRPCGetString(bt_inPacket *packet, char *buffer, int length);
int btRPCGetStat(bt_inPacket *packet, struct stat *st);
bt_outPacket * btRPCPutHeader(unsigned char command, unsigned char argc, int32 length);
void btRPCPutArg(bt_outPacket *packet, unsigned int type, void *data, int length);
void btRPCPutChar(bt_outPacket *packet, char value);
void btRPCPutInt32(bt_outPacket *packet, int32 value);
void btRPCPutInt64(bt_outPacket *packet, int64 value);
void btRPCPutString(bt_outPacket *packet, char *buffer, int length);
void btRPCPutBinary(bt_outPacket *packet, void *buffer, int length);
void btRPCPutStat(bt_outPacket *packet, struct stat *st);
void btRPCCreateAck(bt_outPacket *packet, unsigned int xid, int error);
void btRPCSendAck(int client, bt_outPacket *packet);
int btRecv(int sock, void *data, int dataLen, int flags);
int btSend(int sock, void *data, int dataLen, int flags);
int btRecvMsg(int sock, void *data, int dataLen, int flags);
int btSendMsg(int sock, void *data, int dataLen, int flags);
#endif

View File

@ -0,0 +1,10 @@
#ifndef _SYSDEPDEFS_H_
#define _SYSDEPDEFS_H_
#ifdef BONE_VERSION
#define closesocket(s) close(s)
#endif
#endif

View File

@ -0,0 +1,4 @@
authenticate with 10.1.6.15
share e:\temp as "Temp Folder"
grant read,write on "Temp Folder" to kmusick
grant read on "Temp Folder" to group everyone

View File

@ -0,0 +1,102 @@
// BrowseFolders.cpp : implementation file
//
#include "stdafx.h"
#include "FileSharing.h"
#include "BrowseFolders.h"
#include "MTVFolder.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBrowseFolders dialog
CBrowseFolders::CBrowseFolders(CWnd* pParent /*=NULL*/)
: CDialog(CBrowseFolders::IDD, pParent)
{
//{{AFX_DATA_INIT(CBrowseFolders)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_newPath.Empty();
}
void CBrowseFolders::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBrowseFolders)
//}}AFX_DATA_MAP
DDX_Control(pDX, IDC_FOLDERVIEW, m_folderCtrl);
}
BEGIN_MESSAGE_MAP(CBrowseFolders, CDialog)
//{{AFX_MSG_MAP(CBrowseFolders)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBrowseFolders message handlers
BOOL CBrowseFolders::OnInitDialog()
{
CDialog::OnInitDialog();
SetPath(m_newPath);
return TRUE;
}
// SelectFolder()
//
int CBrowseFolders::SelectFolder(LPCTSTR lpszPath)
{
m_newPath = lpszPath;
return DoModal();
}
// SetPath()
//
void CBrowseFolders::SetPath(LPCTSTR lpszPath)
{
CString string(lpszPath);
VARIANT variant;
BSTR bstr = string.AllocSysString();
variant.vt = VT_BSTR;
variant.bstrVal = bstr;
m_folderCtrl.put_SelectedFolder(variant);
}
// GetPath()
//
CString CBrowseFolders::GetPath()
{
if (IsWindow(m_folderCtrl.GetSafeHwnd()))
{
VARIANT var = m_folderCtrl.get_SelectedFolder();
CMTVFolder folder(var.pdispVal);
return folder.GetPathName();
}
return m_newPath;
}
// OnOK()
//
void CBrowseFolders::OnOK()
{
VARIANT var = m_folderCtrl.get_SelectedFolder();
CMTVFolder folder(var.pdispVal);
m_newPath = folder.GetPathName();
m_newPath.MakeLower();
CDialog::OnOK();
}

View File

@ -0,0 +1,57 @@
//{{AFX_INCLUDES()
#include "folderview.h"
//}}AFX_INCLUDES
#if !defined(AFX_BROWSEFOLDERS_H__60DF2AD1_F62B_11D5_90FA_00C04F0972A7__INCLUDED_)
#define AFX_BROWSEFOLDERS_H__60DF2AD1_F62B_11D5_90FA_00C04F0972A7__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// BrowseFolders.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CBrowseFolders dialog
class CBrowseFolders : public CDialog
{
// Construction
public:
CBrowseFolders(CWnd* pParent = NULL); // standard constructor
int SelectFolder(LPCTSTR lpszPath);
CString GetPath();
// Dialog Data
//{{AFX_DATA(CBrowseFolders)
enum { IDD = IDD_BROWSER };
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBrowseFolders)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
CString m_newPath;
// Generated message map functions
//{{AFX_MSG(CBrowseFolders)
virtual void OnOK();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
void SetPath(LPCTSTR lpszPath);
public:
CFolderview m_folderCtrl;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BROWSEFOLDERS_H__60DF2AD1_F62B_11D5_90FA_00C04F0972A7__INCLUDED_)

View File

@ -0,0 +1,192 @@
// DomainUsers.cpp : implementation file
//
#include "stdafx.h"
#include "beCompat.h"
#include "betalk.h"
#include "FileSharing.h"
#include "DomainUsers.h"
#include "rpc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDomainUsers dialog
CDomainUsers::CDomainUsers(CWnd* pParent /*=NULL*/)
: CDialog(CDomainUsers::IDD, pParent)
{
//{{AFX_DATA_INIT(CDomainUsers)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_nRights = 0;
m_user.Empty();
m_bGroup = false;
m_bPrinting = false;
}
void CDomainUsers::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDomainUsers)
DDX_Control(pDX, IDOK, m_okayBtn);
DDX_Control(pDX, IDC_DOMAIN_USERS, m_userList);
DDX_Control(pDX, IDC_DOMAIN_RIGHTS, m_rights);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDomainUsers, CDialog)
//{{AFX_MSG_MAP(CDomainUsers)
ON_NOTIFY(NM_CLICK, IDC_DOMAIN_USERS, OnClickDomainUsers)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDomainUsers message handlers
int CDomainUsers::ShowUsers(bool bPrinting)
{
SetPrinting(bPrinting);
return DoModal();
}
BOOL CDomainUsers::OnInitDialog()
{
CDialog::OnInitDialog();
m_userList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_userList.InsertColumn(0, "User or Group", LVCFMT_LEFT, 175);
m_userList.InsertColumn(1, "Full Name", LVCFMT_LEFT, 185);
CBitmap user, group;
user.LoadBitmap(IDB_USER);
group.LoadBitmap(IDB_GROUP);
m_images.Create(16, 16, FALSE, 2, 0);
m_images.Add(&user, (COLORREF) 0);
m_images.Add(&group, (COLORREF) 0);
m_userList.SetImageList(&m_images, LVSIL_SMALL);
if (m_bPrinting)
{
m_rights.ResetContent();
m_rights.AddString("Print");
}
AddUserList();
AddGroupList();
return TRUE;
}
void CDomainUsers::OnClickDomainUsers(NMHDR* pNMHDR, LRESULT* pResult)
{
int nIndex;
*pResult = 0;
nIndex = GetSelectedListItem(&m_userList);
if (nIndex >= 0)
{
m_rights.EnableWindow(TRUE);
m_rights.SelectString(-1, m_bPrinting ? "Print" : "Read-only");
m_okayBtn.EnableWindow(TRUE);
}
else
{
m_rights.EnableWindow(FALSE);
m_okayBtn.EnableWindow(FALSE);
}
}
void CDomainUsers::OnOK()
{
CString rights;
int nItem = GetSelectedListItem(&m_userList);
m_user = m_userList.GetItemText(nItem, 0);
m_bGroup = m_userList.GetItemData(nItem) ? true : false;
m_nRights = m_bPrinting ? BT_RIGHTS_PRINT : BT_RIGHTS_READ;
nItem = m_rights.GetCurSel();
m_rights.GetLBText(nItem, rights);
if (rights.CompareNoCase("Read-write") == 0)
m_nRights |= BT_RIGHTS_WRITE;
CDialog::OnOK();
}
void CDomainUsers::AddUserList()
{
extern unsigned int authServerIP;
int32 *dir = NULL;
char user[MAX_USERNAME_LENGTH], fullName[MAX_DESC_LENGTH];
int nIndex;
bt_outPacket *outPacket = btRPCPutHeader(BT_CMD_READUSERS, 1, 4);
btRPCPutArg(outPacket, B_INT32_TYPE, &dir, sizeof(int32));
bt_inPacket *inPacket = btRPCSimpleCall(authServerIP, BT_BESURE_PORT, outPacket);
if (inPacket)
{
int error, count = 0;
do
{
error = btRPCGetInt32(inPacket);
if (error == B_OK)
{
memset(user, 0, sizeof(user));
memset(fullName, 0, sizeof(fullName));
btRPCGetString(inPacket, user, sizeof(user));
btRPCGetString(inPacket, fullName, sizeof(fullName));
nIndex = m_userList.InsertItem(0, user, 0);
m_userList.SetItemText(nIndex, 1, fullName);
m_userList.SetItemData(nIndex, 0);
}
else break;
} while (++count < 80);
free(inPacket->buffer);
free(inPacket);
}
}
void CDomainUsers::AddGroupList()
{
extern unsigned int authServerIP;
int32 *dir = NULL;
char group[MAX_USERNAME_LENGTH];
int nIndex;
bt_outPacket *outPacket = btRPCPutHeader(BT_CMD_READGROUPS, 1, 4);
btRPCPutArg(outPacket, B_INT32_TYPE, &dir, sizeof(int32));
bt_inPacket *inPacket = btRPCSimpleCall(authServerIP, BT_BESURE_PORT, outPacket);
if (inPacket)
{
int error, count = 0;
do
{
error = btRPCGetInt32(inPacket);
if (error == B_OK)
{
memset(group, 0, sizeof(group));
btRPCGetString(inPacket, group, sizeof(group));
nIndex = m_userList.InsertItem(0, group, 1);
m_userList.SetItemData(nIndex, 1);
}
else break;
} while (++count < 80);
free(inPacket->buffer);
free(inPacket);
}
}

View File

@ -0,0 +1,64 @@
#if !defined(AFX_DOMAINUSERS_H__6F5ED7A2_9C16_11D6_9EF3_00A0C965AF06__INCLUDED_)
#define AFX_DOMAINUSERS_H__6F5ED7A2_9C16_11D6_9EF3_00A0C965AF06__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DomainUsers.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CDomainUsers dialog
class CDomainUsers : public CDialog
{
// Construction
public:
CDomainUsers(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDomainUsers)
enum { IDD = IDD_DOMAIN_USERS };
CButton m_okayBtn;
CListCtrl m_userList;
CComboBox m_rights;
//}}AFX_DATA
int ShowUsers(bool bPrinting);
void AddUserList();
void AddGroupList();
CString GetUser() { return m_user; }
int GetRights() { return m_nRights; }
bool IsGroup() { return m_bGroup; }
void SetPrinting(bool b) { m_bPrinting = b; }
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDomainUsers)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDomainUsers)
virtual BOOL OnInitDialog();
afx_msg void OnClickDomainUsers(NMHDR* pNMHDR, LRESULT* pResult);
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
CImageList m_images;
CString m_user;
int m_nRights;
bool m_bPrinting;
bool m_bGroup;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DOMAINUSERS_H__6F5ED7A2_9C16_11D6_9EF3_00A0C965AF06__INCLUDED_)

View File

@ -0,0 +1,173 @@
# Microsoft Developer Studio Project File - Name="FileSharing" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=FileSharing - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "FileSharing.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "FileSharing.mak" CFG="FileSharing - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "FileSharing - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "FileSharing - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "FileSharing - Win32 Release"
# PROP BASE Use_MFC 5
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 5
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_WINDLL" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /mktyplib203
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386 /def:"FileSharing.def" /out:"Release/FileSharing.cpl"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "FileSharing - Win32 Debug"
# PROP BASE Use_MFC 5
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 5
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_WINDLL" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /mktyplib203
# SUBTRACT MTL /nologo
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /def:"FileSharing.def" /out:"Debug/FileSharing.cpl" /implib:"FileSharing.lib"
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "FileSharing - Win32 Release"
# Name "FileSharing - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\ctrlpan.cpp
# End Source File
# Begin Source File
SOURCE=.\FileSharing.cpp
# End Source File
# Begin Source File
SOURCE=.\FileSharing.rc
!IF "$(CFG)" == "FileSharing - Win32 Release"
!ELSEIF "$(CFG)" == "FileSharing - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\scanDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\scanpan.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\ctrlpan.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
SOURCE=.\FileSharing.h
# End Source File
# Begin Source File
SOURCE=.\scanDlg.h
# End Source File
# Begin Source File
SOURCE=.\scanpan.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\FileSharing.ico
# End Source File
# Begin Source File
SOURCE=.\res\FileSharing.rc2
# End Source File
# End Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project

View File

@ -0,0 +1,103 @@
// FileSharing.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "printing.h"
#include "FileSharing.h"
#include "FolderView.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
bt_fileShare_t fileShares[128];
bt_printer sharedPrinters[BT_MAX_PRINTER_SHARES];
char authServerName[B_OS_NAME_LENGTH + 1];
unsigned int authServerIP;
/////////////////////////////////////////////////////////////////////////////
// CFileSharingApp
BEGIN_MESSAGE_MAP(CFileSharingApp, CWinApp)
//{{AFX_MSG_MAP(CFileSharingApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFileSharingApp construction
CFileSharingApp::CFileSharingApp()
{
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CFileSharingApp object
CFileSharingApp theApp;
BOOL CFileSharingApp::InitInstance()
{
WSADATA wsaData;
AfxEnableControlContainer();
WSAStartup(MAKEWORD(1, 1), &wsaData);
return CWinApp::InitInstance();
}
int CFileSharingApp::ExitInstance()
{
WSACleanup();
return CWinApp::ExitInstance();
}
// ----- Library routine for font generation --------------------------------
HFONT InitializeControlFont(char *fontName, int fontWeight, int fontSize)
{
CDC *dc;
HFONT hFnt;
NPLOGFONT plf = (NPLOGFONT) LocalAlloc(LPTR, sizeof(LOGFONT));
dc = CWnd::GetDesktopWindow()->GetDC();
plf->lfHeight = -MulDiv(fontSize, dc->GetDeviceCaps(LOGPIXELSY), 72);
plf->lfWeight = fontWeight;
lstrcpy((LPSTR) plf->lfFaceName, fontName);
hFnt = CreateFontIndirect(plf);
LocalFree((LOCALHANDLE) plf);
CWnd::GetDesktopWindow()->ReleaseDC(dc);
return (hFnt);
}
// GetSelectedListItem()
//
int GetSelectedListItem(CListCtrl *pListCtrl)
{
int i;
// Find the first selected document in the list.
for (i = 0; i < pListCtrl->GetItemCount(); i++)
if (pListCtrl->GetItemState(i, LVIS_SELECTED) != 0)
break;
// If none could be found, what are we doing here?
if (i >= pListCtrl->GetItemCount())
i = -1;
return (i);
}
// PrintString()
//
void PrintString(FILE *fp, const char *str)
{
if (strchr(str, ' '))
fprintf(fp, "\"%s\"", str);
else
fprintf(fp, "%s", str);
}

View File

@ -0,0 +1,7 @@
; FileSharing.def : Declares the module parameters for the DLL.
LIBRARY FileSharing
EXPORTS
; Explicit exports can go here
CPlApplet

View File

@ -0,0 +1,72 @@
// scanDlg.h : header file
//
#if !defined(AFX_FileSharing_H__INCLUDED_)
#define AFX_FileSharing_H__INCLUDED_
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#ifdef IDC_STATIC
#undef IDC_STATIC
#endif
#include "resource.h"
#include "ScanPan.h"
#include "FileSharingDlg.h"
#ifndef _BETALK_H_
#include "beCompat.h"
#include "betalk.h"
#endif
#define iswhite(c) ((c)==' ' || (c)=='\t')
#define BT_MAX_FILE_SHARES 128
#define BT_MAX_PRINTER_SHARES 16
typedef struct fileShare
{
char path[B_PATH_NAME_LENGTH];
char name[B_FILE_NAME_LENGTH];
bool used;
bool readOnly;
bool followLinks;
bt_user_rights *rights;
int security;
struct fileShare *next;
} bt_fileShare_t;
HFONT InitializeControlFont(char *fontName, int fontWeight, int fontSize);
int GetSelectedListItem(CListCtrl *pListCtrl);
void PrintString(FILE *fp, const char *str);
/////////////////////////////////////////////////////////////////////////////
// CFileSharingApp
// See FileSharing.cpp for the implementation of this class
//
class CFileSharingApp : public CWinApp
{
public:
CFileSharingApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFileSharingApp)
//}}AFX_VIRTUAL
//{{AFX_MSG(CFileSharingApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
CScanPanel m_Control;
virtual BOOL InitInstance();
virtual int ExitInstance();
};
/////////////////////////////////////////////////////////////////////////////
#endif // !defined(AFX_SCANDLG_H__INCLUDED_)

View File

@ -0,0 +1,42 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: scanappl - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating command line "rc.exe /l 0x409 /fo"Release/scanappl.res" /d "NDEBUG" "D:\PROJECTS\scanappl\scanappl.rc""
Creating temporary file "C:\WINDOWS\TEMP\RSP4355.TMP" with contents
[
/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_WINDLL" /Fp"Release/scanappl.pch" /Yu"stdafx.h" /Fo"Release/" /Fd"Release/" /FD /c
"D:\PROJECTS\scanappl\scanDlg.cpp"
]
Creating command line "cl.exe @C:\WINDOWS\TEMP\RSP4355.TMP"
Creating temporary file "C:\WINDOWS\TEMP\RSP4356.TMP" with contents
[
/nologo /subsystem:windows /dll /incremental:no /pdb:"Release/scanappl.pdb" /machine:I386 /def:"scanappl.def" /out:"Release/scanappl.cpl" /implib:"Release/scanappl.lib"
.\Release\ctrlpan.obj
.\Release\scanappl.obj
.\Release\scanDlg.obj
.\Release\scanpan.obj
.\Release\StdAfx.obj
.\Release\scanappl.res
]
Creating command line "link.exe @C:\WINDOWS\TEMP\RSP4356.TMP"
<h3>Output Window</h3>
Compiling resources...
Compiling...
scanDlg.cpp
Linking...
Creating library Release/scanappl.lib and object Release/scanappl.exp
LINK : warning LNK4089: all references to "SHELL32.dll" discarded by /OPT:REF
LINK : warning LNK4089: all references to "comdlg32.dll" discarded by /OPT:REF
<h3>Results</h3>
scanappl.cpl - 0 error(s), 2 warning(s)
</pre>
</body>
</html>

View File

@ -0,0 +1,466 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif\r\n"
"#include ""res\\scanappl.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON "res\\FileSharing.ico"
IDI_GLOBE ICON "res\\idi_globe.ico"
IDI_LIGHTBULB ICON "res\\lightbulb.ico"
IDI_OPTIONS ICON "res\\options.ico"
IDI_PADLOCK ICON "res\\padlock.ico"
IDI_SHARING ICON "res\\sharing.ico"
IDI_VOLUME ICON "res\\icon1.ico"
IDI_PRINTER ICON "res\\printer.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DOMAIN_USERS DIALOG 70, 20, 258, 229
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Domain Users"
FONT 8, "Tahoma"
BEGIN
DEFPUSHBUTTON "OK",IDOK,147,208,50,14,WS_DISABLED
PUSHBUTTON "Cancel",IDCANCEL,201,208,50,14
LTEXT "Select a user or group from the list below, select the desired access rights, then click the OK button. Click the Cancel button to abort the selection.",
IDC_STATIC,7,7,244,19
CONTROL "List1",IDC_DOMAIN_USERS,"SysListView32",LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING |
WS_BORDER | WS_TABSTOP,7,31,244,119
COMBOBOX IDC_DOMAIN_RIGHTS,61,155,98,61,CBS_DROPDOWNLIST |
CBS_SORT | WS_DISABLED | WS_VSCROLL | WS_TABSTOP
LTEXT "Access Rights:",IDC_STATIC,7,157,48,8
ICON IDI_LIGHTBULB,IDC_STATIC,9,177,20,20
LTEXT "When granting write access to a shared volume, you are by definition also granting the ability to rename and delete files.",
IDC_STATIC,37,178,216,19
END
IDD_FILESHARING_DIALOG DIALOGEX 0, 0, 320, 252
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "File Sharing"
FONT 8, "Tahoma", 0, 0, 0x1
BEGIN
CONTROL "List1",IDC_SHARE_LIST,"SysListView32",LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING |
WS_BORDER | WS_TABSTOP,7,67,306,149
LTEXT "File Sharing Preferences",IDC_MAIN_HEADING,40,7,116,8
LTEXT "Normally, remote BeOS computers on your network do not have access to files on this computer. You grant them access by explicitly sharing specific folders.",
IDC_STATIC,39,17,256,18
PUSHBUTTON "&New",IDC_SHARE_NEW,7,49,50,14
PUSHBUTTON "&Edit",IDC_SHARE_EDIT,61,49,50,14
PUSHBUTTON "&Remove",IDC_SHARE_REMOVE,115,49,50,14
LTEXT "Save your changes to file sharing preferences by clicking the OK button. This will not have an effect on users until you manually restart the BeServed file serving application.",
IDC_STATIC,7,221,306,19
ICON IDI_SHARING,IDC_STATIC,9,8,20,20
PUSHBUTTON "Se&curity",IDC_SECURITY,263,49,50,14
END
IDD_SECURITY DIALOG 0, 0, 248, 106
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Security"
FONT 8, "Tahoma"
BEGIN
DEFPUSHBUTTON "OK",IDOK,136,85,50,14
PUSHBUTTON "Cancel",IDCANCEL,191,85,50,14
LTEXT "When users connect to this computer to access shared files, the settings here will be used to determine how those users are authenticated.",
IDC_STATIC,39,7,202,29
LTEXT "Authentication Method:",IDC_STATIC,7,44,76,8
LTEXT "Server Name:",IDC_STATIC,7,60,45,8
COMBOBOX IDC_SECURITY_TYPE,92,41,149,50,CBS_DROPDOWNLIST |
CBS_SORT | WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_SECURITY_SERVER,92,57,149,14,ES_AUTOHSCROLL |
WS_DISABLED
ICON IDI_PADLOCK,IDC_STATIC,10,8,20,20
END
IDD_SHARE_PROPERTIES DIALOG 35, 5, 303, 292
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Sample Share"
FONT 8, "Tahoma"
BEGIN
DEFPUSHBUTTON "OK",IDOK,192,271,50,14,WS_DISABLED
PUSHBUTTON "Cancel",IDCANCEL,246,271,50,14
LTEXT "Sample Share",IDC_SHARE_HEADING,35,7,254,8
LTEXT "Use this properties window to define the parameters under which you will allow users to share files on this computer.",
IDC_STATIC,36,18,260,18
EDITTEXT IDC_SHARE_NAME,35,44,116,14,ES_AUTOHSCROLL
LTEXT "Name:",IDC_STATIC,7,47,22,8
LTEXT "Path:",IDC_STATIC,7,64,18,8
EDITTEXT IDC_SHARE_PATH,35,61,205,14,ES_AUTOHSCROLL
PUSHBUTTON "&Browse...",IDC_SHARE_BROWSE,246,61,50,14
CONTROL "Users can make changes to files and folders",
IDC_SHARE_WRITE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,
117,156,10
CONTROL "Follow links leading outside the path",IDC_SHARE_LINKS,
"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,7,
130,131,10
ICON IDI_VOLUME,IDC_STATIC,7,7,20,20
ICON IDI_OPTIONS,IDC_STATIC,7,91,20,20
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,83,289,1
LTEXT "General Options",IDC_OPTIONS_HEADING,35,96,261,8
ICON IDI_GLOBE,IDC_STATIC,9,154,20,20
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,149,288,1
LTEXT "Domain User Access",IDC_DOMAIN_HEADING,35,159,261,8
CONTROL "List1",IDC_DOMAIN_USERS,"SysListView32",LVS_REPORT |
LVS_SINGLESEL | LVS_SORTASCENDING | WS_BORDER |
WS_TABSTOP,7,178,234,83
PUSHBUTTON "&Add",IDC_SHARE_ADD,246,178,50,14
PUSHBUTTON "&Remove",IDC_SHARE_REMOVE,246,195,50,14,WS_DISABLED
END
IDD_BROWSER DIALOGEX 0, 0, 210, 167
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select Folder"
FONT 8, "Tahoma", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,101,146,50,14
PUSHBUTTON "Cancel",IDCANCEL,156,146,50,14
CONTROL "",IDC_FOLDERVIEW,"{FBF52F2D-9B93-11D2-B482-0020AFD69DE6}",
WS_TABSTOP,4,2,202,139
END
IDD_MAINPANEL DIALOGEX 0, 0, 344, 249
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "BeServed File and Print Services"
FONT 8, "Tahoma", 400, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,233,228,50,14
PUSHBUTTON "Cancel",IDCANCEL,287,228,50,14
END
IDD_MANAGE_QUEUE DIALOG 35, 40, 356, 201
STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_THICKFRAME
CAPTION "Manage Print Queue"
FONT 8, "Tahoma"
BEGIN
PUSHBUTTON "Close",IDCANCEL,298,180,50,14
CONTROL "List1",IDC_QUEUE_LIST,"SysListView32",LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_BORDER |
WS_TABSTOP,0,0,356,175
PUSHBUTTON "&Remove",IDC_REMOVE_JOB,241,180,52,14
PUSHBUTTON "&Pause",IDC_PAUSE_JOB,187,180,50,14
END
IDD_PRINTER_PROPERTIES DIALOGEX 45, 5, 303, 332
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Sample Printer"
FONT 8, "Tahoma", 0, 0, 0x0
BEGIN
LTEXT "Name:",IDC_STATIC,7,47,22,8
EDITTEXT IDC_PRINTER_NAME,40,44,116,14,ES_AUTOHSCROLL
LTEXT "Device:",IDC_STATIC,7,64,25,8
COMBOBOX IDC_PRINTER_DEVICE,40,61,200,82,CBS_DROPDOWNLIST |
CBS_SORT | WS_VSCROLL | WS_TABSTOP
LTEXT "Type:",IDC_STATIC,7,79,20,8
COMBOBOX IDC_PRINTER_TYPE,40,76,155,65,CBS_DROPDOWNLIST |
CBS_SORT | WS_VSCROLL | WS_TABSTOP
LTEXT "Model:",IDC_STATIC,7,94,22,8
COMBOBOX IDC_PRINTER_MODEL,40,91,155,99,CBS_DROPDOWNLIST |
CBS_SORT | WS_VSCROLL | WS_TABSTOP
LTEXT "Queue:",IDC_STATIC,7,147,25,8
EDITTEXT IDC_QUEUE_PATH,40,143,200,14,ES_AUTOHSCROLL
PUSHBUTTON "&Browse...",IDC_PRINTER_BROWSE,246,143,50,14
PUSHBUTTON "&Manage Queue",IDC_MANAGE,40,160,71,14
CONTROL "List1",IDC_DOMAIN_USERS,"SysListView32",LVS_REPORT |
LVS_SINGLESEL | LVS_SORTASCENDING | WS_BORDER |
WS_TABSTOP,7,210,234,83
PUSHBUTTON "&Add",IDC_PRINTER_ADD,246,210,50,14
PUSHBUTTON "&Remove",IDC_PRINTER_REMOVE,246,227,50,14,WS_DISABLED
DEFPUSHBUTTON "OK",IDOK,192,311,50,14
PUSHBUTTON "Cancel",IDCANCEL,246,311,50,14
LTEXT "Sample Printer",IDC_PRINTER_HEADING,35,7,254,8
LTEXT "Use this properties window to define the parameters under which you will allow users to access this printer from this computer.",
IDC_STATIC,36,18,260,18
ICON IDI_PRINTER,IDC_STATIC,7,7,20,20
ICON IDI_GLOBE,IDC_STATIC,9,186,20,20
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,181,287,1
LTEXT "Domain User Access",IDC_DOMAIN_HEADING,35,191,261,8
LTEXT "You must also specify a location on this computer where documents can be stored in preparation for printing. Since some of these documents may be large, and may be submitted by multiple users, you should select a location with ample storage.",
IDC_STATIC,7,113,289,27
END
IDD_PRINTERSHARING_DIALOG DIALOGEX 0, 0, 320, 252
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Printer Sharing"
FONT 8, "Tahoma", 0, 0, 0x1
BEGIN
CONTROL "List1",IDC_PRINTERS,"SysListView32",LVS_REPORT |
LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER |
WS_TABSTOP,7,67,306,149
LTEXT "Printer Sharing Preferences",IDC_MAIN_HEADING,40,7,116,
8
LTEXT "Normally, remote BeOS computers on your network do not have permission to use printers available from this computer. You may permit others to share the printers you have access to.",
IDC_STATIC,39,17,256,25
ICON IDI_SHARING,IDC_STATIC,9,8,20,20
PUSHBUTTON "&New",IDC_NEW_PRINTER,7,49,50,14
PUSHBUTTON "&Edit",IDC_EDIT_PRINTER,61,49,50,14
PUSHBUTTON "&Remove",IDC_REMOVE_PRINTER,115,49,50,14
PUSHBUTTON "Se&curity",IDC_SECURITY,263,49,50,14
LTEXT "Save your changes to file sharing preferences by clicking the OK button. This will not have an effect on users until you manually restart the BeServed file serving application.",
IDC_STATIC,7,221,306,19
END
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,4
PRODUCTVERSION 1,0,0,4
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "BeServed Control Panel Applet"
VALUE "FileVersion", "1, 0, 0, 5"
VALUE "InternalName", "BeServed"
VALUE "LegalCopyright", "Copyright (C) 2001-2003"
VALUE "OriginalFilename", "BeServed.exe"
VALUE "ProductName", "BeServed"
VALUE "ProductVersion", "1, 0, 0, 5"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_DOMAIN_USERS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 251
TOPMARGIN, 7
BOTTOMMARGIN, 222
END
IDD_FILESHARING_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 313
TOPMARGIN, 7
BOTTOMMARGIN, 245
END
IDD_SECURITY, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 241
TOPMARGIN, 7
BOTTOMMARGIN, 99
END
IDD_SHARE_PROPERTIES, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 296
TOPMARGIN, 7
BOTTOMMARGIN, 285
END
IDD_BROWSER, DIALOG
BEGIN
LEFTMARGIN, 4
RIGHTMARGIN, 206
TOPMARGIN, 2
BOTTOMMARGIN, 160
END
IDD_MAINPANEL, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 337
TOPMARGIN, 7
BOTTOMMARGIN, 242
END
IDD_MANAGE_QUEUE, DIALOG
BEGIN
BOTTOMMARGIN, 194
END
IDD_PRINTER_PROPERTIES, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 296
TOPMARGIN, 7
BOTTOMMARGIN, 325
END
IDD_PRINTERSHARING_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 313
TOPMARGIN, 7
BOTTOMMARGIN, 245
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_FILESHARING BITMAP "res\\filesharing.bmp"
IDB_GROUP BITMAP "res\\group.bmp"
IDB_USER BITMAP "res\\user.bmp"
IDB_VOLUME BITMAP "res\\volume.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Info
//
IDD_DOMAIN_USERS DLGINIT
BEGIN
IDC_DOMAIN_RIGHTS, 0x403, 10, 0
0x6552, 0x6461, 0x6f2d, 0x6c6e, 0x0079,
IDC_DOMAIN_RIGHTS, 0x403, 11, 0
0x6552, 0x6461, 0x772d, 0x6972, 0x6574, "\000"
0
END
IDD_SECURITY DLGINIT
BEGIN
IDC_SECURITY_TYPE, 0x403, 27, 0
0x6f4e, 0x4120, 0x7475, 0x6568, 0x746e, 0x6369, 0x7461, 0x6f69, 0x206e,
0x6552, 0x7571, 0x7269, 0x6465, "\000"
IDC_SECURITY_TYPE, 0x403, 29, 0
0x6542, 0x7553, 0x6572, 0x4120, 0x7475, 0x6568, 0x746e, 0x6369, 0x7461,
0x6f69, 0x206e, 0x6553, 0x7672, 0x7265, "\000"
0
END
IDD_BROWSER DLGINIT
BEGIN
IDC_FOLDERVIEW, 0x376, 150, 0
0x0008, 0x0000, 0x0031, 0x0039, 0x0039, 0x0039, 0x0030, 0x0037, 0x0037,
0x0030, 0x0300, 0x0000, 0x1f51, 0x0000, 0x175c, 0x0000, 0x0003, 0x0001,
0x0000, 0x0003, 0x0000, 0x0000, 0x0013, 0x0009, 0x8000, 0x0013, 0x0000,
0x0000, 0x000b, 0xffff, 0x000b, 0xffff, 0x000b, 0x0000, 0x000b, 0xffff,
0x000b, 0x0000, 0x000b, 0x0000, 0x000b, 0xffff, 0x000b, 0xffff, 0x000b,
0x0000, 0x000b, 0xffff, 0x0009, 0x5203, 0x0be3, 0x8f91, 0x11ce, 0xe39d,
0xaa00, 0x4b00, 0x51b8, 0x0001, 0x0000, 0x0190, 0x4244, 0x0001, 0x4105,
0x6972, 0x6c61, 0x000b, 0xffff, 0x000b, 0xffff, 0x0008, 0x0002, 0x0000,
0x0000, 0x000b, 0x0000,
0
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif
#include "res\scanappl.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,23 @@
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileSharing", "FileSharing.vcproj", "{E318D966-15D7-4FBD-9F7D-8F42974F645D}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{E318D966-15D7-4FBD-9F7D-8F42974F645D}.Debug.ActiveCfg = Debug|Win32
{E318D966-15D7-4FBD-9F7D-8F42974F645D}.Debug.Build.0 = Debug|Win32
{E318D966-15D7-4FBD-9F7D-8F42974F645D}.Release.ActiveCfg = Release|Win32
{E318D966-15D7-4FBD-9F7D-8F42974F645D}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionItems) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,308 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="FileSharing"
SccProjectName=""
SccLocalPath=""
Keyword="MFCProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
UseOfMFC="1"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,_USRDLL"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="3"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Release/FileSharing.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="ws2_32.lib"
OutputFile="Release/FileSharing.cpl"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile="FileSharing.def"
ProgramDatabaseFile=".\Release/FileSharing.pdb"
SubSystem="2"
ImportLibrary=".\Release/FileSharing.lib"/>
<Tool
Name="VCMIDLTool"
MkTypLibCompatible="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Release/FileSharing.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
UseOfMFC="1"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,_USRDLL"
RuntimeLibrary="1"
UsePrecompiledHeader="3"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Debug/FileSharing.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="ws2_32.lib"
OutputFile="Debug/FileSharing.cpl"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile="FileSharing.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/FileSharing.pdb"
SubSystem="2"
ImportLibrary="FileSharing.lib"/>
<Tool
Name="VCMIDLTool"
MkTypLibCompatible="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Debug/FileSharing.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="BrowseFolders.cpp">
</File>
<File
RelativePath="DomainUsers.cpp">
</File>
<File
RelativePath=".\FileSharing.cpp">
</File>
<File
RelativePath=".\FileSharing.rc">
</File>
<File
RelativePath="FileSharingDlg.cpp">
</File>
<File
RelativePath="MainPanel.cpp">
</File>
<File
RelativePath="ManageQueue.cpp">
</File>
<File
RelativePath="PrinterProperties.cpp">
</File>
<File
RelativePath="PrinterSharingDlg.cpp">
</File>
<File
RelativePath="Security.cpp">
</File>
<File
RelativePath="ShareProperties.cpp">
</File>
<File
RelativePath=".\StdAfx.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
<File
RelativePath=".\ctrlpan.cpp">
</File>
<File
RelativePath="folderview.cpp">
</File>
<File
RelativePath="mtvfolder.cpp">
</File>
<File
RelativePath="rpc.cpp">
</File>
<File
RelativePath=".\scanpan.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="BrowseFolders.h">
</File>
<File
RelativePath="DomainUsers.h">
</File>
<File
RelativePath=".\FileSharing.h">
</File>
<File
RelativePath="FileSharingDlg.h">
</File>
<File
RelativePath="MainPanel.h">
</File>
<File
RelativePath="ManageQueue.h">
</File>
<File
RelativePath="PrinterProperties.h">
</File>
<File
RelativePath="PrinterSharingDlg.h">
</File>
<File
RelativePath=".\Resource.h">
</File>
<File
RelativePath="Security.h">
</File>
<File
RelativePath="ShareProperties.h">
</File>
<File
RelativePath=".\StdAfx.h">
</File>
<File
RelativePath=".\ctrlpan.h">
</File>
<File
RelativePath="folderview.h">
</File>
<File
RelativePath="mtvfolder.h">
</File>
<File
RelativePath="printing.h">
</File>
<File
RelativePath="rpc.h">
</File>
<File
RelativePath=".\scanpan.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe">
<File
RelativePath=".\res\FileSharing.ico">
</File>
<File
RelativePath=".\res\FileSharing.rc2">
</File>
<File
RelativePath="res\bitmap1.bmp">
</File>
<File
RelativePath="res\filesharing.bmp">
</File>
<File
RelativePath="res\group.bmp">
</File>
<File
RelativePath="res\icon1.ico">
</File>
<File
RelativePath="res\idi_globe.ico">
</File>
<File
RelativePath="res\lightbulb.ico">
</File>
<File
RelativePath="res\options.ico">
</File>
<File
RelativePath="res\padlock.ico">
</File>
<File
RelativePath="res\printer.ico">
</File>
<File
RelativePath="res\scanappl.ico">
</File>
<File
RelativePath="res\sharing.ico">
</File>
<File
RelativePath="res\user.bmp">
</File>
<File
RelativePath="res\volume.bmp">
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,727 @@
// FileSharingDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ctype.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "becompat.h"
#include "betalk.h"
#include "FileSharing.h"
#include "FileSharingDlg.h"
#include "ShareProperties.h"
#include "printing.h"
#include "Security.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern bt_fileShare_t fileShares[];
extern bt_printer sharedPrinters[];
extern char authServerName[];
extern unsigned int authServerIP;
char tokBuffer[MAX_NAME_LENGTH + 1], *tokPtr;
char *keywords[] =
{
"share",
"as",
"set",
"read",
"write",
"read-write",
"promiscuous",
"on",
"to",
"authenticate",
"with",
"group",
"printer",
"print",
"is",
"spooled",
"device",
"type",
NULL
};
/////////////////////////////////////////////////////////////////////////////
// CFileSharingDlg dialog
CFileSharingDlg::CFileSharingDlg()
: CPropertyPage(CFileSharingDlg::IDD)
{
//{{AFX_DATA_INIT(CFileSharingDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CFileSharingDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFileSharingDlg)
DDX_Control(pDX, IDC_SHARE_REMOVE, m_removeBtn);
DDX_Control(pDX, IDC_SHARE_EDIT, m_editBtn);
DDX_Control(pDX, IDC_MAIN_HEADING, m_heading);
DDX_Control(pDX, IDC_SHARE_LIST, m_shareList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFileSharingDlg, CDialog)
//{{AFX_MSG_MAP(CFileSharingDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_NOTIFY(NM_CLICK, IDC_SHARE_LIST, OnClickShareList)
ON_NOTIFY(NM_DBLCLK, IDC_SHARE_LIST, OnDblclkShareList)
ON_BN_CLICKED(IDC_SHARE_EDIT, OnShareEdit)
ON_BN_CLICKED(IDC_SHARE_REMOVE, OnShareRemove)
ON_BN_CLICKED(IDC_SHARE_NEW, OnShareNew)
ON_BN_CLICKED(IDC_SECURITY, OnSecurity)
//}}AFX_MSG_MAP
ON_WM_DESTROY()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFileSharingDlg message handlers
BOOL CFileSharingDlg::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_editBtn.EnableWindow(FALSE);
m_removeBtn.EnableWindow(FALSE);
m_shareList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_shareList.InsertColumn(0, "Share Name", LVCFMT_LEFT, 150);
m_shareList.InsertColumn(1, "Access", LVCFMT_LEFT, 80);
m_shareList.InsertColumn(2, "Path", LVCFMT_LEFT, 200);
CBitmap fileShare;
fileShare.LoadBitmap(IDB_VOLUME);
m_images.Create(16, 16, FALSE, 2, 0);
m_images.Add(&fileShare, (COLORREF) 0);
m_shareList.SetImageList(&m_images, LVSIL_SMALL);
m_hBoldFont = InitializeControlFont("Tahoma", FW_BOLD, 8);
m_heading.SendMessage(WM_SETFONT, (WPARAM) m_hBoldFont, MAKELPARAM(TRUE, 0));
InitShares();
ListShares();
return TRUE;
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CFileSharingDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CFileSharingDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
// InitShares()
//
void CFileSharingDlg::InitShares()
{
extern char settingsFile[];
FILE *fp;
char buffer[512];
int i, length;
for (i = 0; i < BT_MAX_FILE_SHARES; i++)
{
fileShares[i].name[0] = 0;
fileShares[i].path[0] = 0;
fileShares[i].used = false;
fileShares[i].readOnly = true;
fileShares[i].followLinks = false;
fileShares[i].next = NULL;
}
for (i = 0; i < BT_MAX_PRINTER_SHARES; i++)
{
sharedPrinters[i].printerName[0] = 0;
sharedPrinters[i].deviceName[0] = 0;
sharedPrinters[i].spoolDir[0] = 0;
sharedPrinters[i].rights = NULL;
sharedPrinters[i].security = BT_AUTH_NONE;
sharedPrinters[i].used = false;
sharedPrinters[i].killed = false;
}
GetCurrentDirectory(sizeof(buffer), buffer);
fp = fopen(settingsFile, "r");
if (fp)
{
while (fgets(buffer, sizeof(buffer) - 1, fp))
{
length = strlen(buffer);
if (length <= 1 || buffer[0] == '#')
continue;
if (buffer[length - 1] == '\n')
buffer[--length] = 0;
if (strncmp(buffer, "share ", 6) == 0)
GetFileShare(buffer);
else if (strncmp(buffer, "set ", 4) == 0)
GetShareProperty(buffer);
else if (strncmp(buffer, "grant ", 6) == 0)
GetGrant(buffer);
else if (strncmp(buffer, "authenticate ", 13) == 0)
GetAuthenticate(buffer);
else if (strncmp(buffer, "printer ", 8) == 0)
GetPrinter(buffer);
}
fclose(fp);
}
}
// GetFileShare()
//
void CFileSharingDlg::GetFileShare(const char *buffer)
{
// struct stat st;
char path[B_PATH_NAME_LENGTH], share[MAX_NAME_LENGTH + 1], *folder;
int i, tok;
// Skip over SHARE command.
tokPtr = (char *) buffer + (6 * sizeof(char));
tok = GetToken();
if (tok != BT_TOKEN_STRING)
return;
strcpy(path, tokBuffer);
tok = GetToken();
if (tok != BT_TOKEN_AS)
return;
tok = GetToken();
if (tok != BT_TOKEN_STRING)
return;
strcpy(share, tokBuffer);
// Now verify that the share name specified has not already been
// used to share another path.
folder = GetSharePath(share);
if (folder)
return;
for (i = 0; i < BT_MAX_FILE_SHARES; i++)
if (!fileShares[i].used)
{
strcpy(fileShares[i].name, share);
strcpy(fileShares[i].path, path);
fileShares[i].used = true;
return;
}
}
void CFileSharingDlg::GetShareProperty(const char *buffer)
{
char share[B_FILE_NAME_LENGTH + 1];
int tok, shareId;
// Skip over SET command.
tokPtr = (char *) buffer + (4 * sizeof(char));
tok = GetToken();
if (tok != BT_TOKEN_STRING)
return;
strcpy(share, tokBuffer);
// Get the index of the share referred to. If the named share cannot be
// found, then abort.
shareId = GetShareId(share);
if (shareId < 0)
return;
tok = GetToken();
if (tok == BT_TOKEN_READWRITE)
fileShares[shareId].readOnly = false;
}
void CFileSharingDlg::GetGrant(const char *buffer)
{
char share[MAX_NAME_LENGTH + 1];
int tok, rights;
bool isGroup = false;
// Skip over GRANT command.
tokPtr = (char *) buffer + (6 * sizeof(char));
rights = 0;
do
{
tok = GetToken();
if (tok == BT_TOKEN_READ)
{
rights |= BT_RIGHTS_READ;
tok = GetToken();
}
else if (tok == BT_TOKEN_WRITE)
{
rights |= BT_RIGHTS_WRITE;
tok = GetToken();
}
else if (tok == BT_TOKEN_PRINT)
{
rights |= BT_RIGHTS_PRINT;
tok = GetToken();
}
} while (tok == BT_TOKEN_COMMA);
if (tok != BT_TOKEN_ON)
return;
tok = GetToken();
if (tok != BT_TOKEN_STRING)
return;
strcpy(share, tokBuffer);
tok = GetToken();
if (tok != BT_TOKEN_TO)
return;
tok = GetToken();
if (tok == BT_TOKEN_GROUP)
{
isGroup = true;
tok = GetToken();
}
if (tok != BT_TOKEN_STRING)
return;
AddUserRights(share, tokBuffer, rights, isGroup);
}
void CFileSharingDlg::GetAuthenticate(const char *buffer)
{
struct hostent *ent;
int i, tok;
// Skip over AUTHENTICATE command.
tokPtr = (char *) buffer + (13 * sizeof(char));
tok = GetToken();
if (tok != BT_TOKEN_WITH)
return;
tok = GetToken();
if (tok != BT_TOKEN_STRING)
return;
// Look up address for given host.
strcpy(authServerName, tokBuffer);
ent = gethostbyname(tokBuffer);
if (ent != NULL)
authServerIP = ntohl(*((unsigned int *) ent->h_addr));
else
authServerIP = 0;
// Make all file shares use BeSure authentication.
for (i = 0; i < BT_MAX_FILE_SHARES; i++)
fileShares[i].security = BT_AUTH_BESURE;
// Make all shared printers use BeSure authentication.
for (i = 0; i < BT_MAX_PRINTER_SHARES; i++)
sharedPrinters[i].security = BT_AUTH_BESURE;
}
void CFileSharingDlg::AddUserRights(char *share, char *user, int rights, bool isGroup)
{
bt_user_rights *ur;
bt_printer *printer = NULL;
int shareId = -1;
// Now make sure that the rights make sense. If we're granting the
// right to print, we should not have granted the right to read or write.
// We should also be working exclusively with a printer.
if (rights & BT_RIGHTS_PRINT)
{
if ((rights & BT_RIGHTS_READ) == 0 && (rights & BT_RIGHTS_WRITE) == 0)
printer = btFindPrinter(share);
}
else
shareId = GetShareId(share);
// If we didn't find a printer or a file share, then quit here.
if (!printer && shareId < 0)
return;
ur = (bt_user_rights *) malloc(sizeof(bt_user_rights));
if (ur)
{
ur->user = (char *) malloc(strlen(user) + 1);
if (ur->user)
{
strcpy(ur->user, user);
ur->rights = rights;
ur->isGroup = isGroup;
if (printer)
{
ur->next = printer->rights;
printer->rights = ur;
}
else
{
ur->next = fileShares[shareId].rights;
fileShares[shareId].rights = ur;
}
}
else
free(ur);
}
}
void CFileSharingDlg::GetPrinter(const char *buffer)
{
bt_printer printer;
int i, tok;
// Skip over PRINTER command.
tokPtr = (char *) buffer + (8 * sizeof(char));
// Now get the name this printer will be shared as.
tok = GetToken();
if (tok != BT_TOKEN_STRING)
return;
strcpy(printer.printerName, tokBuffer);
// Bypass the IS and TYPE keywords.
tok = GetToken();
if (tok != BT_TOKEN_IS)
return;
tok = GetToken();
if (tok != BT_TOKEN_TYPE)
return;
// Get the device type of the printer.
tok = GetToken();
if (tok != BT_TOKEN_STRING)
return;
strcpy(printer.deviceType, tokBuffer);
// Bypass the DEVICE keyword.
tok = GetToken();
if (tok != BT_TOKEN_DEVICE)
return;
// Get the system device name of the printer.
tok = GetToken();
if (tok != BT_TOKEN_STRING)
return;
strcpy(printer.deviceName, tokBuffer);
// Bypass the SPOOLED TO keywords.
tok = GetToken();
if (tok != BT_TOKEN_SPOOLED)
return;
tok = GetToken();
if (tok != BT_TOKEN_TO)
return;
// Get the spooling folder, where temporary files will be stored.
tok = GetToken();
if (tok != BT_TOKEN_STRING)
return;
strcpy(printer.spoolDir, tokBuffer);
for (i = 0; i < BT_MAX_PRINTER_SHARES; i++)
if (!sharedPrinters[i].used)
{
sharedPrinters[i].used = true;
strcpy(sharedPrinters[i].printerName, printer.printerName);
strcpy(sharedPrinters[i].deviceType, printer.deviceType);
strcpy(sharedPrinters[i].deviceName, printer.deviceName);
strcpy(sharedPrinters[i].spoolDir, printer.spoolDir);
break;
}
}
int CFileSharingDlg::GetToken()
{
bool quoted = false;
tokBuffer[0] = 0;
while (*tokPtr && iswhite(*tokPtr))
tokPtr++;
if (*tokPtr == ',')
{
*tokPtr++;
return BT_TOKEN_COMMA;
}
else if (*tokPtr == '\"')
{
quoted = true;
tokPtr++;
}
if (isalnum(*tokPtr) || *tokPtr == '\\')
{
int i = 0;
while (isalnum(*tokPtr) || isValid(*tokPtr) || (quoted && *tokPtr == ' '))
if (i < MAX_NAME_LENGTH)
tokBuffer[i++] = *tokPtr++;
else
tokPtr++;
tokBuffer[i] = 0;
if (!quoted)
for (i = 0; keywords[i]; i++)
if (stricmp(tokBuffer, keywords[i]) == 0)
return ++i;
if (quoted)
if (*tokPtr != '\"')
return BT_TOKEN_ERROR;
else
tokPtr++;
return BT_TOKEN_STRING;
}
return BT_TOKEN_ERROR;
}
char *CFileSharingDlg::GetSharePath(char *shareName)
{
int i;
for (i = 0; i < BT_MAX_FILE_SHARES; i++)
if (fileShares[i].used)
if (stricmp(fileShares[i].name, shareName) == 0)
return fileShares[i].path;
return NULL;
}
int CFileSharingDlg::GetShareId(char *shareName)
{
int i;
for (i = 0; i < BT_MAX_FILE_SHARES; i++)
if (fileShares[i].used)
if (stricmp(fileShares[i].name, shareName) == 0)
return i;
return -1;
}
// btFindPrinter()
//
bt_printer *CFileSharingDlg::btFindPrinter(char *printerName)
{
int i;
for (i = 0; i < BT_MAX_PRINTER_SHARES; i++)
if (sharedPrinters[i].used)
if (stricmp(printerName, sharedPrinters[i].printerName) == 0)
return &sharedPrinters[i];
return NULL;
}
// WriteShares()
//
void CFileSharingDlg::WriteShares(FILE *fp)
{
bt_user_rights *ur;
int i;
if (fp)
{
for (i = 0; i < BT_MAX_FILE_SHARES; i++)
if (fileShares[i].used)
{
fprintf(fp, "share ");
PrintString(fp, fileShares[i].path);
fprintf(fp, " as ");
PrintString(fp, fileShares[i].name);
fputc('\n', fp);
if (!fileShares[i].readOnly)
{
fprintf(fp, "set ");
PrintString(fp, fileShares[i].name);
fprintf(fp, " read-write\n");
}
if (fileShares[i].followLinks)
{
fprintf(fp, "set ");
PrintString(fp, fileShares[i].name);
fprintf(fp, " promiscuous\n");
}
for (ur = fileShares[i].rights; ur; ur = ur->next)
{
int rights = ur->rights;
fprintf(fp, "grant ");
do
{
if (rights & BT_RIGHTS_READ)
{
fprintf(fp, "read");
rights &= ~BT_RIGHTS_READ;
}
else if (rights & BT_RIGHTS_WRITE)
{
fprintf(fp, "write");
rights &= ~BT_RIGHTS_WRITE;
}
fprintf(fp, "%c", rights > 0 ? ',' : ' ');
} while (rights > 0);
fprintf(fp, "on ");
PrintString(fp, fileShares[i].name);
fprintf(fp, " to ");
if (ur->isGroup)
fprintf(fp, "group ");
fprintf(fp, "%s\n", ur->user);
}
}
}
}
// ListShares()
//
void CFileSharingDlg::ListShares()
{
struct stat st;
int i, nItem;
for (i = 0; i < BT_MAX_FILE_SHARES; i++)
if (fileShares[i].used)
{
nItem = m_shareList.InsertItem(0, fileShares[i].name, 0);
m_shareList.SetItemText(nItem, 1, fileShares[i].readOnly ? "Read-only" : "Read-Write");
m_shareList.SetItemText(nItem, 2, stat(fileShares[i].path, &st) == 0 ? fileShares[i].path : "--- Invalid Path ---");
m_shareList.SetItemData(nItem, i);
}
}
void CFileSharingDlg::OnClickShareList(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
m_editBtn.EnableWindow(GetSelectedListItem(&m_shareList) != -1);
m_removeBtn.EnableWindow(GetSelectedListItem(&m_shareList) != -1);
}
void CFileSharingDlg::OnDblclkShareList(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
OnShareEdit();
}
void CFileSharingDlg::OnShareEdit()
{
CShareProperties share;
int nItem = GetSelectedListItem(&m_shareList);
if (nItem != -1)
if (share.ShowProperties(m_shareList.GetItemData(nItem)) == IDOK)
RefreshShare(nItem);
}
void CFileSharingDlg::OnShareRemove()
{
int nItem = GetSelectedListItem(&m_shareList);
if (nItem >= 0)
if (MessageBox(WARN_REMOVE_SHARE, fileShares[nItem].name, MB_YESNO | MB_ICONQUESTION) == IDYES)
{
fileShares[nItem].used = false;
m_shareList.DeleteItem(nItem);
}
}
void CFileSharingDlg::OnShareNew()
{
CShareProperties share;
int nIndex = m_shareList.GetItemCount();
strcpy(fileShares[nIndex].name, "Untitled");
strcpy(fileShares[nIndex].path, "c:\\temp");
fileShares[nIndex].readOnly = true;
fileShares[nIndex].followLinks = false;
if (share.ShowProperties(nIndex) == IDOK)
{
int nItem = m_shareList.InsertItem(0, fileShares[nIndex].name, 0);
m_shareList.SetItemText(nItem, 1, fileShares[nIndex].readOnly ? "Read-only" : "Read-Write");
m_shareList.SetItemText(nItem, 2, fileShares[nIndex].path);
m_shareList.SetItemData(nItem, nIndex);
fileShares[nIndex].used = true;
}
}
void CFileSharingDlg::RefreshShare(int nItem)
{
int nIndex = m_shareList.GetItemData(nItem);
m_shareList.SetItemText(nItem, 0, fileShares[nIndex].name);
m_shareList.SetItemText(nItem, 1, fileShares[nIndex].readOnly ? "Read-only" : "Read-Write");
m_shareList.SetItemText(nItem, 2, fileShares[nIndex].path);
}
void CFileSharingDlg::OnSecurity()
{
CSecurity security;
security.DoModal();
}

View File

@ -0,0 +1,83 @@
// FileSharingDlg.h : header file
//
#if !defined(AFX_FILESHARINGDLG_H__AF7E12FC_F583_11D5_90F9_00C04F0972A7__INCLUDED_)
#define AFX_FILESHARINGDLG_H__AF7E12FC_F583_11D5_90F9_00C04F0972A7__INCLUDED_
#include "printing.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CFileSharingDlg dialog
class CFileSharingDlg : public CPropertyPage
{
// Construction
public:
CFileSharingDlg(); // standard constructor
// Public method used to save changes.
void WriteShares(FILE *fp);
// Dialog Data
//{{AFX_DATA(CFileSharingDlg)
enum { IDD = IDD_FILESHARING_DIALOG };
CButton m_removeBtn;
CButton m_editBtn;
CStatic m_heading;
CListCtrl m_shareList;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFileSharingDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
HFONT m_hBoldFont;
CImageList m_images;
// Generated message map functions
//{{AFX_MSG(CFileSharingDlg)
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnClickShareList(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDblclkShareList(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnShareEdit();
afx_msg void OnShareRemove();
afx_msg void OnShareNew();
afx_msg void OnSave();
afx_msg void OnDeploy();
afx_msg void OnSecurity();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
void InitShares();
void GetFileShare(const char *buffer);
void GetShareProperty(const char *buffer);
void GetGrant(const char *buffer);
void GetAuthenticate(const char *buffer);
void AddUserRights(char *share, char *user, int rights, bool isGroup);
void GetPrinter(const char *buffer);
int GetToken();
char * GetSharePath(char *shareName);
int GetShareId(char *shareName);
bt_printer *btFindPrinter(char *printerName);
void ListShares();
void RefreshShare(int nItem);
};
#define WARN_REMOVE_SHARE "Removing this file share will prevent other users on your network from accessing certain files on this computer. Are you sure you want to remove this file share?"
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FILESHARINGDLG_H__AF7E12FC_F583_11D5_90F9_00C04F0972A7__INCLUDED_)

View File

@ -0,0 +1,104 @@
// MainPanel.cpp : implementation file
//
#include "stdafx.h"
#include "winsvc.h"
#include "FileSharing.h"
#include "MainPanel.h"
#define SERVICE_CONTROL_USER 128
#define SERVICE_USER_CONTROL_HUP SERVICE_CONTROL_USER + 1
char settingsFile[_MAX_PATH];
// CMainPanel dialog
IMPLEMENT_DYNAMIC(CMainPanel, CPropertySheet)
CMainPanel::CMainPanel(CWnd* pParent /*=NULL*/)
: CPropertySheet("BeServed File and Print Services", pParent), m_filePanel()
{
AddPage(&m_filePanel);
AddPage(&m_printerPanel);
}
CMainPanel::~CMainPanel()
{
}
void CMainPanel::DoDataExchange(CDataExchange* pDX)
{
CPropertySheet::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CMainPanel, CPropertySheet)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()
// CMainPanel message handlers
BOOL CMainPanel::OnInitDialog()
{
HKEY hRegKey;
DWORD dwType = 0, dwSize;
char *p;
// Get service executable folder.
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\BeServed", 0, KEY_READ, &hRegKey) == ERROR_SUCCESS)
{
if (RegQueryValueEx(hRegKey, (LPTSTR) "ImagePath", NULL, &dwType, NULL, &dwSize) == ERROR_SUCCESS)
RegQueryValueEx(hRegKey, (LPTSTR) "ImagePath", NULL, &dwType, (LPBYTE) settingsFile, &dwSize);
RegCloseKey(hRegKey);
}
if ((p = strrchr(settingsFile, '\\')) != NULL)
*p = 0;
strcat(settingsFile, "\\BeServed-Settings");
BOOL bResult = CPropertySheet::OnInitDialog();
return bResult;
}
// OnBnClickedOk()
//
void CMainPanel::OnBnClickedOk()
{
extern unsigned authServerIP;
extern char authServerName[];
SC_HANDLE hManager, hService;
SERVICE_STATUS status;
FILE *fp;
fp = fopen(settingsFile, "w");
if (fp)
{
if (authServerIP)
fprintf(fp, "authenticate with %s\n", authServerName);
m_filePanel.WriteShares(fp);
m_printerPanel.WritePrinters(fp);
fclose(fp);
}
hManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_CONNECT);
if (hManager)
{
hService = OpenService(hManager, "BeServed", SERVICE_USER_DEFINED_CONTROL);
if (hService)
{
ControlService(hService, SERVICE_USER_CONTROL_HUP, &status);
CloseServiceHandle(hService);
}
CloseServiceHandle(hManager);
}
EndDialog(IDOK);
}

View File

@ -0,0 +1,30 @@
#pragma once
#include "FileSharingDlg.h"
#include "PrinterSharingDlg.h"
// CMainPanel property sheet
class CMainPanel : public CPropertySheet
{
DECLARE_DYNAMIC(CMainPanel)
public:
CMainPanel(CWnd* pParent = NULL); // standard constructor
virtual ~CMainPanel();
// Dialog Data
enum { IDD = IDD_MAINPANEL };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
CFileSharingDlg m_filePanel;
CPrinterSharingDlg m_printerPanel;
public:
virtual BOOL OnInitDialog();
afx_msg void OnBnClickedOk();
};

View File

@ -0,0 +1,222 @@
// ManageQueue.cpp : implementation file
//
#include "stdafx.h"
#include "FileSharing.h"
#include "ManageQueue.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CManageQueue dialog
CManageQueue::CManageQueue(CWnd* pParent /*=NULL*/)
: CDialog(CManageQueue::IDD, pParent)
{
//{{AFX_DATA_INIT(CManageQueue)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CManageQueue::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CManageQueue)
DDX_Control(pDX, IDC_PAUSE_JOB, m_pauseBtn);
DDX_Control(pDX, IDC_REMOVE_JOB, m_removeBtn);
DDX_Control(pDX, IDC_QUEUE_LIST, m_queue);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CManageQueue, CDialog)
//{{AFX_MSG_MAP(CManageQueue)
ON_WM_TIMER()
ON_NOTIFY(NM_CLICK, IDC_QUEUE_LIST, OnClickQueueList)
ON_BN_CLICKED(IDC_PAUSE_JOB, OnPauseJob)
ON_BN_CLICKED(IDC_REMOVE_JOB, OnRemoveJob)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CManageQueue message handlers
int CManageQueue::ShowQueue(bt_printer *printer)
{
this->printer = printer;
return DoModal();
}
BOOL CManageQueue::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowText(CString(printer->printerName) + " Queue");
m_queue.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_queue.InsertColumn(0, "Document Name", LVCFMT_LEFT, 190);
m_queue.InsertColumn(1, "Status", LVCFMT_LEFT, 90);
m_queue.InsertColumn(2, "Submitted By", LVCFMT_LEFT, 110);
m_queue.InsertColumn(3, "Size", LVCFMT_RIGHT, 70);
m_queue.InsertColumn(4, "Submitted On", LVCFMT_LEFT, 170);
m_queue.InsertColumn(5, "Submitted From", LVCFMT_LEFT, 120);
BuildJobList();
return TRUE;
}
void CManageQueue::OnTimer(UINT nIDEvent)
{
CDialog::OnTimer(nIDEvent);
}
void CManageQueue::OnClickQueueList(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
int nItem = GetSelectedListItem(&m_queue);
if (nItem != -1)
{
CString status = m_queue.GetItemText(nItem, 1);
if (status == "Paused...")
m_pauseBtn.SetWindowText("&Continue");
else
m_pauseBtn.SetWindowText("&Pause");
}
}
void CManageQueue::OnPauseJob()
{
int nItem = GetSelectedListItem(&m_queue);
if (nItem != -1)
{
bt_print_job *printJob = (bt_print_job *) m_queue.GetItemData(nItem);
if (printJob)
{
CString status = m_queue.GetItemText(nItem, 1);
if (status == "Paused...")
{
WritePrivateProfileString("PrintJob", "Status", "Scheduling...", printJob->jobFile);
m_queue.SetItemText(nItem, 1, "Scheduling...");
m_pauseBtn.SetWindowText("&Pause");
}
else
{
WritePrivateProfileString("PrintJob", "Status", "Paused...", printJob->jobFile);
m_queue.SetItemText(nItem, 1, "Paused...");
m_pauseBtn.SetWindowText("&Continue");
}
}
}
m_queue.SetFocus();
}
void CManageQueue::OnRemoveJob()
{
char dataFile[B_PATH_NAME_LENGTH];
int nItem = GetSelectedListItem(&m_queue);
if (nItem != -1)
{
bt_print_job *printJob = (bt_print_job *) m_queue.GetItemData(nItem);
if (printJob)
{
GetPrivateProfileString("PrintJob", "DataFile", "", dataFile, sizeof(dataFile), printJob->jobFile);
remove(dataFile);
remove(printJob->jobFile);
}
}
}
void CManageQueue::OnDestroy()
{
CDialog::OnDestroy();
bt_print_job *job = rootJob, *nextJob;
while (job)
{
nextJob = job->next;
free(job);
job = nextJob;
}
}
void CManageQueue::BuildJobList()
{
bt_print_job *job;
struct _finddata_t fileInfo;
char path[B_PATH_NAME_LENGTH];
long int finder, result;
rootJob = NULL;
sprintf(path, "%s\\*.job", printer->spoolDir);
finder = result = _findfirst(path, &fileInfo);
while (result != -1)
{
// Create the fully-qualified path to this print job file, then check
// its status.
sprintf(path, "%s\\%s", printer->spoolDir, fileInfo.name);
job = AddPrintJob(printer, path);
job->next = rootJob;
rootJob = job;
// Get the next print job.
result = _findnext(finder, &fileInfo);
}
}
bt_print_job *CManageQueue::AddPrintJob(bt_printer *printer, char *path)
{
bt_print_job *job;
struct stat st;
char dataFile[B_PATH_NAME_LENGTH];
char buffer[B_FILE_NAME_LENGTH];
int nItem;
job = new bt_print_job;
job->next = NULL;
strcpy(job->jobFile, path);
GetPrivateProfileString("PrintJob", "JobName", "Untitled", job->jobName, sizeof(job->jobName), path);
nItem = m_queue.InsertItem(0, job->jobName);
m_queue.SetItemData(nItem, (DWORD)(LPVOID) job);
GetPrivateProfileString("PrintJob", "Status", "", job->status, sizeof(job->status), path);
m_queue.SetItemText(nItem, 1, job->status);
GetPrivateProfileString("PrintJob", "User", "Unknown", job->sourceUser, sizeof(job->sourceUser), path);
m_queue.SetItemText(nItem, 2, job->sourceUser);
GetPrivateProfileString("PrintJob", "DataFile", "", buffer, sizeof(buffer), path);
sprintf(dataFile, "%s\\%s", printer->spoolDir, buffer);
if (stat(dataFile, &st) == 0)
{
if (st.st_size > 1024 * 1024)
sprintf(buffer, "%.2f MB", (float) st.st_size / (1024.0 * 1024.0));
else if (st.st_size > 1024)
sprintf(buffer, "%d KB", st.st_size / 1024);
else
sprintf(buffer, "%d", st.st_size);
m_queue.SetItemText(nItem, 3, buffer);
struct tm *time = localtime(&st.st_ctime);
strftime(buffer, sizeof(buffer), "%a %b %d, %Y at %I:%M %p", time);
m_queue.SetItemText(nItem, 4, buffer);
}
GetPrivateProfileString("PrintJob", "Source", "Unknown", buffer, sizeof(buffer), path);
m_queue.SetItemText(nItem, 5, buffer);
job->sourceAddr = inet_addr(buffer);
return job;
}

View File

@ -0,0 +1,63 @@
#if !defined(AFX_MANAGEQUEUE_H__CF35E7B7_4D1E_4FC2_AA9C_5308F6334777__INCLUDED_)
#define AFX_MANAGEQUEUE_H__CF35E7B7_4D1E_4FC2_AA9C_5308F6334777__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "printing.h"
// ManageQueue.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CManageQueue dialog
class CManageQueue : public CDialog
{
// Construction
public:
CManageQueue(CWnd* pParent = NULL); // standard constructor
int ShowQueue(bt_printer *printer);
// Dialog Data
//{{AFX_DATA(CManageQueue)
enum { IDD = IDD_MANAGE_QUEUE };
CButton m_pauseBtn;
CButton m_removeBtn;
CListCtrl m_queue;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CManageQueue)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
void BuildJobList();
bt_print_job *AddPrintJob(bt_printer *printer, char *path);
bt_printer *printer;
bt_print_job *rootJob;
// Generated message map functions
//{{AFX_MSG(CManageQueue)
virtual BOOL OnInitDialog();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnClickQueueList(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnPauseJob();
afx_msg void OnRemoveJob();
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MANAGEQUEUE_H__CF35E7B7_4D1E_4FC2_AA9C_5308F6334777__INCLUDED_)

View File

@ -0,0 +1,296 @@
// PrinterProperties.cpp : implementation file
//
#include "stdafx.h"
#include "winspool.h"
#include "FileSharing.h"
#include "PrinterProperties.h"
#include "BrowseFolders.h"
#include "DomainUsers.h"
#include "ManageQueue.h"
#include "printing.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern bt_printer sharedPrinters[];
extern unsigned int authServerIP;
/////////////////////////////////////////////////////////////////////////////
// CPrinterProperties dialog
CPrinterProperties::CPrinterProperties(CWnd* pParent /*=NULL*/)
: CDialog(CPrinterProperties::IDD, pParent)
{
//{{AFX_DATA_INIT(CPrinterProperties)
m_printerName = _T("");
m_queuePath = _T("");
//}}AFX_DATA_INIT
}
void CPrinterProperties::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrinterProperties)
DDX_Control(pDX, IDC_PRINTER_TYPE, m_printerType);
DDX_Control(pDX, IDC_PRINTER_NAME, m_nameCtrl);
DDX_Control(pDX, IDOK, m_okayBtn);
DDX_Control(pDX, IDC_PRINTER_REMOVE, m_removeBtn);
DDX_Control(pDX, IDC_PRINTER_HEADING, m_heading);
DDX_Control(pDX, IDC_DOMAIN_HEADING, m_domainHeading);
DDX_Control(pDX, IDC_PRINTER_DEVICE, m_device);
DDX_Control(pDX, IDC_PRINTER_ADD, m_addBtn);
DDX_Control(pDX, IDC_DOMAIN_USERS, m_userList);
DDX_Text(pDX, IDC_PRINTER_NAME, m_printerName);
DDX_Text(pDX, IDC_QUEUE_PATH, m_queuePath);
//}}AFX_DATA_MAP
DDX_Control(pDX, IDC_PRINTER_MODEL, m_printerModel);
}
BEGIN_MESSAGE_MAP(CPrinterProperties, CDialog)
//{{AFX_MSG_MAP(CPrinterProperties)
ON_NOTIFY(NM_CLICK, IDC_DOMAIN_USERS, OnClickDomainUsers)
ON_BN_CLICKED(IDC_PRINTER_ADD, OnPrinterAdd)
ON_BN_CLICKED(IDC_PRINTER_REMOVE, OnPrinterRemove)
ON_BN_CLICKED(IDC_MANAGE, OnManage)
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_PRINTER_BROWSE, OnBnClickedPrinterBrowse)
ON_CBN_SELCHANGE(IDC_PRINTER_TYPE, OnCbnSelchangePrinterType)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrinterProperties message handlers
int CPrinterProperties::ShowProperties(int nIndex)
{
m_nIndex = nIndex;
return DoModal();
}
BOOL CPrinterProperties::OnInitDialog()
{
m_printerName = sharedPrinters[m_nIndex].printerName;
m_queuePath = sharedPrinters[m_nIndex].spoolDir;
CDialog::OnInitDialog();
SetWindowText(sharedPrinters[m_nIndex].printerName);
m_heading.SetWindowText(sharedPrinters[m_nIndex].printerName);
m_hBoldFont = InitializeControlFont("Tahoma", FW_BOLD, 8);
m_heading.SendMessage(WM_SETFONT, (WPARAM) m_hBoldFont, MAKELPARAM(TRUE, 0));
m_domainHeading.SendMessage(WM_SETFONT, (WPARAM) m_hBoldFont, MAKELPARAM(TRUE, 0));
m_userList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_userList.InsertColumn(0, "User or Group", LVCFMT_LEFT, 175);
m_userList.InsertColumn(1, "Access", LVCFMT_LEFT, 100);
m_nameCtrl.SetSel(0, -1);
m_nameCtrl.SetFocus();
m_okayBtn.EnableWindow(!m_printerName.IsEmpty() && !m_queuePath.IsEmpty());
m_addBtn.EnableWindow(authServerIP != 0);
CBitmap user, group;
user.LoadBitmap(IDB_USER);
group.LoadBitmap(IDB_GROUP);
m_images.Create(16, 16, FALSE, 2, 0);
m_images.Add(&user, (COLORREF) 0);
m_images.Add(&group, (COLORREF) 0);
m_userList.SetImageList(&m_images, LVSIL_SMALL);
AddUserList();
BuildPrinterList();
m_device.SelectString(-1, sharedPrinters[m_nIndex].deviceName);
m_printerType.AddString(PRT_TYPE_LASERJET);
m_printerType.AddString(PRT_TYPE_INKJET);
m_printerType.AddString(PRT_TYPE_POSTSCRIPT);
m_printerType.AddString(PRT_TYPE_EPSON_STYLUS);
if (m_printerType.SelectString(-1, sharedPrinters[m_nIndex].deviceType) == CB_ERR)
m_printerType.SelectString(-1, PRT_TYPE_LASERJET);
OnCbnSelchangePrinterType();
return FALSE;
}
void CPrinterProperties::AddUserList()
{
bt_user_rights *ur;
int nItem;
if (sharedPrinters[m_nIndex].security != BT_AUTH_NONE)
for (ur = sharedPrinters[m_nIndex].rights; ur; ur = ur->next)
{
char access[50];
access[0] = 0;
if (ur->rights & BT_RIGHTS_PRINT)
strcpy(access, "Print");
nItem = m_userList.InsertItem(0, ur->user, ur->isGroup ? 1 : 0);
m_userList.SetItemText(nItem, 1, access);
}
}
void CPrinterProperties::BuildPrinterList()
{
PRINTER_INFO_1 netPrinters[BT_MAX_PRINTER_SHARES];
PRINTER_INFO_5 printers[BT_MAX_PRINTER_SHARES];
DWORD bytesCopied, structsCopied;
int i;
if (EnumPrinters(PRINTER_ENUM_NAME, NULL, 5, (LPBYTE) printers, sizeof(printers), &bytesCopied, &structsCopied))
for (i = 0; i < structsCopied; i++)
m_device.AddString(printers[i].pPrinterName);
if (EnumPrinters(PRINTER_ENUM_CONNECTIONS, NULL, 1, (LPBYTE) netPrinters, sizeof(netPrinters), &bytesCopied, &structsCopied))
for (i = 0; i < structsCopied; i++)
m_device.AddString(netPrinters[i].pName);
}
void CPrinterProperties::OnClickDomainUsers(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
m_removeBtn.EnableWindow(GetSelectedListItem(&m_userList) != -1);
}
void CPrinterProperties::OnPrinterAdd()
{
CDomainUsers users;
char access[50];
int nItem;
if (users.ShowUsers(true) == IDOK)
{
CString user = users.GetUser();
int nRights = users.GetRights();
bool isGroup = users.IsGroup();
SaveUserRights(LPCTSTR(user), nRights, isGroup);
access[0] = 0;
if (nRights & BT_RIGHTS_PRINT)
strcpy(access, "Print");
nItem = m_userList.InsertItem(0, user, isGroup ? 1 : 0);
m_userList.SetItemText(nItem, 1, access);
}
}
void CPrinterProperties::OnPrinterRemove()
{
bt_user_rights *ur, *lastUR;
int nItem = GetSelectedListItem(&m_userList);
CString user = m_userList.GetItemText(nItem, 0);
lastUR = NULL;
for (ur = sharedPrinters[m_nIndex].rights; ur; ur = ur->next)
if (strcmp(ur->user, user) == 0)
{
if (lastUR)
lastUR->next = ur->next;
else
sharedPrinters[m_nIndex].rights = ur->next;
free(ur);
m_userList.DeleteItem(nItem);
break;
}
else
lastUR = ur;
}
void CPrinterProperties::SaveUserRights(const char *user, int rights, bool isGroup)
{
bt_user_rights *ur;
if (user == NULL || rights == 0)
return;
for (ur = sharedPrinters[m_nIndex].rights; ur; ur = ur->next)
if (strcmp(ur->user, user) == 0)
{
ur->rights = rights;
return;
}
ur = (bt_user_rights *) malloc(sizeof(bt_user_rights));
if (ur)
{
ur->user = (char *) malloc(strlen(user) + 1);
if (ur->user)
{
strcpy(ur->user, user);
ur->rights = rights;
ur->isGroup = isGroup;
ur->next = sharedPrinters[m_nIndex].rights;
sharedPrinters[m_nIndex].rights = ur;
}
else
free(ur);
}
}
void CPrinterProperties::OnOK()
{
CString itemName;
int item;
CDialog::OnOK();
strcpy(sharedPrinters[m_nIndex].printerName, m_printerName);
strcpy(sharedPrinters[m_nIndex].spoolDir, m_queuePath);
item = m_device.GetCurSel();
m_device.GetLBText(item, itemName);
strcpy(sharedPrinters[m_nIndex].deviceName, itemName);
item = m_printerType.GetCurSel();
m_printerType.GetLBText(item, itemName);
strcpy(sharedPrinters[m_nIndex].deviceType, itemName);
}
void CPrinterProperties::OnManage()
{
CManageQueue queueDlg;
queueDlg.ShowQueue(&sharedPrinters[m_nIndex]);
}
void CPrinterProperties::OnBnClickedPrinterBrowse()
{
CBrowseFolders browser;
CWaitCursor wait;
if (browser.SelectFolder(m_queuePath) == IDOK)
{
m_queuePath = browser.GetPath();
UpdateData(FALSE);
}
}
void CPrinterProperties::OnCbnSelchangePrinterType()
{
CString itemName;
int item;
UpdateData(TRUE);
m_printerModel.ResetContent();
item = m_printerType.GetCurSel();
m_printerType.GetLBText(item, itemName);
if (itemName.CompareNoCase(PRT_TYPE_LASERJET) == 0)
m_printerModel.EnableWindow(FALSE);
else
{
m_printerModel.EnableWindow(TRUE);
}
}

View File

@ -0,0 +1,80 @@
#include "afxwin.h"
#if !defined(AFX_PRINTERPROPERTIES_H__1ED970A1_8FE9_431D_9F26_5E797DCB8C62__INCLUDED_)
#define AFX_PRINTERPROPERTIES_H__1ED970A1_8FE9_431D_9F26_5E797DCB8C62__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PrinterProperties.h : header file
//
#define PRT_TYPE_LASERJET "HP LaserJet Compatible"
#define PRT_TYPE_INKJET "HP InkJet Compatible"
#define PRT_TYPE_POSTSCRIPT "Postscript Printer"
#define PRT_TYPE_EPSON_STYLUS "Epson Stylus"
/////////////////////////////////////////////////////////////////////////////
// CPrinterProperties dialog
class CPrinterProperties : public CDialog
{
// Construction
public:
CPrinterProperties(CWnd* pParent = NULL); // standard constructor
int ShowProperties(int nIndex);
// Dialog Data
//{{AFX_DATA(CPrinterProperties)
enum { IDD = IDD_PRINTER_PROPERTIES };
CComboBox m_printerType;
CEdit m_nameCtrl;
CButton m_removeBtn;
CButton m_okayBtn;
CStatic m_heading;
CStatic m_domainHeading;
CComboBox m_device;
CButton m_addBtn;
CListCtrl m_userList;
CString m_printerName;
CString m_queuePath;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPrinterProperties)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
void AddUserList();
void BuildPrinterList();
void SaveUserRights(const char *user, int rights, bool isGroup);
CImageList m_images;
HFONT m_hBoldFont;
int m_nIndex;
// Generated message map functions
//{{AFX_MSG(CPrinterProperties)
virtual BOOL OnInitDialog();
afx_msg void OnClickDomainUsers(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnPrinterAdd();
afx_msg void OnPrinterRemove();
afx_msg void OnManage();
afx_msg void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedPrinterBrowse();
afx_msg void OnCbnSelchangePrinterType();
CComboBox m_printerModel;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PRINTERPROPERTIES_H__1ED970A1_8FE9_431D_9F26_5E797DCB8C62__INCLUDED_)

View File

@ -0,0 +1,264 @@
// PrinterSharingDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ctype.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "becompat.h"
#include "betalk.h"
#include "FileSharing.h"
#include "PrinterSharingDlg.h"
#include "PrinterProperties.h"
#include "printing.h"
#include "Security.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern bt_printer sharedPrinters[];
extern char authServerName[];
extern unsigned int authServerIP;
extern char tokBuffer[MAX_NAME_LENGTH + 1], *tokPtr;
extern char *keywords[];
/////////////////////////////////////////////////////////////////////////////
// CPrinterSharingDlg dialog
CPrinterSharingDlg::CPrinterSharingDlg()
: CPropertyPage(CPrinterSharingDlg::IDD)
{
//{{AFX_DATA_INIT(CPrinterSharingDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CPrinterSharingDlg::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrinterSharingDlg)
DDX_Control(pDX, IDC_MAIN_HEADING, m_heading);
DDX_Control(pDX, IDC_PRINTERS, m_printerList);
DDX_Control(pDX, IDC_REMOVE_PRINTER, m_removeBtn);
DDX_Control(pDX, IDC_EDIT_PRINTER, m_editBtn);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPrinterSharingDlg, CPropertyPage)
//{{AFX_MSG_MAP(CPrinterSharingDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_NOTIFY(NM_CLICK, IDC_PRINTERS, OnClickPrinters)
ON_NOTIFY(NM_DBLCLK, IDC_PRINTERS, OnDblclkPrinters)
ON_BN_CLICKED(IDC_EDIT_PRINTER, OnEditPrinter)
ON_BN_CLICKED(IDC_REMOVE_PRINTER, OnRemovePrinter)
ON_BN_CLICKED(IDC_NEW_PRINTER, OnNewPrinter)
ON_BN_CLICKED(IDC_SECURITY, OnSecurity)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrinterSharingDlg message handlers
BOOL CPrinterSharingDlg::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_editBtn.EnableWindow(FALSE);
m_removeBtn.EnableWindow(FALSE);
m_printerList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_printerList.InsertColumn(0, "Printer Name", LVCFMT_LEFT, 120);
m_printerList.InsertColumn(1, "Local Device", LVCFMT_LEFT, 120);
m_printerList.InsertColumn(2, "Queue Path", LVCFMT_LEFT, 200);
CBitmap printer;
printer.LoadBitmap(IDB_USER);
m_images.Create(16, 16, FALSE, 2, 0);
m_images.Add(&printer, (COLORREF) 0);
m_printerList.SetImageList(&m_images, LVSIL_SMALL);
m_hBoldFont = InitializeControlFont("Tahoma", FW_BOLD, 8);
m_heading.SendMessage(WM_SETFONT, (WPARAM) m_hBoldFont, MAKELPARAM(TRUE, 0));
ListPrinters();
return TRUE;
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CPrinterSharingDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPropertyPage::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CPrinterSharingDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CPrinterSharingDlg::OnClickPrinters(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
m_editBtn.EnableWindow(GetSelectedListItem(&m_printerList) != -1);
m_removeBtn.EnableWindow(GetSelectedListItem(&m_printerList) != -1);
}
void CPrinterSharingDlg::OnDblclkPrinters(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
OnEditPrinter();
}
void CPrinterSharingDlg::OnEditPrinter()
{
CPrinterProperties printer;
int nItem = GetSelectedListItem(&m_printerList);
if (nItem != -1)
if (printer.ShowProperties(m_printerList.GetItemData(nItem)) == IDOK)
RefreshPrinter(nItem);
}
void CPrinterSharingDlg::OnRemovePrinter()
{
int nItem = GetSelectedListItem(&m_printerList);
if (nItem >= 0)
if (MessageBox(WARN_REMOVE_PRINTER, sharedPrinters[nItem].printerName, MB_YESNO | MB_ICONQUESTION) == IDYES)
{
sharedPrinters[nItem].used = false;
m_printerList.DeleteItem(nItem);
}
}
void CPrinterSharingDlg::OnNewPrinter()
{
CPrinterProperties printer;
struct stat st;
int nIndex;
for (nIndex = 0; nIndex < BT_MAX_PRINTER_SHARES; nIndex++)
if (!sharedPrinters[nIndex].used)
break;
if (nIndex == BT_MAX_PRINTER_SHARES)
return;
strcpy(sharedPrinters[nIndex].printerName, "Untitled");
strcpy(sharedPrinters[nIndex].spoolDir, "c:\\temp");
if (printer.ShowProperties(nIndex) == IDOK)
{
int nItem = m_printerList.InsertItem(0, sharedPrinters[nIndex].printerName, 0);
m_printerList.SetItemText(nItem, 1, sharedPrinters[nIndex].deviceName);
m_printerList.SetItemText(nItem, 2, stat(sharedPrinters[nIndex].spoolDir, &st) == 0 ? sharedPrinters[nIndex].spoolDir : "--- Invalid Path ---");
m_printerList.SetItemData(nItem, nIndex);
sharedPrinters[nIndex].used = true;
}
}
void CPrinterSharingDlg::OnSecurity()
{
CSecurity security;
security.DoModal();
}
// ListPrinters()
//
void CPrinterSharingDlg::ListPrinters()
{
struct stat st;
int i, nItem;
for (i = 0; i < BT_MAX_PRINTER_SHARES; i++)
if (sharedPrinters[i].used)
{
nItem = m_printerList.InsertItem(0, sharedPrinters[i].printerName, 0);
m_printerList.SetItemText(nItem, 1, sharedPrinters[i].deviceName);
m_printerList.SetItemText(nItem, 2, stat(sharedPrinters[i].spoolDir, &st) == 0 ? sharedPrinters[i].spoolDir : "--- Invalid Path ---");
m_printerList.SetItemData(nItem, i);
}
}
void CPrinterSharingDlg::RefreshPrinter(int nItem)
{
struct stat st;
int nIndex = m_printerList.GetItemData(nItem);
m_printerList.SetItemText(nItem, 0, sharedPrinters[nItem].printerName);
m_printerList.SetItemText(nItem, 1, sharedPrinters[nItem].deviceName);
m_printerList.SetItemText(nItem, 2, stat(sharedPrinters[nItem].spoolDir, &st) == 0 ? sharedPrinters[nItem].spoolDir : "--- Invalid Path ---");
}
// WritePrinters()
//
void CPrinterSharingDlg::WritePrinters(FILE *fp)
{
bt_user_rights *ur;
int i;
if (fp)
{
for (i = 0; i < BT_MAX_PRINTER_SHARES; i++)
if (sharedPrinters[i].used)
{
fprintf(fp, "printer ");
PrintString(fp, sharedPrinters[i].printerName);
fprintf(fp, " is type ");
PrintString(fp, sharedPrinters[i].deviceType);
fprintf(fp, " device ");
PrintString(fp, sharedPrinters[i].deviceName);
fprintf(fp, " spooled to ");
PrintString(fp, sharedPrinters[i].spoolDir);
fputc('\n', fp);
for (ur = sharedPrinters[i].rights; ur; ur = ur->next)
if (ur->rights & BT_RIGHTS_PRINT)
{
fprintf(fp, "grant print on ");
PrintString(fp, sharedPrinters[i].printerName);
fprintf(fp, " to ");
if (ur->isGroup)
fprintf(fp, "group ");
fprintf(fp, "%s\n", ur->user);
}
}
}
}

View File

@ -0,0 +1,78 @@
// PrinterSharingDlg.h : header file
//
#if !defined(AFX_PRINTERSHARINGDLG_H__2CCAE8D2_2185_42AD_A50D_AEC540DE7434__INCLUDED_)
#define AFX_PRINTERSHARINGDLG_H__2CCAE8D2_2185_42AD_A50D_AEC540DE7434__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "printing.h"
/////////////////////////////////////////////////////////////////////////////
// CPrinterSharingDlg dialog
class CPrinterSharingDlg : public CPropertyPage
{
// Construction
public:
CPrinterSharingDlg(); // standard constructor
void WritePrinters(FILE *fp);
// Dialog Data
//{{AFX_DATA(CPrinterSharingDlg)
enum { IDD = IDD_PRINTERSHARING_DIALOG };
CStatic m_heading;
CListCtrl m_printerList;
CButton m_removeBtn;
CButton m_editBtn;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPrinterSharingDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
void ListPrinters();
void RefreshPrinter(int nItem);
void initPrinters();
void getGrant(const char *buffer);
void getAuthenticate(const char *buffer);
void addUserRights(char *share, char *user, int rights, bool isGroup);
void getPrinter(const char *buffer);
int getToken();
bt_printer *btFindPrinter(char *printerName);
CImageList m_images;
HICON m_hIcon;
HFONT m_hBoldFont;
// Generated message map functions
//{{AFX_MSG(CPrinterSharingDlg)
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnClickPrinters(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDblclkPrinters(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnEditPrinter();
afx_msg void OnRemovePrinter();
afx_msg void OnNewPrinter();
afx_msg void OnSecurity();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#define WARN_REMOVE_PRINTER "Removing this printer will prevent other users on your network from using it. Are you sure you want to remove this printer?"
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PRINTERSHARINGDLG_H__2CCAE8D2_2185_42AD_A50D_AEC540DE7434__INCLUDED_)

View File

@ -0,0 +1,115 @@
// Security.cpp : implementation file
//
#include "stdafx.h"
#include "winsock2.h"
#include "FileSharing.h"
#include "Security.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSecurity dialog
CSecurity::CSecurity(CWnd* pParent /*=NULL*/)
: CDialog(CSecurity::IDD, pParent)
{
//{{AFX_DATA_INIT(CSecurity)
m_server = _T("");
//}}AFX_DATA_INIT
}
void CSecurity::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSecurity)
DDX_Control(pDX, IDOK, m_okayBtn);
DDX_Control(pDX, IDC_SECURITY_TYPE, m_type);
DDX_Control(pDX, IDC_SECURITY_SERVER, m_serverCtrl);
DDX_Text(pDX, IDC_SECURITY_SERVER, m_server);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSecurity, CDialog)
//{{AFX_MSG_MAP(CSecurity)
ON_EN_CHANGE(IDC_SECURITY_SERVER, OnChangeSecurityServer)
ON_CBN_SELCHANGE(IDC_SECURITY_TYPE, OnSelchangeSecurityType)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSecurity message handlers
BOOL CSecurity::OnInitDialog()
{
extern char authServerName[];
extern unsigned int authServerIP;
CDialog::OnInitDialog();
if (authServerIP)
{
m_type.SelectString(-1, "BeSure Authentication Server");
m_server = authServerName;
UpdateData(FALSE);
m_serverCtrl.EnableWindow(TRUE);
}
else
m_type.SelectString(-1, "No Authentication Required");
m_type.SetFocus();
return FALSE;
}
void CSecurity::OnChangeSecurityServer()
{
UpdateData(TRUE);
m_okayBtn.EnableWindow(!m_server.IsEmpty());
}
void CSecurity::OnSelchangeSecurityType()
{
CString typeName;
int nType = m_type.GetCurSel();
m_type.GetLBText(nType, typeName);
if (typeName.CompareNoCase("No Authentication Required") == 0)
{
m_serverCtrl.EnableWindow(FALSE);
m_okayBtn.EnableWindow(TRUE);
}
else
{
m_serverCtrl.EnableWindow(TRUE);
UpdateData(TRUE);
m_okayBtn.EnableWindow(!m_server.IsEmpty());
}
}
void CSecurity::OnOK()
{
extern char authServerName[];
extern unsigned int authServerIP;
struct hostent *ent;
CDialog::OnOK();
strcpy(authServerName, m_server);
ent = gethostbyname(authServerName);
if (ent == NULL)
{
unsigned long addr = inet_addr(authServerName);
authServerIP = ntohl(addr);
}
else
authServerIP = ntohl(*((unsigned int *) ent->h_addr));
}

View File

@ -0,0 +1,52 @@
#if !defined(AFX_SECURITY_H__6F5ED7A3_9C16_11D6_9EF3_00A0C965AF06__INCLUDED_)
#define AFX_SECURITY_H__6F5ED7A3_9C16_11D6_9EF3_00A0C965AF06__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Security.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CSecurity dialog
class CSecurity : public CDialog
{
// Construction
public:
CSecurity(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CSecurity)
enum { IDD = IDD_SECURITY };
CButton m_okayBtn;
CComboBox m_type;
CEdit m_serverCtrl;
CString m_server;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSecurity)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CSecurity)
virtual BOOL OnInitDialog();
afx_msg void OnChangeSecurityServer();
afx_msg void OnSelchangeSecurityType();
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SECURITY_H__6F5ED7A3_9C16_11D6_9EF3_00A0C965AF06__INCLUDED_)

View File

@ -0,0 +1,253 @@
// ShareProperties.cpp : implementation file
//
#include "stdafx.h"
#include "FileSharing.h"
#include "ShareProperties.h"
#include "BrowseFolders.h"
#include "DomainUsers.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern bt_fileShare_t fileShares[];
extern unsigned int authServerIP;
/////////////////////////////////////////////////////////////////////////////
// CShareProperties dialog
CShareProperties::CShareProperties(CWnd* pParent /*=NULL*/)
: CDialog(CShareProperties::IDD, pParent)
{
//{{AFX_DATA_INIT(CShareProperties)
m_bLinks = FALSE;
m_bReadWrite = FALSE;
m_shareName = _T("");
m_sharePath = _T("");
//}}AFX_DATA_INIT
}
void CShareProperties::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CShareProperties)
DDX_Control(pDX, IDC_SHARE_ADD, m_addBtn);
DDX_Control(pDX, IDC_SHARE_REMOVE, m_removeBtn);
DDX_Control(pDX, IDC_DOMAIN_USERS, m_userList);
DDX_Control(pDX, IDC_DOMAIN_HEADING, m_domainHeading);
DDX_Control(pDX, IDC_OPTIONS_HEADING, m_optionsHeading);
DDX_Control(pDX, IDC_SHARE_NAME, m_nameCtrl);
DDX_Control(pDX, IDOK, m_okayBtn);
DDX_Control(pDX, IDC_SHARE_HEADING, m_heading);
DDX_Check(pDX, IDC_SHARE_LINKS, m_bLinks);
DDX_Check(pDX, IDC_SHARE_WRITE, m_bReadWrite);
DDX_Text(pDX, IDC_SHARE_NAME, m_shareName);
DDX_Text(pDX, IDC_SHARE_PATH, m_sharePath);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CShareProperties, CDialog)
//{{AFX_MSG_MAP(CShareProperties)
ON_BN_CLICKED(IDC_SHARE_BROWSE, OnShareBrowse)
ON_EN_CHANGE(IDC_SHARE_NAME, OnChangeShareName)
ON_EN_CHANGE(IDC_SHARE_PATH, OnChangeSharePath)
ON_NOTIFY(NM_CLICK, IDC_DOMAIN_USERS, OnClickDomainUsers)
ON_BN_CLICKED(IDC_SHARE_ADD, OnShareAdd)
ON_BN_CLICKED(IDC_SHARE_REMOVE, OnShareRemove)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CShareProperties message handlers
BOOL CShareProperties::OnInitDialog()
{
m_shareName = fileShares[m_nIndex].name;
m_sharePath = fileShares[m_nIndex].path;
m_bReadWrite = !fileShares[m_nIndex].readOnly;
m_bLinks = FALSE;
CDialog::OnInitDialog();
SetWindowText(fileShares[m_nIndex].name);
m_heading.SetWindowText(fileShares[m_nIndex].name);
m_hBoldFont = InitializeControlFont("Tahoma", FW_BOLD, 8);
m_heading.SendMessage(WM_SETFONT, (WPARAM) m_hBoldFont, MAKELPARAM(TRUE, 0));
m_optionsHeading.SendMessage(WM_SETFONT, (WPARAM) m_hBoldFont, MAKELPARAM(TRUE, 0));
m_domainHeading.SendMessage(WM_SETFONT, (WPARAM) m_hBoldFont, MAKELPARAM(TRUE, 0));
m_userList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_userList.InsertColumn(0, "User or Group", LVCFMT_LEFT, 175);
m_userList.InsertColumn(1, "Access", LVCFMT_LEFT, 100);
m_nameCtrl.SetSel(0, -1);
m_nameCtrl.SetFocus();
m_okayBtn.EnableWindow(!m_shareName.IsEmpty() && !m_sharePath.IsEmpty());
m_addBtn.EnableWindow(authServerIP != 0);
CBitmap user, group;
user.LoadBitmap(IDB_USER);
group.LoadBitmap(IDB_GROUP);
m_images.Create(16, 16, FALSE, 2, 0);
m_images.Add(&user, (COLORREF) 0);
m_images.Add(&group, (COLORREF) 0);
m_userList.SetImageList(&m_images, LVSIL_SMALL);
AddUserList();
return FALSE;
}
void CShareProperties::OnShareBrowse()
{
CBrowseFolders browser;
CWaitCursor wait;
if (browser.SelectFolder(m_sharePath) == IDOK)
{
m_sharePath = browser.GetPath();
UpdateData(FALSE);
}
}
void CShareProperties::OnChangeShareName()
{
UpdateData(TRUE);
m_okayBtn.EnableWindow(!m_shareName.IsEmpty());
}
void CShareProperties::OnChangeSharePath()
{
UpdateData(TRUE);
m_okayBtn.EnableWindow(!m_sharePath.IsEmpty());
}
void CShareProperties::OnOK()
{
CDialog::OnOK();
strcpy(fileShares[m_nIndex].name, m_shareName);
strcpy(fileShares[m_nIndex].path, m_sharePath);
fileShares[m_nIndex].readOnly = !m_bReadWrite;
fileShares[m_nIndex].followLinks = m_bLinks ? 1 : 0;
}
int CShareProperties::ShowProperties(int nIndex)
{
m_nIndex = nIndex;
return DoModal();
}
void CShareProperties::AddUserList()
{
bt_user_rights *ur;
int nItem;
if (fileShares[m_nIndex].security != BT_AUTH_NONE)
for (ur = fileShares[m_nIndex].rights; ur; ur = ur->next)
{
char access[50];
access[0] = 0;
if (ur->rights & BT_RIGHTS_READ)
strcat(access, "Read ");
if (ur->rights & BT_RIGHTS_WRITE)
strcat(access, "Write");
nItem = m_userList.InsertItem(0, ur->user, ur->isGroup ? 1 : 0);
m_userList.SetItemText(nItem, 1, access);
}
}
void CShareProperties::OnClickDomainUsers(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
m_removeBtn.EnableWindow(GetSelectedListItem(&m_userList) != -1);
}
void CShareProperties::OnShareAdd()
{
CDomainUsers users;
char access[50];
int nItem;
if (users.DoModal() == IDOK)
{
CString user = users.GetUser();
int nRights = users.GetRights();
bool isGroup = users.IsGroup();
SaveUserRights(LPCTSTR(user), nRights, isGroup);
access[0] = 0;
if (nRights & BT_RIGHTS_READ)
strcat(access, "Read ");
if (nRights & BT_RIGHTS_WRITE)
strcat(access, "Write");
nItem = m_userList.InsertItem(0, user, isGroup ? 1 : 0);
m_userList.SetItemText(nItem, 1, access);
}
}
void CShareProperties::OnShareRemove()
{
bt_user_rights *ur, *lastUR;
int nItem = GetSelectedListItem(&m_userList);
CString user = m_userList.GetItemText(nItem, 0);
lastUR = NULL;
for (ur = fileShares[m_nIndex].rights; ur; ur = ur->next)
if (strcmp(ur->user, user) == 0)
{
if (lastUR)
lastUR->next = ur->next;
else
fileShares[m_nIndex].rights = ur->next;
free(ur);
m_userList.DeleteItem(nItem);
break;
}
else
lastUR = ur;
}
void CShareProperties::SaveUserRights(const char *user, int rights, bool isGroup)
{
bt_user_rights *ur;
if (user == NULL || rights == 0)
return;
for (ur = fileShares[m_nIndex].rights; ur; ur = ur->next)
if (strcmp(ur->user, user) == 0)
{
ur->rights = rights;
return;
}
ur = (bt_user_rights *) malloc(sizeof(bt_user_rights));
if (ur)
{
ur->user = (char *) malloc(strlen(user) + 1);
if (ur->user)
{
strcpy(ur->user, user);
ur->rights = rights;
ur->isGroup = isGroup;
ur->next = fileShares[m_nIndex].rights;
fileShares[m_nIndex].rights = ur;
}
else
free(ur);
}
}

View File

@ -0,0 +1,73 @@
#if !defined(AFX_SHAREPROPERTIES_H__AF7E1305_F583_11D5_90F9_00C04F0972A7__INCLUDED_)
#define AFX_SHAREPROPERTIES_H__AF7E1305_F583_11D5_90F9_00C04F0972A7__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ShareProperties.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CShareProperties dialog
class CShareProperties : public CDialog
{
// Construction
public:
CShareProperties(CWnd* pParent = NULL); // standard constructor
int ShowProperties(int nIndex);
// Dialog Data
//{{AFX_DATA(CShareProperties)
enum { IDD = IDD_SHARE_PROPERTIES };
CButton m_addBtn;
CButton m_removeBtn;
CListCtrl m_userList;
CStatic m_domainHeading;
CStatic m_optionsHeading;
CEdit m_nameCtrl;
CButton m_okayBtn;
CStatic m_heading;
BOOL m_bLinks;
BOOL m_bReadWrite;
CString m_shareName;
CString m_sharePath;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CShareProperties)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
void AddUserList();
void SaveUserRights(const char *user, int rights, bool isGroup);
CImageList m_images;
HFONT m_hBoldFont;
// Generated message map functions
//{{AFX_MSG(CShareProperties)
virtual BOOL OnInitDialog();
afx_msg void OnShareBrowse();
afx_msg void OnChangeShareName();
afx_msg void OnChangeSharePath();
virtual void OnOK();
afx_msg void OnClickDomainUsers(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnShareAdd();
afx_msg void OnShareRemove();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
int m_nIndex;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SHAREPROPERTIES_H__AF7E1305_F583_11D5_90F9_00C04F0972A7__INCLUDED_)

View File

@ -0,0 +1,6 @@
// stdafx.cpp : source file that includes just the standard includes
// scanappl.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@ -0,0 +1,21 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__INCLUDED_)
#define AFX_STDAFX_H__INCLUDED_
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxole.h> // MFC OLE classes
#include <afxodlgs.h> // MFC OLE dialog classes
#include <afxdisp.h> // MFC OLE automation classes
#include <afxdb.h> // MFC database classes
#include <afxcmn.h> // MFC common controls
#include <afxdisp.h>
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__INCLUDED_)

View File

@ -0,0 +1,147 @@
#ifndef B_OK
#include <windows.h>
#include <winnt.h>
//#include <semaphore.h>
//#include <pthread.h>
//#include <sys/utsname.h>
#define B_OK 0
#define B_ENTRY_NOT_FOUND ENOENT
#define B_PATH_NAME_LENGTH 1024
#define B_FILE_NAME_LENGTH 256
#define B_OS_NAME_LENGTH 32
#define B_INTERRUPTED 1
#define BEOS_ENOENT 2147508227
#define BEOS_EACCES 2147483650
#define BEOS_ENOMEM 2147483648
#define BEOS_EINVAL 0
#ifndef true
#define true 1
#define false 0
#endif
#define WSTAT_MODE 0x0001
#define WSTAT_UID 0x0002
#define WSTAT_GID 0x0004
#define WSTAT_SIZE 0x0008
#define WSTAT_ATIME 0x0010
#define WSTAT_MTIME 0x0020
#define WSTAT_CRTIME 0x0040
#define B_COMMON_SETTINGS_DIRECTORY ".\\"
#define B_COMMON_SYSTEM_DIRECTORY ".\\"
#define ENOTSUP 1
#define B_HOST_TO_LENDIAN_INT32(x) (x)
#define B_HOST_TO_LENDIAN_INT64(x) (x)
#define B_HOST_TO_BENDIAN_INT32(x) (x)
#define B_HOST_TO_BENDIAN_INT64(x) (x)
#define B_LENDIAN_TO_HOST_INT32(x) (x)
#define B_LENDIAN_TO_HOST_INT64(x) (x)
#define B_BENDIAN_TO_HOST_INT32(x) (x)
#define B_BENDIAN_TO_HOST_INT64(x) (x)
#define lstat(f, s) stat(f, s)
#define S_ISDIR(m) ((m) & _S_IFDIR)
typedef char int8;
typedef long int32;
typedef LONGLONG int64;
typedef unsigned char uint8;
typedef unsigned long uint32;
typedef ULONGLONG uint64;
typedef uint64 vnode_id;
typedef uint64 beos_ino_t;
typedef uint64 beos_off_t;
typedef unsigned long beos_dev_t;
typedef long sem_id;
typedef long thread_id;
enum {
B_ANY_TYPE = 'ANYT',
B_BOOL_TYPE = 'BOOL',
B_CHAR_TYPE = 'CHAR',
B_COLOR_8_BIT_TYPE = 'CLRB',
B_DOUBLE_TYPE = 'DBLE',
B_FLOAT_TYPE = 'FLOT',
B_GRAYSCALE_8_BIT_TYPE = 'GRYB',
B_INT64_TYPE = 'LLNG',
B_INT32_TYPE = 'LONG',
B_INT16_TYPE = 'SHRT',
B_INT8_TYPE = 'BYTE',
B_MESSAGE_TYPE = 'MSGG',
B_MESSENGER_TYPE = 'MSNG',
B_MIME_TYPE = 'MIME',
B_MONOCHROME_1_BIT_TYPE = 'MNOB',
B_OBJECT_TYPE = 'OPTR',
B_OFF_T_TYPE = 'OFFT',
B_PATTERN_TYPE = 'PATN',
B_POINTER_TYPE = 'PNTR',
B_POINT_TYPE = 'BPNT',
B_RAW_TYPE = 'RAWT',
B_RECT_TYPE = 'RECT',
B_REF_TYPE = 'RREF',
B_RGB_32_BIT_TYPE = 'RGBB',
B_RGB_COLOR_TYPE = 'RGBC',
B_SIZE_T_TYPE = 'SIZT',
B_SSIZE_T_TYPE = 'SSZT',
B_STRING_TYPE = 'CSTR',
B_TIME_TYPE = 'TIME',
B_UINT64_TYPE = 'ULLG',
B_UINT32_TYPE = 'ULNG',
B_UINT16_TYPE = 'USHT',
B_UINT8_TYPE = 'UBYT',
B_MEDIA_PARAMETER_TYPE = 'BMCT',
B_MEDIA_PARAMETER_WEB_TYPE = 'BMCW',
B_MEDIA_PARAMETER_GROUP_TYPE= 'BMCG',
/* deprecated, do not use */
B_ASCII_TYPE = 'TEXT' /* use B_STRING_TYPE instead */
};
typedef struct fs_info
{
beos_dev_t dev;
beos_ino_t root;
uint32 flags;
// beos_off_t block_size;
uint32 block_size;
beos_off_t io_size;
// beos_off_t total_blocks;
// beos_off_t free_blocks;
uint32 total_blocks;
uint32 free_blocks;
beos_off_t total_nodes;
beos_off_t free_nodes;
char device_name[128];
char volume_name[B_FILE_NAME_LENGTH];
char fsh_name[B_OS_NAME_LENGTH];
} fs_info;
typedef struct beos_stat
{
uint32 st_dev;
uint32 st_nlink;
uint32 st_uid;
uint32 st_gid;
uint32 st_size;
uint32 st_blksize;
uint32 st_rdev;
uint32 st_ino;
uint32 st_mode;
uint32 st_atime;
uint32 st_mtime;
uint32 st_ctime;
} beos_stat;
bool IsValidUser(char *user, char *domain, char *password);
#endif

View File

@ -0,0 +1,252 @@
#ifndef _BETALK_H_
#define _BETALK_H_
#include <sys/types.h> //linux
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <signal.h>
#include <sys/stat.h>
#include <winsock.h> // windows
#include <ctype.h>
#include <sys/utime.h> // windows
#include <time.h>
#include <io.h> // windows
#include <direct.h> // windows
#include <process.h> // windows
#ifndef NULL
#define NULL 0L
#endif
#ifndef INVALID_SOCKET
#define INVALID_SOCKET (int)(~0)
#endif
#define BT_TCPIP_PORT 9092
#define BT_QUERYHOST_PORT 9093
#define BT_BESURE_PORT 9094
#define BT_CMD_TERMINATOR 13
#define BT_CMD_PREMOUNT 0
#define BT_CMD_MOUNT 1
#define BT_CMD_FSINFO 2
#define BT_CMD_LOOKUP 3
#define BT_CMD_STAT 4
#define BT_CMD_READDIR 5
#define BT_CMD_READ 6
#define BT_CMD_WRITE 7
#define BT_CMD_CREATE 8
#define BT_CMD_TRUNCATE 9
#define BT_CMD_MKDIR 10
#define BT_CMD_RMDIR 11
#define BT_CMD_RENAME 12
#define BT_CMD_UNLINK 13
#define BT_CMD_READLINK 14
#define BT_CMD_SYMLINK 15
#define BT_CMD_WSTAT 16
#define BT_CMD_READATTRIB 50
#define BT_CMD_WRITEATTRIB 51
#define BT_CMD_READATTRIBDIR 52
#define BT_CMD_REMOVEATTRIB 53
#define BT_CMD_STATATTRIB 54
#define BT_CMD_READINDEXDIR 60
#define BT_CMD_CREATEINDEX 61
#define BT_CMD_REMOVEINDEX 62
#define BT_CMD_STATINDEX 63
#define BT_CMD_READQUERY 70
#define BT_CMD_COMMIT 80
#define BT_CMD_PRINTJOB_NEW 200
#define BT_CMD_PRINTJOB_DATA 201
#define BT_CMD_PRINTJOB_COMMIT 202
#define BT_CMD_AUTHENTICATE 210
#define BT_CMD_QUIT 255
#define BT_CMD_AUTH 1
#define BT_CMD_READUSERS 2
#define BT_CMD_READGROUPS 3
#define BT_CMD_WHICHGROUPS 4
#define BT_REQ_HOST_PROBE 1
#define BT_REQ_SHARE_PROBE 2
#define BT_REQ_HOST_INFO 3
#define BT_REQ_HOST_USERS 4
#define BT_REQ_AUTH_TYPES 5
#define BT_AUTH_REQ_CONNECT 1
#define BT_AUTH_REQ_USERS 2
#define BT_SHARED_NULL 0
#define BT_SHARED_FOLDER 1
#define BT_SHARED_PRINTER 2
#define BT_PRINTER_PCL3 0
#define BT_PRINTER_POSTSCRIPT 1
#define BT_PRINTER_INKJET 2
#define BT_AUTH_NONE 0
#define BT_AUTH_BESURE 1
#define BT_RIGHTS_READ 0x00000001
#define BT_RIGHTS_WRITE 0x00000002
#define BT_RIGHTS_PRINT 0x00000004
#define BT_RPC_SIGNATURE "btRPC"
#define BT_RPC_VERSION_HI 0
#define BT_RPC_VERSION_LO 1
#define BT_MAX_IO_BUFFER 8192
#define BT_MAX_ATTR_BUFFER 256
#define BT_RPC_MIN_PACKET_SIZE 64
#define BT_RPC_MAX_PACKET_SIZE (BT_MAX_IO_BUFFER + 1024)
#define BT_TOKEN_SHARE 1
#define BT_TOKEN_AS 2
#define BT_TOKEN_SET 3
#define BT_TOKEN_READ 4
#define BT_TOKEN_WRITE 5
#define BT_TOKEN_READWRITE 6
#define BT_TOKEN_PROMISCUOUS 7
#define BT_TOKEN_ON 8
#define BT_TOKEN_TO 9
#define BT_TOKEN_AUTHENTICATE 10
#define BT_TOKEN_WITH 11
#define BT_TOKEN_GROUP 12
#define BT_TOKEN_PRINTER 13
#define BT_TOKEN_PRINT 14
#define BT_TOKEN_IS 15
#define BT_TOKEN_SPOOLED 16
#define BT_TOKEN_DEVICE 17
#define BT_TOKEN_TYPE 18
#define BT_TOKEN_COMMA 200
#define BT_TOKEN_QUOTE 201
#define BT_TOKEN_STRING 202
#define BT_TOKEN_NUMBER 203
#define BT_TOKEN_ERROR 255
#define isValid(c) ((c)=='.' || (c)=='_' || (c)=='-' || (c)=='/' || (c)=='\\' || (c)==':' || (c)=='&' || (c)=='\'' || (c)=='\\')
#define MAX_COMMAND_ARGS 10
#define MAX_NAME_LENGTH 32
#define MAX_KEY_LENGTH MAX_NAME_LENGTH
#define MAX_USERNAME_LENGTH MAX_NAME_LENGTH
#define MAX_GROUPNAME_LENGTH MAX_NAME_LENGTH
#define BT_AUTH_TOKEN_LENGTH (B_FILE_NAME_LENGTH + MAX_USERNAME_LENGTH)
#define MAX_DESC_LENGTH 64
#define MAX_GROUPS_PER_USER 80
typedef struct
{
char signature[6];
uint8 command;
char share[MAX_NAME_LENGTH + 1];
} bt_request;
typedef struct
{
uint32 type;
uint32 subType;
char name[B_FILE_NAME_LENGTH + 1];
} bt_resource;
typedef struct
{
char system[B_FILE_NAME_LENGTH];
char beServed[B_FILE_NAME_LENGTH];
char platform[B_FILE_NAME_LENGTH];
int cpus;
int connections;
int maxConnections;
} bt_hostinfo;
typedef struct userRights
{
char *user;
int rights;
bool isGroup;
struct userRights *next;
} bt_user_rights;
typedef struct
{
unsigned int blockSize;
unsigned int totalBlocks;
unsigned int freeBlocks;
} bt_fsinfo;
typedef struct
{
unsigned int size;
unsigned int length;
char *buffer;
} bt_outPacket;
typedef struct
{
unsigned int length;
unsigned int offset;
char *buffer;
} bt_inPacket;
typedef struct rpcCall
{
unsigned int xid;
sem_id sem;
bt_inPacket *inPacket;
bool finished;
struct rpcCall *next;
struct rpcCall *prev;
} bt_rpccall;
#define BT_COOKIE_SIZE 4
#define BT_COOKIE_BUFFER_SIZE 4096
#define BT_QUERY_COOKIE_SIZE 4
#define BT_FILE_HANDLE_SIZE 32
typedef struct btFileHandle
{
char opaque[BT_FILE_HANDLE_SIZE];
} btFileHandle;
typedef struct btCookie
{
char opaque[BT_COOKIE_SIZE];
bt_inPacket packet;
bool lpbCache;
bool eof;
} btCookie;
typedef struct btQueryCookie
{
char opaque[BT_COOKIE_SIZE];
char *query;
} btQueryCookie;
// RPC Operations
unsigned char btRPCGetChar(bt_inPacket *packet);
unsigned int btRPCGetInt32(bt_inPacket *packet);
int64 btRPCGetInt64(bt_inPacket *packet);
char * btRPCGetNewString(bt_inPacket *packet);
int btRPCGetString(bt_inPacket *packet, char *buffer, int length);
int btRPCGetHandle(bt_inPacket *packet, btFileHandle *fhandle);
void btRPCGetStat(bt_inPacket *packet, beos_stat *st);
bt_outPacket * btRPCPutHeader(unsigned char command, unsigned char argc, int32 length);
void btRPCPutArg(bt_outPacket *packet, unsigned int type, void *data, int length);
void btRPCPutChar(bt_outPacket *packet, char value);
void btRPCPutInt32(bt_outPacket *packet, int32 value);
void btRPCPutInt64(bt_outPacket *packet, int64 value);
void btRPCPutString(bt_outPacket *packet, char *buffer, int length);
void btRPCPutBinary(bt_outPacket *packet, void *buffer, int length);
void btRPCPutHandle(bt_outPacket *packet, btFileHandle *fhandle);
void btRPCPutStat(bt_outPacket *packet, beos_stat *st);
bt_rpccall * btRPCInvoke(int session, bt_outPacket *packet);
void btRPCCreateAck(bt_outPacket *packet, unsigned int xid, int error, int length);
void btRPCSendAck(int client, bt_outPacket *packet);
int btRecv(int sock, void *data, int dataLen, int flags);
int btSend(int sock, void *data, int dataLen, int flags);
#endif

View File

@ -0,0 +1,90 @@
// CtrlPan.cpp
// Source for CControlPanel
#include "stdafx.h"
#include "CtrlPan.h"
// static data
CControlPanel *CControlPanel::m_pThis = NULL;
CControlPanel::CControlPanel()
{
// Set up the static object pointer
m_pThis = this;
}
CControlPanel::~CControlPanel()
{
}
//////////////////////////////////////////////////////////////////////////////
// Callback function (exported)
// static member functions (callbacks)
LONG APIENTRY CControlPanel::CPlApplet(HWND hwndCPl,UINT uMsg,LONG lParam1,LONG lParam2)
{
// Get a pointer to the C++ object
CControlPanel *pCtrl = m_pThis;
ASSERT(pCtrl);
switch (uMsg)
{
case CPL_DBLCLK: return(pCtrl->OnDblclk(hwndCPl,lParam1,lParam2));
case CPL_EXIT: return(pCtrl->OnExit());
case CPL_GETCOUNT: return(pCtrl->OnGetCount());
case CPL_INIT: return(pCtrl->OnInit());
case CPL_NEWINQUIRE: return(pCtrl->OnInquire(lParam1,(NEWCPLINFO *) lParam2));
case CPL_INQUIRE: return(0); // not handled
case CPL_SELECT: return(pCtrl->OnSelect(lParam1,lParam2));
case CPL_STOP: return(pCtrl->OnStop(lParam1,lParam2));
default: break;
}
return(1); // not processed
}
/////////////////////////////////////////////////////////////////////////////////////////
// Default command handlers
LONG CControlPanel::OnDblclk(HWND hwndCPl,UINT uAppNum,LONG lData)
{
// Show the dialog
return(0); // OK
}
LONG CControlPanel::OnExit()
{
return(0); // OK
}
LONG CControlPanel::OnGetCount()
{
return(1); // default is support for one dialog box
}
LONG CControlPanel::OnInit()
{
return(1); // OK
}
LONG CControlPanel::OnInquire(UINT uAppNum,NEWCPLINFO *pInfo)
{
// Fill in the data
pInfo->dwSize = sizeof(NEWCPLINFO); // important
pInfo->dwFlags = 0;
pInfo->dwHelpContext = 0;
pInfo->lData = 0;
pInfo->hIcon = ::LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(1));
strcpy(pInfo->szName,"Applet");
strcpy(pInfo->szInfo,"Bar Code Scanner Applet");
strcpy(pInfo->szHelpFile,"");
return(0); // OK (don't send CPL_INQUIRE msg)
}
LONG CControlPanel::OnSelect(UINT uAppNum,LONG lData)
{
return(1); // not handled
}
LONG CControlPanel::OnStop(UINT uAppNum,LONG lData)
{
return(1); // not handled
}

View File

@ -0,0 +1,30 @@
// CtrlPan.h
#ifndef _CTRLPAN_H_
#define _CTRLPAN_H_
#include <cpl.h> // control panel definitions
class CControlPanel
{
public:
CControlPanel();
virtual ~CControlPanel();
// Event handlers
virtual LONG OnDblclk(HWND hwndCPl,UINT uAppNum,LONG lData);
virtual LONG OnExit();
virtual LONG OnGetCount();
virtual LONG OnInit();
virtual LONG OnInquire(UINT uAppNum,NEWCPLINFO *pInfo);
virtual LONG OnSelect(UINT uAppNum,LONG lData);
virtual LONG OnStop(UINT uAppNum,LONG lData);
// static member functions (callbacks)
static LONG APIENTRY CPlApplet(HWND hwndCPl,UINT uMsg,LONG lParam1,LONG lParam2);
// static data
static CControlPanel *m_pThis; // nasty hack to get object ptr
};
#endif // _CTRLPAN_H_

View File

@ -0,0 +1,19 @@
// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
// NOTE: Do not modify the contents of this file. If this class is regenerated by
// Microsoft Visual C++, your modifications will be overwritten.
#include "stdafx.h"
#include "folderview.h"
/////////////////////////////////////////////////////////////////////////////
// CFolderview
IMPLEMENT_DYNCREATE(CFolderview, CWnd)
/////////////////////////////////////////////////////////////////////////////
// CFolderview properties
/////////////////////////////////////////////////////////////////////////////
// CFolderview operations

View File

@ -0,0 +1,465 @@
#pragma once
// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
// NOTE: Do not modify the contents of this file. If this class is regenerated by
// Microsoft Visual C++, your modifications will be overwritten.
/////////////////////////////////////////////////////////////////////////////
// CFolderview wrapper class
class CFolderview : public CWnd
{
protected:
DECLARE_DYNCREATE(CFolderview)
public:
CLSID const& GetClsid()
{
static CLSID const clsid
= { 0xFBF52F2D, 0x9B93, 0x11D2, { 0xB4, 0x82, 0x0, 0x20, 0xAF, 0xD6, 0x9D, 0xE6 } };
return clsid;
}
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = NULL)
{
return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID);
}
BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE,
BSTR bstrLicKey = NULL)
{
return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
pPersist, bStorage, bstrLicKey);
}
// Attributes
public:
enum
{
Flat = 0,
ThreeD = 1
}AppearanceConstants;
enum
{
None = 0,
FixedSingle = 1
}BorderStyleConstants;
enum
{
AllAttributes = -1,
CapabilityAttributes = 375,
DisplayAttributes = 983040,
ContentsAttributes = -2147483648,
MiscellaneousAttributes = -1048576
}AttributesMask;
enum
{
CanCopy = 1,
CanMove = 2,
CanLink = 4,
CanRename = 16,
CanDelete = 32,
HasPropSheet = 64,
DropTarget = 256,
Shortcut = 65536,
Share = 131072,
ReadOnly = 262144,
Hidden = 524288,
HasSubfolder = -2147483648,
IsFileSysAncestor = 268435456,
IsFolder = 536870912,
IsFileSystem = 1073741824,
Validate = 16777216,
Removable = 33554432,
IsCompressed = 67108864,
IsBrowsable = 134217728,
NonEnumerated = 1048576,
NewContent = 2097152
}AttributesEnum;
enum
{
Desktop = 0,
Internet = 1,
Programs = 2,
ControlPanel = 3,
Printers = 4,
Personal = 5,
Favorites = 6,
Startup = 7,
Recent = 8,
SendTo = 9,
Recycled = 10,
StartMenu = 11,
DesktopDir = 16,
MyComputer = 17,
Network = 18,
NetHood = 19,
Fonts = 20,
Templates = 21,
CommonStartMenu = 22,
CommonPrograms = 23,
CommonStartup = 24,
CommonDesktopDir = 25,
AppData = 26,
PrintHood = 27,
AltStartup = 29,
CommonAltStartup = 30,
CommonFavorites = 31,
InternetCache = 32,
Cookies = 33,
History = 34
}SpecialFolderPathConstants;
// Operations
public:
// IFolderView
// Functions
//
void put_BackColor(unsigned long newValue)
{
static BYTE parms[] = VTS_UI4 ;
InvokeHelper(DISPID_BACKCOLOR, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
unsigned long get_BackColor()
{
unsigned long result;
InvokeHelper(DISPID_BACKCOLOR, DISPATCH_PROPERTYGET, VT_UI4, (void*)&result, NULL);
return result;
}
void put_ForeColor(unsigned long newValue)
{
static BYTE parms[] = VTS_UI4 ;
InvokeHelper(DISPID_FORECOLOR, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
unsigned long get_ForeColor()
{
unsigned long result;
InvokeHelper(DISPID_FORECOLOR, DISPATCH_PROPERTYGET, VT_UI4, (void*)&result, NULL);
return result;
}
long get_Appearance()
{
long result;
InvokeHelper(DISPID_APPEARANCE, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
void put_Appearance(long newValue)
{
static BYTE parms[] = VTS_I4 ;
InvokeHelper(DISPID_APPEARANCE, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
long get_BorderStyle()
{
long result;
InvokeHelper(DISPID_BORDERSTYLE, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
void put_BorderStyle(long newValue)
{
static BYTE parms[] = VTS_I4 ;
InvokeHelper(DISPID_BORDERSTYLE, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
BOOL get_HasLines()
{
BOOL result;
InvokeHelper(0x1, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_HasLines(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
BOOL get_HasButtons()
{
BOOL result;
InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_HasButtons(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x2, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
BOOL get_HasLinesAtRoot()
{
BOOL result;
InvokeHelper(0x3, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_HasLinesAtRoot(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x3, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
BOOL get_ShowSelAlways()
{
BOOL result;
InvokeHelper(0x4, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_ShowSelAlways(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x4, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
VARIANT get_Folders()
{
VARIANT result;
InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL);
return result;
}
BOOL get_HasCheckBoxes()
{
BOOL result;
InvokeHelper(0x5, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_HasCheckBoxes(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x5, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
BOOL get_DisplayShareName()
{
BOOL result;
InvokeHelper(0x7, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_DisplayShareName(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x7, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
LPDISPATCH get_FoldersCheck()
{
LPDISPATCH result;
InvokeHelper(0x8, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL);
return result;
}
BOOL get_OverlayIcons()
{
BOOL result;
InvokeHelper(0x9, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_OverlayIcons(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x9, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
CString get_SpecialFolderPath(long specialFolder)
{
CString result;
static BYTE parms[] = VTS_I4 ;
InvokeHelper(0xa, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, parms, specialFolder);
return result;
}
VARIANT get_SelectedFolder()
{
VARIANT result;
InvokeHelper(0xb, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL);
return result;
}
void put_SelectedFolder(VARIANT newValue)
{
static BYTE parms[] = VTS_VARIANT ;
InvokeHelper(0xb, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, &newValue);
}
BOOL get_EnableShellMenu()
{
BOOL result;
InvokeHelper(0xc, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_EnableShellMenu(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0xc, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
BOOL get_AutoUpdate()
{
BOOL result;
InvokeHelper(0xf, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_AutoUpdate(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0xf, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
long get_VisibleCount()
{
long result;
InvokeHelper(0x10, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
LPDISPATCH get_HitTest(long X, long Y)
{
LPDISPATCH result;
static BYTE parms[] = VTS_I4 VTS_I4 ;
InvokeHelper(0x11, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, parms, X, Y);
return result;
}
BOOL get_HiddenFolders()
{
BOOL result;
InvokeHelper(0x12, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_HiddenFolders(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x12, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
LPDISPATCH get_FirstVisibleFolder()
{
LPDISPATCH result;
InvokeHelper(0x13, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL);
return result;
}
void put_FirstVisibleFolder(LPDISPATCH newValue)
{
static BYTE parms[] = VTS_DISPATCH ;
InvokeHelper(0x13, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
void Refresh()
{
InvokeHelper(0xd, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
void EnsureVisible(VARIANT newVal)
{
static BYTE parms[] = VTS_VARIANT ;
InvokeHelper(0xe, DISPATCH_METHOD, VT_EMPTY, NULL, parms, &newVal);
}
BOOL get_Enabled()
{
BOOL result;
InvokeHelper(DISPID_ENABLED, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_Enabled(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(DISPID_ENABLED, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
LPDISPATCH get_Folder(VARIANT anPath)
{
LPDISPATCH result;
static BYTE parms[] = VTS_VARIANT ;
InvokeHelper(0x14, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, parms, &anPath);
return result;
}
BOOL get_IconsVisible()
{
BOOL result;
InvokeHelper(0x15, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_IconsVisible(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x15, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
LPDISPATCH get_Header()
{
LPDISPATCH result;
InvokeHelper(0x16, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL);
return result;
}
CString get_Version()
{
CString result;
InvokeHelper(0x17, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
void put_Version(LPCTSTR newValue)
{
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0x17, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
CString get_ExploreFromHere()
{
CString result;
InvokeHelper(0x18, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
void put_ExploreFromHere(LPCTSTR newValue)
{
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0x18, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
void About()
{
InvokeHelper(0x19, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
CString get_LicenseKey()
{
CString result;
InvokeHelper(0x1a, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
void put_LicenseKey(LPCTSTR newValue)
{
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0x1a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
long get_DropFilesCount()
{
long result;
InvokeHelper(0x1b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
CString get_DropFilesPathName(long nIndex)
{
CString result;
static BYTE parms[] = VTS_I4 ;
InvokeHelper(0x1c, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, parms, nIndex);
return result;
}
BOOL get_AllowDropFiles()
{
BOOL result;
InvokeHelper(0x1d, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void put_AllowDropFiles(BOOL newValue)
{
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x1d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
long get_hwnd()
{
long result;
InvokeHelper(DISPID_HWND, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
void put_Font(LPDISPATCH newValue)
{
static BYTE parms[] = VTS_DISPATCH ;
InvokeHelper(DISPID_FONT, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
LPDISPATCH get_Font()
{
LPDISPATCH result;
InvokeHelper(DISPID_FONT, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL);
return result;
}
void putref_Font(LPDISPATCH newValue)
{
static BYTE parms[] = VTS_DISPATCH ;
InvokeHelper(DISPID_FONT, DISPATCH_PROPERTYPUTREF, VT_EMPTY, NULL, parms, newValue);
}
// Properties
//
};

View File

@ -0,0 +1,99 @@
// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
// NOTE: Do not modify the contents of this file. If this class is regenerated by
// Microsoft Visual C++, your modifications will be overwritten.
#include "stdafx.h"
#include "mtvfolder.h"
/////////////////////////////////////////////////////////////////////////////
// CMTVFolder properties
/////////////////////////////////////////////////////////////////////////////
// CMTVFolder operations
long CMTVFolder::GetHandle()
{
long result;
InvokeHelper(0x4, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
CString CMTVFolder::GetDisplayName()
{
CString result;
InvokeHelper(0x5, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
CString CMTVFolder::GetPathName()
{
CString result;
InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
VARIANT CMTVFolder::GetFolders()
{
VARIANT result;
InvokeHelper(0x7, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL);
return result;
}
CString CMTVFolder::GetShareName()
{
CString result;
InvokeHelper(0x8, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
CString CMTVFolder::GetName()
{
CString result;
InvokeHelper(0x9, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
BOOL CMTVFolder::GetCheck()
{
BOOL result;
InvokeHelper(0xa, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void CMTVFolder::SetCheck(BOOL bNewValue)
{
static BYTE parms[] =
VTS_BOOL;
InvokeHelper(0xa, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
bNewValue);
}
LPUNKNOWN CMTVFolder::GetShellFolder()
{
LPUNKNOWN result;
InvokeHelper(0xb, DISPATCH_PROPERTYGET, VT_UNKNOWN, (void*)&result, NULL);
return result;
}
long CMTVFolder::GetAttributes(long dwMask)
{
long result;
static BYTE parms[] =
VTS_I4;
InvokeHelper(0xc, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, parms,
dwMask);
return result;
}
BOOL CMTVFolder::GetAttribute(long anAttribute)
{
BOOL result;
static BYTE parms[] =
VTS_I4;
InvokeHelper(0xd, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, parms,
anAttribute);
return result;
}

View File

@ -0,0 +1,43 @@
#if !defined(AFX_MTVFOLDER_H__60DF2AD0_F62B_11D5_90FA_00C04F0972A7__INCLUDED_)
#define AFX_MTVFOLDER_H__60DF2AD0_F62B_11D5_90FA_00C04F0972A7__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
// NOTE: Do not modify the contents of this file. If this class is regenerated by
// Microsoft Visual C++, your modifications will be overwritten.
/////////////////////////////////////////////////////////////////////////////
// CMTVFolder wrapper class
class CMTVFolder : public COleDispatchDriver
{
public:
CMTVFolder() {} // Calls COleDispatchDriver default constructor
CMTVFolder(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}
CMTVFolder(const CMTVFolder& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}
// Attributes
public:
// Operations
public:
long GetHandle();
CString GetDisplayName();
CString GetPathName();
VARIANT GetFolders();
CString GetShareName();
CString GetName();
BOOL GetCheck();
void SetCheck(BOOL bNewValue);
LPUNKNOWN GetShellFolder();
long GetAttributes(long dwMask);
BOOL GetAttribute(long anAttribute);
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MTVFOLDER_H__60DF2AD0_F62B_11D5_90FA_00C04F0972A7__INCLUDED_)

View File

@ -0,0 +1,49 @@
#ifndef __printing_h__
#define __printing_h__
#include "beCompat.h"
#include "betalk.h"
typedef struct
{
char printerName[MAX_NAME_LENGTH];
char deviceName[B_FILE_NAME_LENGTH];
char deviceType[MAX_NAME_LENGTH];
char spoolDir[B_PATH_NAME_LENGTH];
bool killed;
bool used;
bt_user_rights *rights;
int security;
HANDLE handlerID;
} bt_printer;
typedef struct printJob
{
char jobName[MAX_DESC_LENGTH + 1];
char jobFile[B_PATH_NAME_LENGTH + 1];
uint32 sourceAddr;
char sourceUser[MAX_USERNAME_LENGTH + 1];
char status[MAX_DESC_LENGTH + 1];
struct printJob *next;
} bt_print_job;
// Although there is no maximum number of entries that can be queued for
// printing, except as limited by available disk space, for simplicity
// BeServed will only report on the first MAX_PRINT_JOBS in the queue.
// This keeps the print job query from requiring repeated calls to handle
// large volume.
#define MAX_PRINT_JOBS (BT_MAX_IO_BUFFER / sizeof(bt_print_job))
int btPrintJobNew(char *printerName, char *user, char *password, int client_s_addr, char *jobName, char *jobId);
int btPrintJobData(char *printerName, char *jobId, char *jobData, int dataLen);
int btPrintJobCommit(char *printerName, char *jobId);
int btPrintJobQuery(char *printerName, bt_print_job *jobList);
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Some files were not shown because too many files have changed in this diff Show More