summaryrefslogtreecommitdiff
path: root/splashscreen/src
diff options
context:
space:
mode:
authorwatcherhd <watcherhd@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb>2011-04-21 14:14:52 +0000
committerwatcherhd <watcherhd@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb>2011-04-21 14:14:52 +0000
commitcb4a46e7fbe62d788e66ed6121c717a2d22a4d7c (patch)
tree30df260fdc5a1b5a7049c2f8cac8b7ef17513d6d /splashscreen/src
parent19b6f534d2e784a1e120bf52c4aa07004798f473 (diff)
svn.miranda.im is moving to a new home!
git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@7 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb
Diffstat (limited to 'splashscreen/src')
-rw-r--r--splashscreen/src/bitmap_funcs.cpp838
-rw-r--r--splashscreen/src/bitmap_funcs.h105
-rw-r--r--splashscreen/src/debug.h74
-rw-r--r--splashscreen/src/headers.h90
-rw-r--r--splashscreen/src/m_folders.h284
-rw-r--r--splashscreen/src/m_splash.h6
-rw-r--r--splashscreen/src/m_updater.h150
-rw-r--r--splashscreen/src/main.cpp534
-rw-r--r--splashscreen/src/msvc6.rc2
-rw-r--r--splashscreen/src/options.cpp438
-rw-r--r--splashscreen/src/resource.h36
-rw-r--r--splashscreen/src/services.cpp87
-rw-r--r--splashscreen/src/splash.cpp450
-rw-r--r--splashscreen/src/splash.h44
-rw-r--r--splashscreen/src/splash.rc152
-rw-r--r--splashscreen/src/version.h3
-rw-r--r--splashscreen/src/version.rc115
17 files changed, 3408 insertions, 0 deletions
diff --git a/splashscreen/src/bitmap_funcs.cpp b/splashscreen/src/bitmap_funcs.cpp
new file mode 100644
index 0000000..162d832
--- /dev/null
+++ b/splashscreen/src/bitmap_funcs.cpp
@@ -0,0 +1,838 @@
+#include "headers.h"
+
+#include "bitmap_funcs.h"
+
+//#include <ole2.h>
+//#include <olectl.h>
+
+BOOL (WINAPI *_mempng2dib) (BYTE*, DWORD, BITMAPINFOHEADER**);
+
+MyBitmap::MyBitmap()
+{
+ dcBmp = 0;
+ hBmp = 0;
+ bits = 0;
+ width = height = 0;
+ bitsSave = 0;
+}
+
+MyBitmap::MyBitmap(int w, int h)
+{
+ dcBmp = 0;
+ hBmp = 0;
+ bits = 0;
+ width = height = 0;
+ bitsSave = 0;
+ allocate(w,h);
+}
+
+MyBitmap::MyBitmap(const char *fn, const char *fnAlpha)
+{
+ dcBmp = 0;
+ hBmp = 0;
+ bits = 0;
+ width = height = 0;
+ bitsSave = 0;
+ loadFromFile(fn, fnAlpha);
+}
+
+MyBitmap::~MyBitmap()
+{
+ if (bitsSave)
+ delete [] bitsSave;
+ free();
+}
+
+void MyBitmap::makeOpaque()
+{
+ if (!bits) return;
+
+ for (int i = 0; i < width*height; i++)
+ bits[i] |= 0xff000000;
+}
+
+/*
+void MyBitmap::makeOpaqueRect(int x1, int y1, int x2, int y2)
+{
+ if (!bits) return;
+
+ for (int i = y1; i < y2; i++)
+ for (int j = x1; j < x2; j++)
+ {
+ int idx = i * width + j;
+ bits[idx] |= 0xff000000;
+ }
+}
+*/
+
+void MyBitmap::saveAlpha(int x, int y, int w, int h)
+{
+ if (bitsSave)
+ delete [] bitsSave;
+
+ if (!w) w = width;
+ if (!h) h = height;
+
+ bitsSave = new COLOR32[w*h];
+ COLOR32 *p1 = bitsSave;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ COLOR32 *p2 = bits + (y+i)*width + x;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+ *p1++ = *p2++;
+ }
+ }
+}
+
+void MyBitmap::restoreAlpha(int x, int y, int w, int h)
+{
+ if (!bitsSave)
+ return;
+
+ if (!w) w = width;
+ if (!h) h = height;
+
+ COLOR32 *p1 = bitsSave;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ COLOR32 *p2 = bits + (y+i)*width + x;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+ if ((*p1&0x00ffffff) != (*p2&0x00ffffff))
+ {
+ *p2 |= 0xff000000;
+ } else
+ {
+ *p2 = (*p2&0x00ffffff) | (*p1&0xff000000);
+ }
+ ++p1;
+ ++p2;
+ }
+ }
+
+ delete [] bitsSave;
+ bitsSave = 0;
+}
+
+/*
+void MyBitmap::DrawBits(COLOR32 *inbits, int inw, int inh, int x, int y, int w, int h)
+{
+ if (!(bits && inbits)) return;
+
+ float kx = (float)inw / w;
+ float ky = (float)inh / h;
+
+ if (x+w >= this->getWidth())
+ w = this->getWidth() - x;
+ if (y+h >= this->getHeight())
+ h = this->getHeight() - y;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+ bits[(i+y)*width + (j+x)] = inbits[int(i*ky)*inw + int(j*kx)];
+ }
+ }
+}
+*/
+
+/*
+void MyBitmap::BlendBits(COLOR32 *inbits, int inw, int inh, int x, int y, int w, int h)
+{
+ if (!(bits && inbits)) return;
+
+ float kx = (float)inw / w;
+ float ky = (float)inh / h;
+
+ if (x+w >= this->getWidth())
+ w = this->getWidth() - x;
+ if (y+h >= this->getHeight())
+ h = this->getHeight() - y;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+ COLOR32 src = inbits[int(i*ky)*inw + int(j*kx)];
+ COLOR32 dst = bits[(i+y)*width + (j+x)];
+ long alpha = geta(src);
+ bits[(i+y)*width + (j+x)] = rgba(
+ getr(src)+(255-alpha)*getr(dst)/255,
+ getg(src)+(255-alpha)*getg(dst)/255,
+ getb(src)+(255-alpha)*getb(dst)/255,
+ geta(src)+(255-alpha)*geta(dst)/255
+ );
+ }
+ }
+}
+*/
+void MyBitmap::Blend(MyBitmap *bmp, int x, int y, int w, int h)
+{
+ if (!(bits && bmp && bmp->bits)) return;
+
+ if (!w) w = bmp->width;
+ if (!h) h = bmp->height;
+ float kx = (float)bmp->width / w;
+ float ky = (float)bmp->height / h;
+
+ if (x+w >= this->getWidth())
+ w = this->getWidth() - x;
+ if (y+h >= this->getHeight())
+ h = this->getHeight() - y;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+ COLOR32 src = bmp->bits[int(i*ky)*bmp->width + int(j*kx)];
+ COLOR32 dst = bits[(i+y)*width + (j+x)];
+ long alpha = geta(src);
+ bits[(i+y)*width + (j+x)] = rgba(
+ getr(src)+(255-alpha)*getr(dst)/255,
+ getg(src)+(255-alpha)*getg(dst)/255,
+ getb(src)+(255-alpha)*getb(dst)/255,
+ geta(src)+(255-alpha)*geta(dst)/255
+ );
+ }
+ }
+}
+
+/*
+void MyBitmap::Draw(MyBitmap *bmp, int x, int y, int w, int h)
+{
+ if (!(bits && bmp && bmp->bits)) return;
+
+ if (!w) w = bmp->width;
+ if (!h) h = bmp->height;
+ float kx = (float)bmp->width / w;
+ float ky = (float)bmp->height / h;
+
+ if (x+w >= this->getWidth())
+ w = this->getWidth() - x;
+ if (y+h >= this->getHeight())
+ h = this->getHeight() - y;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+ bits[(i+y)*width + (j+x)] = bmp->bits[int(i*ky)*bmp->width + int(j*kx)];
+ }
+ }
+}
+*/
+
+/*
+void MyBitmap::BlendColorized(MyBitmap *bmp, int x, int y, int w, int h, COLOR32 color)
+{
+ if (!(bits && bmp && bmp->bits)) return;
+
+ if (!w) w = bmp->width;
+ if (!h) h = bmp->height;
+ float kx = (float)bmp->width / w;
+ float ky = (float)bmp->height / h;
+
+ // we should swap B and R channels when working with win32 COLORREF
+ float koef1r = (255 - getb(color)) / 128.0;
+ float koef1g = (255 - getg(color)) / 128.0;
+ float koef1b = (255 - getr(color)) / 128.0;
+
+ int br = - 255 + 2 * getb(color);
+ int bg = - 255 + 2 * getg(color);
+ int bb = - 255 + 2 * getr(color);
+
+ float koef2r = (getb(color)) / 128.0;
+ float koef2g = (getg(color)) / 128.0;
+ float koef2b = (getr(color)) / 128.0;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+
+// COLOR32 cl = getr(bmp->bits[int(i*ky)*bmp->width + int(j*kx)]);
+// bits[(i+y)*width + (j+x)] = (cl > 128) ?
+// rgba(koef1r * cl + br, koef1g * cl + bg, koef1b * cl + bb, geta(bmp->bits[int(i*ky)*bmp->width + int(j*kx)])):
+// rgba(koef2r * cl, koef2g * cl, koef2b * cl, geta(bmp->bits[int(i*ky)*bmp->width + int(j*kx)]));
+
+ long alpha = geta(bmp->bits[int(i*ky)*bmp->width + int(j*kx)]);
+// COLOR32 cl = getr(bmp->bits[int(i*ky)*bmp->width + int(j*kx)]);
+ COLOR32 cl = alpha ? getr(bmp->bits[int(i*ky)*bmp->width + int(j*kx)])*255/alpha : 0;
+ COLOR32 src = (cl > 128) ?
+ rgba(
+ (koef1r * cl + br)*alpha/255,
+ (koef1g * cl + bg)*alpha/255,
+ (koef1b * cl + bb)*alpha/255,
+ alpha):
+ rgba(
+ koef2r * cl * alpha/255,
+ koef2g * cl * alpha/255,
+ koef2b * cl * alpha/255,
+ alpha);
+// COLOR32 cl = getr(bmp->bits[int(i*ky)*bmp->width + int(j*kx)]);
+// COLOR32 src = (cl > 128) ?
+// rgba(koef1r * cl + br, koef1g * cl + bg, koef1b * cl + bb, alpha):
+// rgba(koef2r * cl, koef2g * cl, koef2b * cl, alpha);
+ COLOR32 dst = bits[(i+y)*width + (j+x)];
+// long alpha = geta(src);
+ bits[(i+y)*width + (j+x)] = rgba(
+ getr(src)+(255-alpha)*getr(dst)/255,
+ getg(src)+(255-alpha)*getg(dst)/255,
+ getb(src)+(255-alpha)*getb(dst)/255,
+ geta(src)+(255-alpha)*geta(dst)/255
+ );
+
+ }
+ }
+}
+*/
+
+/*
+void MyBitmap::DrawColorized(MyBitmap *bmp, int x, int y, int w, int h, COLOR32 color)
+{
+ if (!(bits && bmp && bmp->bits)) return;
+
+ if (!w) w = bmp->width;
+ if (!h) h = bmp->height;
+ float kx = (float)bmp->width / w;
+ float ky = (float)bmp->height / h;
+
+ // we should swap B and R channels when working with win32 COLORREF
+ float koef1r = (255 - getb(color)) / 128.0;
+ float koef1g = (255 - getg(color)) / 128.0;
+ float koef1b = (255 - getr(color)) / 128.0;
+
+ int br = - 255 + 2 * getb(color);
+ int bg = - 255 + 2 * getg(color);
+ int bb = - 255 + 2 * getr(color);
+
+ float koef2r = (getb(color)) / 128.0;
+ float koef2g = (getg(color)) / 128.0;
+ float koef2b = (getr(color)) / 128.0;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+
+ long alpha = geta(bmp->bits[int(i*ky)*bmp->width + int(j*kx)]);
+// COLOR32 cl = getr(bmp->bits[int(i*ky)*bmp->width + int(j*kx)]);
+ COLOR32 cl = alpha ? getr(bmp->bits[int(i*ky)*bmp->width + int(j*kx)])*255/alpha : 0;
+ bits[(i+y)*width + (j+x)] = (cl > 128) ?
+ rgba(
+ (koef1r * cl + br)*alpha/255,
+ (koef1g * cl + bg)*alpha/255,
+ (koef1b * cl + bb)*alpha/255,
+ alpha):
+ rgba(
+ koef2r * cl * alpha/255,
+ koef2g * cl * alpha/255,
+ koef2b * cl * alpha/255,
+ alpha);
+// bits[(i+y)*width + (j+x)] = (cl > 128) ?
+// rgba(koef1r * cl + br, koef1g * cl + bg, koef1b * cl + bb, geta(bmp->bits[int(i*ky)*bmp->width + int(j*kx)])):
+// rgba(koef2r * cl, koef2g * cl, koef2b * cl, geta(bmp->bits[int(i*ky)*bmp->width + int(j*kx)]));
+ }
+ }
+}
+*/
+
+/*
+void MyBitmap::BlendPart(MyBitmap *bmp, int xin, int yin, int win, int hin, int x, int y, int w, int h)
+{
+ if (!(bits && bmp && bmp->bits)) return;
+
+ if (!w) w = win;
+ if (!h) h = hin;
+ float kx = (float)win / w;
+ float ky = (float)hin / h;
+
+ if (x+w >= this->getWidth())
+ w = this->getWidth() - x;
+ if (y+h >= this->getHeight())
+ h = this->getHeight() - y;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+ COLOR32 src = bmp->bits[int(yin+i*ky)*bmp->width + int(xin+j*kx)];
+ COLOR32 dst = bits[(i+y)*width + (j+x)];
+ long alpha = geta(src);
+ bits[(i+y)*width + (j+x)] = rgba(
+ getr(src)+(255-alpha)*getr(dst)/255,
+ getg(src)+(255-alpha)*getg(dst)/255,
+ getb(src)+(255-alpha)*getb(dst)/255,
+ geta(src)+(255-alpha)*geta(dst)/255
+ );
+// bits[(i+y)*width + (j+x)] = bmp->bits[int(yin+i*ky)*bmp->width + int(xin+j*kx)];
+ }
+ }
+}
+*/
+
+/*
+void MyBitmap::BlendPartColorized(MyBitmap *bmp, int xin, int yin, int win, int hin, int x, int y, int w, int h, COLOR32 color)
+{
+ if (!(bits && bmp && bmp->bits)) return;
+
+ if (!w) w = win;
+ if (!h) h = hin;
+ float kx = (float)win / w;
+ float ky = (float)hin / h;
+
+ if (x+w >= this->getWidth())
+ w = this->getWidth() - x;
+ if (y+h >= this->getHeight())
+ h = this->getHeight() - y;
+
+ // we should swap B and R channels when working with win32 COLORREF
+ float koef1r = (255 - getb(color)) / 128.0;
+ float koef1g = (255 - getg(color)) / 128.0;
+ float koef1b = (255 - getr(color)) / 128.0;
+
+ int br = - 255 + 2 * getb(color);
+ int bg = - 255 + 2 * getg(color);
+ int bb = - 255 + 2 * getr(color);
+
+ float koef2r = (getb(color)) / 128.0;
+ float koef2g = (getg(color)) / 128.0;
+ float koef2b = (getr(color)) / 128.0;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+
+ long alpha = geta(bmp->bits[int(yin+i*ky)*bmp->width + int(xin+j*kx)]);
+// COLOR32 cl = getr(bmp->bits[int(i*ky)*bmp->width + int(j*kx)]);
+ COLOR32 cl = alpha ? getr(bmp->bits[int(yin+i*ky)*bmp->width + int(xin+j*kx)])*255/alpha : 0;
+ COLOR32 src = (cl > 128) ?
+ rgba(
+ (koef1r * cl + br)*alpha/255,
+ (koef1g * cl + bg)*alpha/255,
+ (koef1b * cl + bb)*alpha/255,
+ alpha):
+ rgba(
+ koef2r * cl * alpha/255,
+ koef2g * cl * alpha/255,
+ koef2b * cl * alpha/255,
+ alpha);
+// COLOR32 cl = getr(bmp->bits[int(i*ky)*bmp->width + int(j*kx)]);
+// COLOR32 src = (cl > 128) ?
+// rgba(koef1r * cl + br, koef1g * cl + bg, koef1b * cl + bb, alpha):
+// rgba(koef2r * cl, koef2g * cl, koef2b * cl, alpha);
+ COLOR32 dst = bits[(i+y)*width + (j+x)];
+// long alpha = geta(src);
+ bits[(i+y)*width + (j+x)] = rgba(
+ getr(src)+(255-alpha)*getr(dst)/255,
+ getg(src)+(255-alpha)*getg(dst)/255,
+ getb(src)+(255-alpha)*getb(dst)/255,
+ geta(src)+(255-alpha)*geta(dst)/255
+ );
+
+ COLOR32 src = bmp->bits[int(yin+i*ky)*bmp->width + int(xin+j*kx)];
+ COLOR32 dst = bits[(i+y)*width + (j+x)];
+ long alpha = geta(src);
+ bits[(i+y)*width + (j+x)] = rgba(
+ getr(src)+(255-alpha)*getr(dst)/255,
+ getg(src)+(255-alpha)*getg(dst)/255,
+ getb(src)+(255-alpha)*getb(dst)/255,
+ geta(src)+(255-alpha)*geta(dst)/255
+ );
+// bits[(i+y)*width + (j+x)] = bmp->bits[int(yin+i*ky)*bmp->width + int(xin+j*kx)];
+ }
+ }
+}
+*/
+
+/*
+void MyBitmap::DrawPart(MyBitmap *bmp, int xin, int yin, int win, int hin, int x, int y, int w, int h)
+{
+ if (!(bits && bmp && bmp->bits)) return;
+
+ if (!w) w = win;
+ if (!h) h = hin;
+ float kx = (float)win / w;
+ float ky = (float)hin / h;
+
+ if (x+w >= this->getWidth())
+ w = this->getWidth() - x;
+ if (y+h >= this->getHeight())
+ h = this->getHeight() - y;
+
+ for (int i = 0; i < h; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ for (int j = 0; j < w; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+ bits[(i+y)*width + (j+x)] = bmp->bits[int(yin+i*ky)*bmp->width + int(xin+j*kx)];
+ }
+ }
+}
+*/
+
+/*
+void MyBitmap::DrawNoAlpha(MyBitmap *bmp, int x, int y, int w, int h)
+{
+ if (!(bits && bmp && bmp->bits)) return;
+
+ for (int i = 0; i < bmp->height; i++)
+ {
+ if (i+y < 0) continue;
+ if (i+y >= height) break;
+ for (int j = 0; j < bmp->width; j++)
+ {
+ if (j+x < 0) continue;
+ if (j+x >= width) break;
+ bits[(i+y)*width + (j+x)] = bmp->bits[i*bmp->width + j];
+ }
+ }
+}
+*/
+
+/*
+void MyBitmap::DrawIcon(HICON hic, int x, int y, int w, int h)
+{
+ ICONINFO info;
+ GetIconInfo(hic, &info);
+
+ BITMAP bmpColor, bmpMask;
+ GetObject(info.hbmMask, sizeof(bmpMask), &bmpMask);
+ GetObject(info.hbmColor, sizeof(bmpColor), &bmpColor);
+
+ if (!w) w = abs(bmpMask.bmWidth);
+ if (!h) h = abs(bmpMask.bmHeight);
+
+ if (bmpColor.bmBitsPixel == 32)
+ {
+ if ((w != abs(bmpMask.bmWidth)) || (h != abs(bmpMask.bmHeight)))
+ {
+ DeleteObject(info.hbmColor);
+ DeleteObject(info.hbmMask);
+ hic = (HICON)CopyImage(hic,IMAGE_ICON,w,h,LR_COPYFROMRESOURCE);
+ GetIconInfo(hic, &info);
+ GetObject(info.hbmMask, sizeof(bmpMask), &bmpMask);
+ GetObject(info.hbmColor, sizeof(bmpColor), &bmpColor);
+ }
+
+ BYTE *cbit = new BYTE[bmpColor.bmWidthBytes*bmpColor.bmHeight];
+ BYTE *mbit = new BYTE[bmpMask.bmWidthBytes*bmpMask.bmHeight];
+ GetBitmapBits(info.hbmColor, bmpColor.bmWidthBytes*bmpColor.bmHeight, cbit);
+ GetBitmapBits(info.hbmMask, bmpMask.bmWidthBytes*bmpMask.bmHeight, mbit);
+
+ for (int i = 0; i < bmpColor.bmHeight; i++)
+ {
+ for (int j = 0; j < bmpColor.bmWidth; j++)
+ {
+ BYTE *pixel = cbit + i*bmpColor.bmWidthBytes + j*4;
+ if (!pixel[3])
+ {
+ pixel[3] = (*(mbit + i*bmpMask.bmWidthBytes + j*bmpMask.bmBitsPixel/8) & (1<<(7-j%8))) ? 0 : 255;
+ }
+
+ if (pixel[3] != 255)
+ {
+ pixel[0] = pixel[0] * pixel[3] / 255;
+ pixel[1] = pixel[1] * pixel[3] / 255;
+ pixel[2] = pixel[2] * pixel[3] / 255;
+ }
+ }
+ }
+
+ this->BlendBits((COLOR32 *)cbit, bmpColor.bmWidth, bmpColor.bmHeight, x, y, w, h);
+
+ delete [] mbit;
+ delete [] cbit;
+ } else
+ {
+ this->saveAlpha(x,y,w,h);
+ DrawIconEx(this->getDC(), x, y, hic, w, h, 0, NULL, DI_NORMAL);
+ this->restoreAlpha(x,y,w,h);
+ }
+
+ DeleteObject(info.hbmColor);
+ DeleteObject(info.hbmMask);
+}
+*/
+
+void MyBitmap::DrawText(char *str, int x, int y)
+{
+ SIZE sz; GetTextExtentPoint32(this->getDC(), str, lstrlen(str), &sz);
+ RECT rc; SetRect(&rc, x, y, x+10000, y+10000);
+ this->saveAlpha(x-2,y-2,sz.cx+2,sz.cy+2);
+ ::DrawText(this->getDC(), str, strlen(str), &rc, DT_LEFT | DT_TOP | DT_SINGLELINE | DT_NOPREFIX);
+ this->restoreAlpha(x-2,y-2,sz.cx+2,sz.cy+2);
+ //(x,y,sz.cx,sz.cy);
+}
+
+/*
+void MyBitmap::DrawTextW(WCHAR *str, int x, int y)
+{
+ if (MyGetTextExtentPoint32W && MyDrawTextW)
+ {
+ SIZE sz; MyGetTextExtentPoint32W(this->getDC(), str, MylstrlenW(str), &sz);
+ RECT rc; SetRect(&rc, x, y, x+10000, y+10000);
+ this->saveAlpha(x,y,sz.cx,sz.cy);
+ MyDrawTextW(this->getDC(), str, MylstrlenW(str), &rc, DT_LEFT | DT_TOP | DT_SINGLELINE | DT_NOPREFIX);
+ this->restoreAlpha(x,y,sz.cx,sz.cy);
+ }
+}
+*/
+
+HRGN MyBitmap::buildOpaqueRgn()
+{
+ return CreateRectRgn(0, 0, width, height);
+
+ //
+ int i, rectCount = 0;
+ for (i = 0; i < width*height; i++)
+ if (((bits[i] >> 24)&0xff) >= 128)
+ rectCount++;
+
+ RGNDATA *rgnData = (RGNDATA *)malloc(sizeof(RGNDATAHEADER) + rectCount * sizeof(RECT));
+ rgnData->rdh.dwSize = sizeof(RGNDATAHEADER);
+ rgnData->rdh.iType = RDH_RECTANGLES;
+ rgnData->rdh.nCount = rectCount;
+ rgnData->rdh.nRgnSize = rectCount * sizeof(RECT);
+ SetRect(&(rgnData->rdh.rcBound), 0, 0, width, height);
+
+ char *p = (char *)&(rgnData->Buffer);
+ for (i = 0; i < width*height; i++)
+ if (((bits[i] >> 24)&0xff) >= 128)
+ {
+ SetRect((LPRECT)p, i%width,i/width,i%width+1,i/width+1);
+ p += sizeof(RECT);
+ }
+
+ HRGN rgn = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + rectCount * sizeof(RECT), rgnData);
+ ::free(rgnData);
+
+ return rgn;
+}
+
+bool MyBitmap::loadFromFile(const char *fn, const char *fnAlpha)
+{
+ if (bits) free();
+
+ SIZE sz;
+
+ char ext[5];
+ memcpy(ext,fn+(strlen(fn)-4),5);
+
+ if (!lstrcmpi(ext,".png"))
+ {
+ HANDLE hFile, hMap = NULL;
+ BYTE* ppMap = NULL;
+ long cbFileSize = 0;
+ BITMAPINFOHEADER* pDib;
+ BYTE* pDibBits = 0;
+
+ if (!png2dibConvertor) {
+ return false;
+ }
+
+ if ((hFile = CreateFileA(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE)
+ if ((hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL)
+ if ((ppMap = (BYTE*)MapViewOfFile( hMap, FILE_MAP_READ, 0, 0, 0 )) != NULL)
+ cbFileSize = GetFileSize(hFile, NULL);
+ if ( cbFileSize != 0 )
+ {
+ PNG2DIB param;
+ param.pSource = ppMap;
+ param.cbSourceSize = cbFileSize;
+ param.pResult = &pDib;
+
+ if (png2dibConvertor((char*)param.pSource, param.cbSourceSize, param.pResult))
+ pDibBits = (BYTE*)(pDib+1);
+ else
+ cbFileSize = 0;
+ #ifdef _DEBUG
+ logMessage("Loading splash file","done");
+ #endif
+
+ }
+
+ if (ppMap) UnmapViewOfFile(ppMap);
+ if (hMap) CloseHandle(hMap);
+ if (hFile) CloseHandle(hFile);
+
+ if (!cbFileSize) return false;
+
+ BITMAPINFO *bi=(BITMAPINFO*)pDib;
+ BYTE *pt=(BYTE*)bi;
+ pt+=bi->bmiHeader.biSize;
+ HBITMAP hBitmap = NULL;
+
+ if (bi->bmiHeader.biBitCount!=32)
+ {
+ allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight));
+ HDC hdcTmp = CreateCompatibleDC(getDC());
+ HBITMAP hBitmap = CreateDIBitmap(getDC(), pDib, CBM_INIT, pDibBits, bi, DIB_PAL_COLORS);
+ SelectObject(hdcTmp, hBitmap);
+ BitBlt(this->getDC(), 0, 0, abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight), hdcTmp, 0, 0, SRCCOPY);
+ this->makeOpaque();
+ DeleteDC(hdcTmp);
+ DeleteObject(hBitmap);
+
+ }
+ else
+ {
+ BYTE *ptPixels = pt;
+ hBitmap = CreateDIBSection(NULL, bi, DIB_RGB_COLORS, (void **)&ptPixels, NULL, 0);
+ memcpy(ptPixels,pt,bi->bmiHeader.biSizeImage);
+
+ allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight));
+ //memcpy(bits, pt, bi->bmiHeader.biSizeImage);
+
+ BYTE *p2=(BYTE *)pt;
+ for (int y=0; y<bi->bmiHeader.biHeight; ++y)
+ {
+ BYTE *p1=(BYTE *)bits + (bi->bmiHeader.biHeight-y-1)*bi->bmiHeader.biWidth*4;
+ for (int x=0; x<bi->bmiHeader.biWidth; ++x)
+ {
+ p1[0]= p2[0];
+ p1[1]= p2[1];
+ p1[2]= p2[2];
+ p1[3]= p2[3];
+ p1 += 4;
+ p2 += 4;
+ }
+ }
+
+ premultipleChannels();
+ }
+
+ GlobalFree(pDib);
+ DeleteObject(hBitmap);
+ return true;
+ } else
+ {
+ HBITMAP hBmpLoaded = (HBITMAP)LoadImage(NULL, fn, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
+ if (!hBmpLoaded)
+ {
+ #ifdef _DEBUG
+ logMessage("MyBitmap::loadFromFile", "Bitmap load failed");
+ #endif
+ return false;
+ }
+
+ BITMAP bm; GetObject(hBmpLoaded, sizeof(bm), &bm);
+ SetBitmapDimensionEx(hBmpLoaded, bm.bmWidth, bm.bmHeight, NULL);
+
+ HDC dcTmp = CreateCompatibleDC(0);
+ GetBitmapDimensionEx(hBmpLoaded, &sz);
+ HBITMAP hBmpDcSave = (HBITMAP)SelectObject(dcTmp, hBmpLoaded);
+
+ allocate(sz.cx, sz.cy);
+ BitBlt(dcBmp, 0, 0, width, height, dcTmp, 0, 0, SRCCOPY);
+
+ DeleteObject(SelectObject(dcTmp, hBmpDcSave));
+ DeleteDC(dcTmp);
+
+ MyBitmap alpha;
+ if (fnAlpha && alpha.loadFromFile(fnAlpha) &&
+ (alpha.getWidth() == width) &&
+ (alpha.getHeight() == height) )
+ {
+ for (int i = 0; i < width*height; i++)
+ bits[i] = (bits[i] & 0x00ffffff) | ( (alpha.bits[i] & 0x000000ff) << 24 );
+ premultipleChannels();
+ } else
+ {
+ makeOpaque();
+ }
+ return true;
+ }
+ // unreachable place
+ return false;
+}
+
+void MyBitmap::allocate(int w, int h)
+{
+ width = w;
+ height = h;
+
+ BITMAPINFO bi;
+
+ bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
+ bi.bmiHeader.biWidth = w;
+ bi.bmiHeader.biHeight = -h;
+ bi.bmiHeader.biPlanes = 1;
+ bi.bmiHeader.biBitCount = 32;
+ bi.bmiHeader.biCompression = BI_RGB;
+
+ if (dcBmp)
+ {
+ DeleteObject(SelectObject(dcBmp, hBmpSave));
+ DeleteDC(dcBmp);
+ }
+
+ hBmp = (HBITMAP)CreateDIBSection(0, &bi, DIB_RGB_COLORS, (void **)&bits, 0, 0);
+ dcBmp = CreateCompatibleDC(0);
+ hBmpSave = (HBITMAP)SelectObject(dcBmp, hBmp);
+}
+
+void MyBitmap::free()
+{
+ DeleteObject(SelectObject(dcBmp, hBmpSave));
+ DeleteDC(dcBmp);
+
+ dcBmp = 0;
+ hBmp = 0;
+ bits = 0;
+ width = height = 0;
+}
+
+void MyBitmap::premultipleChannels()
+{
+ for (int i = 0; i < width*height; i++)
+ bits[i] = rgba(getr(bits[i])*geta(bits[i])/255, getg(bits[i])*geta(bits[i])/255, getb(bits[i])*geta(bits[i])/255, geta(bits[i]));
+}
diff --git a/splashscreen/src/bitmap_funcs.h b/splashscreen/src/bitmap_funcs.h
new file mode 100644
index 0000000..83f22bd
--- /dev/null
+++ b/splashscreen/src/bitmap_funcs.h
@@ -0,0 +1,105 @@
+#ifndef __bitmap_funcs_h__
+#define __bitmap_funcs_h__
+
+// This should make bitmap manipulations much easier...
+class MyBitmap
+{
+public:
+ typedef unsigned long COLOR32;
+ static inline COLOR32 RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0xff)
+ {
+ return (a << 24) | (r << 16) | (g << 8) | b;
+ };
+
+private:
+ HBITMAP hBmpSave, hBmp;
+ HDC dcBmp;
+ COLOR32 *bits;
+ COLOR32 *bitsSave;
+ int width, height;
+
+ void allocate(int w, int h);
+ void free();
+
+ void premultipleChannels();
+
+public:
+ MyBitmap();
+ MyBitmap(int w, int h);
+ MyBitmap(const char *fn, const char *fnAlpha = 0);
+ ~MyBitmap();
+
+ bool loadFromFile(const char *fn, const char *fnAlpha = 0);
+
+ int getWidth() { return width; }
+ int getHeight() { return height; }
+
+ HDC getDC() { return dcBmp; }
+ HBITMAP getBitmap() { return hBmp; }
+
+
+ void makeOpaque();
+ /*
+ void makeOpaqueRect(int x1, int y1, int x2, int y2);
+ void makeOpaqueRect(RECT rc) { makeOpaqueRect(rc.left, rc.top, rc.right, rc.bottom); }
+ */
+
+ void saveAlpha(int x = 0, int y = 0, int w = 0, int h = 0);
+ void restoreAlpha(int x = 0, int y = 0, int w = 0, int h = 0);
+
+ /*
+ void DrawBits(COLOR32 *inbits, int inw, int inh, int x, int y, int w, int h);
+ void BlendBits(COLOR32 *inbits, int inw, int inh, int x, int y, int w, int h);
+
+ void DrawNoAlpha(MyBitmap *bmp, int x, int y, int w, int h);
+ */
+ void Blend(MyBitmap *bmp, int x, int y, int w, int h);
+ /*
+ void Draw(MyBitmap *bmp, int x, int y, int w, int h);
+
+ void BlendColorized(MyBitmap *bmp, int x, int y, int w, int h, COLOR32 color);
+ void DrawColorized(MyBitmap *bmp, int x, int y, int w, int h, COLOR32 color);
+
+ void BlendPart(MyBitmap *bmp, int xin, int yin, int win, int hin, int x, int y, int w, int h);
+ void BlendPartColorized(MyBitmap *bmp, int xin, int yin, int win, int hin, int x, int y, int w, int h, COLOR32 color);
+ void DrawPart(MyBitmap *bmp, int xin, int yin, int win, int hin, int x, int y, int w, int h);
+// void DrawPartNoAlpha(MyBitmap *bmp, int x, int y, int w, int h);
+// void DrawPartColorized(MyBitmap *bmp, int x, int y, int w, int h, COLOR32 color);
+
+ void DrawIcon(HICON hic, int x, int y, int w = 0, int h = 0);
+ */
+ void DrawText(char *str, int x, int y);
+ /*
+ void DrawTextW(WCHAR *str, int x, int y);
+ */
+
+
+ inline COLOR32 *getBits() { return bits; }
+ inline COLOR32 *getRow(int row) { return bits + row * width; }
+ inline COLOR32 *operator[] (int row) { return bits + row * width; }
+
+ COLOR32 rgba(COLOR32 r, COLOR32 g, COLOR32 b, COLOR32 a)
+ {
+ return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff);
+ }
+ COLOR32 getr(COLOR32 c)
+ {
+ return (c >> 16) & 0xff;
+ }
+ COLOR32 getg(COLOR32 c)
+ {
+ return (c >> 8) & 0xff;
+ }
+ COLOR32 getb(COLOR32 c)
+ {
+ return c & 0xff;
+ }
+ COLOR32 geta(COLOR32 c)
+ {
+ return (c >> 24) & 0xff;
+ }
+
+ HRGN buildOpaqueRgn();
+};
+
+#endif // __bitmap_funcs_h__
diff --git a/splashscreen/src/debug.h b/splashscreen/src/debug.h
new file mode 100644
index 0000000..3e8ac38
--- /dev/null
+++ b/splashscreen/src/debug.h
@@ -0,0 +1,74 @@
+#ifndef __debug_h__
+#define __debug_h__
+
+#include <stdio.h>
+
+#define PlugName "SplashScreen"
+extern char szLogFile[MAX_PATH];
+
+/*
+ * output a notification message.
+ * may accept a hContact to include the contacts nickname in the notification message...
+ * the actual message is using printf() rules for formatting and passing the arguments...
+ *
+ */
+
+int inline _DebugPopup(HANDLE hContact, const char *fmt, ...)
+{
+ POPUPDATA ppd;
+ va_list va;
+ char debug[1024];
+ int ibsize = 1023;
+
+ va_start(va, fmt);
+ _vsnprintf(debug, ibsize, fmt, va);
+
+ if(CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0) == 1) {
+ ZeroMemory((void *)&ppd, sizeof(ppd));
+ ppd.lchContact = hContact;
+ ppd.lchIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+ if(hContact != 0)
+ strncpy(ppd.lpzContactName, (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,0), MAX_CONTACTNAME);
+ else
+ strncpy(ppd.lpzContactName, PlugName, MAX_CONTACTNAME);
+ strncat(ppd.lpzText, debug, MAX_SECONDLINE - 20);
+ ppd.colorText = RGB(255,255,255);
+ ppd.colorBack = RGB(255,0,0);
+ CallService(MS_POPUP_ADDPOPUP, (WPARAM)&ppd, 0);
+ }
+ return 0;
+}
+
+/*
+ * initialize logfile
+ */
+
+int inline initLog()
+{
+ fclose(fopen(szLogFile,"w"));
+ return 0;
+}
+
+/*
+ * log timestamp
+ */
+
+void inline logTimeStamp()
+{
+ FILE *f = fopen(szLogFile, "a");
+ fprintf(f,"Time: %s\n", __TIME__);
+ fclose(f);
+}
+
+/*
+ * logging func
+ */
+
+void inline logMessage(const char *func, const char *msg)
+{
+ FILE *f = fopen(szLogFile, "a");
+ fprintf(f,"%s:\t\t%s\n", func, msg);
+ fclose(f);
+}
+
+#endif // __debug_h__ \ No newline at end of file
diff --git a/splashscreen/src/headers.h b/splashscreen/src/headers.h
new file mode 100644
index 0000000..e4b0b8a
--- /dev/null
+++ b/splashscreen/src/headers.h
@@ -0,0 +1,90 @@
+/*
+ Splash Screen Plugin for Miranda-IM (www.miranda-im.org)
+ (c) 2004-2007 nullbie, (c) 2005-2007 Thief
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ File name : $URL: http://svn.miranda.im/mainrepo/splashscreen/trunk/src/headers.h $
+ Revision : $Rev: 1587 $
+ Last change on : $Date: 2010-04-09 13:01:30 +0300 (Пт, 09 апр 2010) $
+ Last change by : $Author: Thief $
+*/
+
+#ifndef HEADERS_H
+#define HEADERS_H
+
+#define _WIN32_WINNT 0x0500
+#define WINVER 0x0400
+#define AC_SRC_ALPHA 0x01
+#define OEMRESOURCE
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include <windows.h>
+#include <stdio.h>
+#include <commctrl.h>
+#include <time.h>
+
+// Internal defines
+#define SPLASH_CLASS "MirandaSplash"
+#define WM_LOADED (WM_USER + 10)
+#define BuildDate __DATE__" "__TIME__
+
+struct SPLASHOPTS
+{
+ byte active;
+ byte playsnd;
+ byte loopsnd;
+ byte runonce;
+ byte fadein;
+ byte fadeout;
+ byte inheritGS;
+ byte random;
+ byte showversion;
+ byte fontsize;
+ int showtime;
+ int fosteps;
+ int fisteps;
+};
+
+extern SPLASHOPTS options;
+
+// png2dib interface
+typedef BOOL ( *pfnConvertPng2dib )( char*, size_t, BITMAPINFOHEADER** );
+extern pfnConvertPng2dib png2dibConvertor;
+
+// Common headers
+#include "version.h"
+#include "resource.h"
+#include "bitmap_funcs.h"
+#include "m_splash.h"
+
+// Miranda API headers
+#include <newpluginapi.h>
+#include <m_database.h>
+#include <m_options.h>
+#include <m_utils.h>
+#include <m_langpack.h>
+#include <m_system.h>
+#include <m_png.h>
+#include "m_updater.h"
+
+#ifdef _DEBUG
+#include <m_clist.h>
+#include <m_skin.h>
+#include <m_popup.h>
+#include "debug.h"
+#endif
+
+#endif //HEADERS_H
diff --git a/splashscreen/src/m_folders.h b/splashscreen/src/m_folders.h
new file mode 100644
index 0000000..5971cff
--- /dev/null
+++ b/splashscreen/src/m_folders.h
@@ -0,0 +1,284 @@
+/*
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_CUSTOM_FOLDERS_H
+#define M_CUSTOM_FOLDERS_H
+
+#define FOLDERS_API 501 //dunno why it's here but it is :)
+
+#define PROFILE_PATH "%profile_path%"
+#define CURRENT_PROFILE "%current_profile%"
+#define MIRANDA_PATH "%miranda_path%"
+#define PLUGINS_PATH "%miranda_path%" "\\plugins"
+#define MIRANDA_USERDATA "%miranda_userdata%"
+
+#define TO_WIDE(x) L ## x
+
+#define PROFILE_PATHW L"%profile_path%"
+#define CURRENT_PROFILEW L"%current_profile%"
+#define MIRANDA_PATHW L"%miranda_path%"
+#define MIRANDA_USERDATAW L"%miranda_userdata%"
+
+#define FOLDER_AVATARS PROFILE_PATH "\\" CURRENT_PROFILE "\\avatars"
+#define FOLDER_VCARDS PROFILE_PATH "\\" CURRENT_PROFILE "\\vcards"
+#define FOLDER_LOGS PROFILE_PATH "\\" CURRENT_PROFILE "\\logs"
+#define FOLDER_RECEIVED_FILES PROFILE_PATH "\\" CURRENT_PROFILE "\\received files"
+#define FOLDER_DOCS MIRANDA_PATH "\\" "docs"
+
+#define FOLDER_CONFIG PLUGINS_PATH "\\" "config"
+
+#define FOLDER_SCRIPTS MIRANDA_PATH "\\" "scripts"
+
+#define FOLDER_UPDATES MIRANDA_PATH "\\" "updates"
+
+#define FOLDER_CUSTOMIZE MIRANDA_PATH "\\" "customize"
+#define FOLDER_CUSTOMIZE_SOUNDS FOLDER_CUSTOMIZE "\\sounds"
+#define FOLDER_CUSTOMIZE_ICONS FOLDER_CUSTOMIZE "\\icons"
+#define FOLDER_CUSTOMIZE_SMILEYS FOLDER_CUSTOMIZE "\\smileys"
+#define FOLDER_CUSTOMIZE_SKINS FOLDER_CUSTOMIZE "\\skins"
+#define FOLDER_CUSTOMIZE_THEMES FOLDER_CUSTOMIZE "\\themes"
+
+
+#define FOLDERS_NAME_MAX_SIZE 64 //maximum name and section size
+
+#define FF_UNICODE 0x00000001
+
+#if defined (UNICODE)
+ #define FF_TCHAR FF_UNICODE
+#else
+ #define FF_TCHAR 0
+#endif
+
+typedef struct{
+ int cbSize; //size of struct
+ char szSection[FOLDERS_NAME_MAX_SIZE]; //section name, if it doesn't exist it will be created otherwise it will just add this entry to it
+ char szName[FOLDERS_NAME_MAX_SIZE]; //entry name - will be shown in options
+ union{
+ const char *szFormat; //default string format. Fallback string in case there's no entry in the database for this folder. This should be the initial value for the path, users will be able to change it later.
+ const wchar_t *szFormatW; //String is dup()'d so you can free it later. If you set the unicode string don't forget to set the flag accordingly.
+ const TCHAR *szFormatT;
+ };
+ DWORD flags; //FF_* flags
+} FOLDERSDATA;
+
+/*Folders/Register/Path service
+ wParam - not used, must be 0
+ lParam - (LPARAM) (const FOLDERDATA *) - Data structure filled with
+ the necessary information.
+ Returns a handle to the registered path or 0 on error.
+ You need to use this to call the other services.
+*/
+#define MS_FOLDERS_REGISTER_PATH "Folders/Register/Path"
+
+/*Folders/Get/PathSize service
+ wParam - (WPARAM) (int) - handle to registered path
+ lParam - (LPARAM) (int *) - pointer to the variable that receives the size of the path
+ string (not including the null character). Depending on the flags set when creating the path
+ it will either call strlen() or wcslen() to get the length of the string.
+ Returns the size of the buffer.
+*/
+#define MS_FOLDERS_GET_SIZE "Folders/Get/PathSize"
+
+typedef struct{
+ int cbSize;
+ int nMaxPathSize; //maximum size of buffer. This represents the number of characters that can be copied to it (so for unicode strings you don't send the number of bytes but the length of the string).
+ union{
+ char *szPath; //pointer to the buffer that receives the path without the last "\\"
+ wchar_t *szPathW; //unicode version of the buffer.
+ TCHAR *szPathT;
+ };
+} FOLDERSGETDATA;
+
+/*Folders/Get/Path service
+ wParam - (WPARAM) (int) - handle to registered path
+ lParam - (LPARAM) (FOLDERSGETDATA *) pointer to a FOLDERSGETDATA that has all the relevant fields filled.
+ Should return 0 on success, or nonzero otherwise.
+*/
+#define MS_FOLDERS_GET_PATH "Folders/Get/Path"
+
+typedef struct{
+ int cbSize;
+ union{
+ char **szPath; //address of a string variable (char *) or (wchar_t*) where the path should be stored (the last \ won't be copied).
+ wchar_t **szPathW; //unicode version of string.
+ TCHAR **szPathT;
+ };
+} FOLDERSGETALLOCDATA;
+
+/*Folders/GetRelativePath/Alloc service
+ wParam - (WPARAM) (int) - Handle to registered path
+ lParam - (LPARAM) (FOLDERSALLOCDATA *) data
+ This service is the same as MS_FOLDERS_GET_PATH with the difference that this service
+ allocates the needed space for the buffer. It uses miranda's memory functions for that and you need
+ to use those to free the resulting buffer.
+ Should return 0 on success, or nonzero otherwise. Currently it only returns 0.
+*/
+#define MS_FOLDERS_GET_PATH_ALLOC "Folders/Get/Path/Alloc"
+
+
+/*Folders/On/Path/Changed
+ wParam - (WPARAM) 0
+ lParam - (LPARAM) 0
+ Triggered when the folders change, you should reget the paths you registered.
+*/
+#define ME_FOLDERS_PATH_CHANGED "Folders/On/Path/Changed"
+
+#ifndef FOLDERS_NO_HELPER_FUNCTIONS
+
+#ifndef M_UTILS_H__
+#error The helper functions require that m_utils.h be included in the project. Please include that file if you want to use the helper functions. If you don''t want to use the functions just define FOLDERS_NO_HELPER_FUNCTIONS.
+#endif
+//#include "../../../include/newpluginapi.h"
+
+__inline static HANDLE FoldersRegisterCustomPath(const char *section, const char *name, const char *defaultPath)
+{
+ FOLDERSDATA fd = {0};
+ if (!ServiceExists(MS_FOLDERS_REGISTER_PATH)) return 0;
+ fd.cbSize = sizeof(FOLDERSDATA);
+ strncpy(fd.szSection, section, FOLDERS_NAME_MAX_SIZE);
+ fd.szSection[FOLDERS_NAME_MAX_SIZE - 1] = '\0';
+ strncpy(fd.szName, name, FOLDERS_NAME_MAX_SIZE);
+ fd.szName[FOLDERS_NAME_MAX_SIZE - 1] = '\0';
+ fd.szFormat = defaultPath;
+ return (HANDLE) CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM) &fd);
+}
+
+__inline static HANDLE FoldersRegisterCustomPathW(const char *section, const char *name, const wchar_t *defaultPathW)
+{
+ FOLDERSDATA fd = {0};
+ if (!ServiceExists(MS_FOLDERS_REGISTER_PATH)) return 0;
+ fd.cbSize = sizeof(FOLDERSDATA);
+ strncpy(fd.szSection, section, FOLDERS_NAME_MAX_SIZE);
+ fd.szSection[FOLDERS_NAME_MAX_SIZE - 1] = '\0'; //make sure it's NULL terminated
+ strncpy(fd.szName, name, FOLDERS_NAME_MAX_SIZE);
+ fd.szName[FOLDERS_NAME_MAX_SIZE - 1] = '\0'; //make sure it's NULL terminated
+ fd.szFormatW = defaultPathW;
+ fd.flags = FF_UNICODE;
+ return (HANDLE) CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM) &fd);
+}
+
+__inline static INT_PTR FoldersGetCustomPath(HANDLE hFolderEntry, char *path, const int size, const char *notFound)
+{
+ FOLDERSGETDATA fgd = {0};
+ INT_PTR res;
+ fgd.cbSize = sizeof(FOLDERSGETDATA);
+ fgd.nMaxPathSize = size;
+ fgd.szPath = path;
+ res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
+ if (res)
+ {
+ char buffer[MAX_PATH];
+ CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM) notFound, (LPARAM) buffer);
+ mir_snprintf(path, size, "%s", buffer);
+ }
+
+ return res;
+}
+
+__inline static INT_PTR FoldersGetCustomPathW(HANDLE hFolderEntry, wchar_t *pathW, const int count, const wchar_t *notFoundW)
+{
+ FOLDERSGETDATA fgd = {0};
+ INT_PTR res;
+ fgd.cbSize = sizeof(FOLDERSGETDATA);
+ fgd.nMaxPathSize = count;
+ fgd.szPathW = pathW;
+ res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
+ if (res)
+ {
+ wcsncpy(pathW, notFoundW, count);
+ pathW[count - 1] = '\0';
+ }
+
+ return res;
+}
+
+__inline static INT_PTR FoldersGetCustomPathEx(HANDLE hFolderEntry, char *path, const int size, char *notFound, char *fileName)
+{
+ FOLDERSGETDATA fgd = {0};
+ INT_PTR res;
+ fgd.cbSize = sizeof(FOLDERSGETDATA);
+ fgd.nMaxPathSize = size;
+ fgd.szPath = path;
+ res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
+ if (res)
+ {
+ char buffer[MAX_PATH];
+ CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM) notFound, (LPARAM) buffer);
+ mir_snprintf(path, size, "%s", buffer);
+ }
+ if (strlen(path) > 0)
+ {
+ strcat(path, "\\");
+ }
+ else{
+ path[0] = '\0';
+ }
+
+ if (fileName)
+ {
+ strcat(path, fileName);
+ }
+
+ return res;
+}
+
+__inline static INT_PTR FoldersGetCustomPathExW(HANDLE hFolderEntry, wchar_t *pathW, const int count, wchar_t *notFoundW, wchar_t *fileNameW)
+{
+ FOLDERSGETDATA fgd = {0};
+ INT_PTR res;
+ fgd.cbSize = sizeof(FOLDERSGETDATA);
+ fgd.nMaxPathSize = count;
+ fgd.szPathW = pathW;
+ res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
+ if (res)
+ {
+ wcsncpy(pathW, notFoundW, count);
+ pathW[count - 1] = '\0';
+ }
+
+ if (wcslen(pathW) > 0)
+ {
+ wcscat(pathW, L"\\");
+ }
+ else{
+ pathW[0] = L'\0';
+ }
+
+ if (fileNameW)
+ {
+ wcscat(pathW, fileNameW);
+ }
+
+ return res;
+}
+
+# ifdef _UNICODE
+# define FoldersGetCustomPathT FoldersGetCustomPathW
+# define FoldersGetCustomPathExT FoldersGetCustomPathExW
+# define FoldersRegisterCustomPathT FoldersRegisterCustomPathW
+#else
+# define FoldersGetCustomPathT FoldersGetCustomPath
+# define FoldersGetCustomPathExT FoldersGetCustomPath
+# define FoldersRegisterCustomPathT FoldersRegisterCustomPath
+#endif
+
+#endif
+
+#endif //M_CUSTOM_FOLDERS_H \ No newline at end of file
diff --git a/splashscreen/src/m_splash.h b/splashscreen/src/m_splash.h
new file mode 100644
index 0000000..3652e6a
--- /dev/null
+++ b/splashscreen/src/m_splash.h
@@ -0,0 +1,6 @@
+// Shows splash image
+// wParam = (char *) image filename, either relative to Miranda dir or absolute
+// lParam = (int) time to display in milliseconds, 0 - infinite (hangs on screen until clicked)
+// returns: 1 if success and 0 if failed
+
+#define MS_SHOWSPLASH "SplashScreen/Show"
diff --git a/splashscreen/src/m_updater.h b/splashscreen/src/m_updater.h
new file mode 100644
index 0000000..488d372
--- /dev/null
+++ b/splashscreen/src/m_updater.h
@@ -0,0 +1,150 @@
+#ifndef _M_UPDATER_H
+#define _M_UPDATER_H
+
+// NOTES:
+// - For langpack updates, include a string of the following format in the langpack text file:
+// ";FLID: <file listing name> <version>"
+// version must be four numbers seperated by '.', in the range 0-255 inclusive
+// - Updater will disable plugins that are downloaded but were not active prior to the update (this is so that, if an archive contains e.g. ansi and
+// unicode versions, the correct plugin will be the only one active after the new version is installed)...so if you add a support plugin, you may need
+// to install an ini file to make the plugin activate when miranda restarts after the update
+// - Updater will replace all dlls that have the same internal shortName as a downloaded update dll (this is so that msn1.dll and msn2.dll, for example,
+// will both be updated) - so if you have a unicode and a non-unicode version of a plugin in your archive, you should make the internal names different (which will break automatic
+// updates from the file listing if there is only one file listing entry for both versions, unless you use the 'MS_UPDATE_REGISTER' service below)
+// - Updater will install all files in the root of the archive into the plugins folder, except for langpack files that contain the FLID string which go into the root folder (same
+// folder as miranda32.exe)...all folders in the archive will also be copied to miranda's root folder, and their contents transferred into the new folders. The only exception is a
+// special folder called 'root_files' - if there is a folder by that name in the archive, it's contents will also be copied into miranda's root folder - this is intended to be used
+// to install additional dlls etc that a plugin may require)
+
+// if you set Update.szUpdateURL to the following value when registering, as well as setting your beta site and version data,
+// Updater will ignore szVersionURL and pbVersionPrefix, and attempt to find the file listing URL's from the backend XML data.
+// for this to work, the plugin name in pluginInfo.shortName must match the file listing exactly (except for case)
+#define UPDATER_AUTOREGISTER "UpdaterAUTOREGISTER"
+// Updater will also use the backend xml data if you provide URL's that reference the miranda file listing for updates (so you can use that method
+// if e.g. your plugin shortName does not match the file listing) - it will grab the file listing id from the end of these URLs
+
+typedef struct Update_tag {
+ int cbSize;
+ char *szComponentName; // component name as it will appear in the UI (will be translated before displaying)
+
+ char *szVersionURL; // URL where the current version can be found (NULL to disable)
+ BYTE *pbVersionPrefix; // bytes occuring in VersionURL before the version, used to locate the version information within the URL data
+ // (note that this URL could point at a binary file - dunno why, but it could :)
+ int cpbVersionPrefix; // number of bytes pointed to by pbVersionPrefix
+ char *szUpdateURL; // URL where dll/zip is located
+ // set to UPDATER_AUTOREGISTER if you want Updater to find the file listing URLs (ensure plugin shortName matches file listing!)
+
+ char *szBetaVersionURL; // URL where the beta version can be found (NULL to disable betas)
+ BYTE *pbBetaVersionPrefix; // bytes occuring in VersionURL before the version, used to locate the version information within the URL data
+ int cpbBetaVersionPrefix; // number of bytes pointed to by pbVersionPrefix
+ char *szBetaUpdateURL; // URL where dll/zip is located
+
+ BYTE *pbVersion; // bytes of current version, used for comparison with those in VersionURL
+ int cpbVersion; // number of bytes pointed to by pbVersion
+
+ char *szBetaChangelogURL; // url for displaying changelog for beta versions
+} Update;
+
+// register a comonent with Updater
+//
+// wparam = 0
+// lparam = (LPARAM)&Update
+#define MS_UPDATE_REGISTER "Update/Register"
+
+// utility functions to create a version string from a DWORD or from pluginInfo
+// point buf at a buffer at least 16 chars wide - but note the version string returned may be shorter
+//
+__inline static char *CreateVersionString(DWORD version, char *buf) {
+ mir_snprintf(buf, 16, "%d.%d.%d.%d", (version >> 24) & 0xFF, (version >> 16) & 0xFF, (version >> 8) & 0xFF, version & 0xFF);
+ return buf;
+}
+
+__inline static char *CreateVersionStringPlugin(PLUGININFO *pluginInfo, char *buf) {
+ return CreateVersionString(pluginInfo->version, buf);
+}
+
+__inline static char *CreateVersionStringPluginEx(PLUGININFOEX *pluginInfo, char *buf) {
+ return CreateVersionString(pluginInfo->version, buf);
+}
+
+
+// register the 'easy' way - use this method if you have no beta URL and the plugin is on the miranda file listing
+// NOTE: the plugin version string on the file listing must be the string version of the version in pluginInfo (i.e. 0.0.0.1,
+// four numbers between 0 and 255 inclusivem, so no letters, brackets, etc.)
+//
+// wParam = (int)fileID - this is the file ID from the file listing (i.e. the number at the end of the download link)
+// lParam = (PLUGININFO*)&pluginInfo
+#define MS_UPDATE_REGISTERFL "Update/RegisterFL"
+
+// this function can be used to 'unregister' components - useful for plugins that register non-plugin/langpack components and
+// may need to change those components on the fly
+// lParam = (char *)szComponentName
+#define MS_UPDATE_UNREGISTER "Update/Unregister"
+
+// this event is fired when the startup process is complete, but NOT if a restart is imminent
+// it is designed for status managment plugins to use as a trigger for beggining their own startup process
+// wParam = lParam = 0 (unused)
+// (added in version 0.1.6.0)
+#define ME_UPDATE_STARTUPDONE "Update/StartupDone"
+
+// this service can be used to enable/disable Updater's global status control
+// it can be called from the StartupDone event handler
+// wParam = (BOOL)enable
+// lParam = 0
+// (added in version 0.1.6.0)
+#define MS_UPDATE_ENABLESTATUSCONTROL "Update/EnableStatusControl"
+
+// An description of usage of the above service and event:
+// Say you are a status control plugin that normally sets protocol or global statuses in your ModulesLoaded event handler.
+// In order to make yourself 'Updater compatible', you would move the status control code from ModulesLoaded to another function,
+// say DoStartup. Then, in ModulesLoaded you would check for the existence of the MS_UPDATE_ENABLESTATUSCONTROL service.
+// If it does not exist, call DoStartup. If it does exist, hook the ME_UPDATE_STARTUPDONE event and call DoStartup from there. You may
+// also wish to call MS_UPDATE_ENABLESTATUSCONTROL with wParam == FALSE at this time, to disable Updater's own status control feature.
+
+// this service can be used to determine whether updates are possible for a component with the given name
+// wParam = 0
+// lParam = (char *)szComponentName
+// returns TRUE if updates are supported, FALSE otherwise
+#define MS_UPDATE_ISUPDATESUPPORTED "Update/IsUpdateSupported"
+
+#endif
+
+
+/////////////// Usage Example ///////////////
+
+#ifdef EXAMPLE_CODE
+
+// you need to #include "m_updater.h" and HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded) in your Load function...
+
+int OnModulesLoaded(WPARAM wParam, LPARAM lParam) {
+
+ Update update = {0}; // for c you'd use memset or ZeroMemory...
+ char szVersion[16];
+
+ update.cbSize = sizeof(Update);
+
+ update.szComponentName = pluginInfo.shortName;
+ update.pbVersion = (BYTE *)CreateVersionString(&pluginInfo, szVersion);
+ update.cpbVersion = strlen((char *)update.pbVersion);
+
+ // these are the three lines that matter - the archive, the page containing the version string, and the text (or data)
+ // before the version that we use to locate it on the page
+ // (note that if the update URL and the version URL point to standard file listing entries, the backend xml
+ // data will be used to check for updates rather than the actual web page - this is not true for beta urls)
+ update.szUpdateURL = "http://scottellis.com.au:81/test/updater.zip";
+ update.szVersionURL = "http://scottellis.com.au:81/test/updater_test.html";
+ update.pbVersionPrefix = (BYTE *)"Updater version ";
+
+ update.cpbVersionPrefix = strlen((char *)update.pbVersionPrefix);
+
+ // do the same for the beta versions of the above struct members if you wish to allow beta updates from another URL
+
+ CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update);
+
+ // Alternatively, to register a plugin with e.g. file ID 2254 on the file listing...
+ // CallService(MS_UPDATE_REGISTERFL, (WPARAM)2254, (LPARAM)&pluginInfo);
+
+ return 0;
+}
+
+#endif
diff --git a/splashscreen/src/main.cpp b/splashscreen/src/main.cpp
new file mode 100644
index 0000000..90f83b4
--- /dev/null
+++ b/splashscreen/src/main.cpp
@@ -0,0 +1,534 @@
+/*
+ Splash Screen Plugin for Miranda-IM (www.miranda-im.org)
+ (c) 2004-2007 nullbie, (c) 2005-2007 Thief
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ File name : $URL: http://svn.miranda.im/mainrepo/splashscreen/trunk/src/main.cpp $
+ Revision : $Rev: 1586 $
+ Last change on : $Date: 2010-04-09 12:34:01 +0300 (Пт, 09 апр 2010) $
+ Last change by : $Author: Thief $
+
+*/
+
+#include "headers.h"
+
+HINSTANCE hInst = 0;
+PLUGINLINK *pluginLink;
+
+static HMODULE hUserDll = NULL;
+static HMODULE hAdvaimg = NULL;
+
+pfnConvertPng2dib png2dibConvertor = NULL;
+
+bool bstartup = true; // startup?
+bool bserviceinvoked = false;
+bool bmodulesloaded = false; // modules are loaded
+bool png2dibavail = true; // can we use png2dib service?
+
+char *mirandaVerString;
+char szPrefix[128];
+PVOID pVerInfo;
+
+// path to miranda's dir, config file path, splash path, sound path
+char szMirDir[MAX_PATH], szIniFile[MAX_PATH], szDllName[MAX_PATH], szSplashFile[MAX_PATH], szSoundFile [MAX_PATH], szhAdvaimgPath [MAX_PATH];
+#ifdef _DEBUG
+char szLogFile[MAX_PATH];
+#endif
+static char inBuf[80];
+
+SPLASHOPTS options;
+
+// Options handle. Declarated in options.cpp
+extern BOOL CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+extern int OptInit(WPARAM wParam, LPARAM lParam);
+extern bool ShowSplash(bool bpreview);
+extern void ReadIniConfig();
+
+HANDLE hShowSplashService, hTestService;
+// Service functions declarated in service.cpp
+extern int ShowSplashService(WPARAM wparam,LPARAM lparam);
+#ifdef _DEBUG
+extern int TestService(WPARAM wParam,LPARAM lParam);
+#endif
+
+extern BOOL (WINAPI *MyUpdateLayeredWindow)
+ (HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc,
+ COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags);
+extern HWND hwndSplash;
+
+PLUGININFOEX pluginInfo={
+ sizeof(PLUGININFOEX),
+ #ifndef _DEBUG
+ "Splash Screen",
+ #else
+ "Splash Screen (Debug)",
+ #endif
+ __VERSION_DWORD,
+ "Shows a splash at Miranda startup",
+ "nullbie, Thief",
+ "thief@miranda.im",
+ "2004-2007 Victor Pavlychko, 2005-2010 Alexander Turyak ["BuildDate"]",
+ "http://addons.miranda-im.org/details.php?id=2624",
+ 0, //not transient
+ 0, //doesn't replace anything built-in
+ {0xc64cc8e0, 0xcf03, 0x474a, {0x8b, 0x11, 0x8b, 0xd4, 0x56, 0x5c, 0xcf, 0x04}} /* C64CC8E0-CF03-474A-8B11-8BD4565CC */
+};
+
+PLUGININFO oldpluginInfo={
+ sizeof(PLUGININFO),
+ pluginInfo.shortName,
+ pluginInfo.version,
+ pluginInfo.description,
+ pluginInfo.author,
+ pluginInfo.authorEmail,
+ pluginInfo.copyright,
+ pluginInfo.homepage,
+ pluginInfo.flags,
+ pluginInfo.replacesDefaultModule
+};
+
+/* 91CB1E8D-C33C-43C0-BDD8-6725B070B3E0 */
+#define MIID_SPLASHSCREEN {0x91cb1e8d, 0xc33c, 0x43c0, {0xbd, 0xd8, 0x67, 0x25, 0xb0, 0x70, 0xb3, 0xe0}}
+
+extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
+{
+ static const MUUID interfaces[] = {MIID_SPLASHSCREEN, MIID_LAST};
+ return interfaces;
+}
+
+HANDLE hSplashThread, hModulesLoaded, hPlugDisableHook, hOptInit, hSystemOKToExit;
+LRESULT CALLBACK SplashWindowProc(HWND, UINT, WPARAM, LPARAM);
+int ModulesLoaded(WPARAM wParam,LPARAM lParam);
+int PlugDisableHook(WPARAM wParam,LPARAM lParam);
+int onSystemOKToExit(WPARAM wParam,LPARAM lParam);
+
+extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ hInst = hinstDLL;
+ return TRUE;
+}
+
+void SplashMain()
+{
+if (bstartup)
+{
+ DWORD unused;
+ DWORD verInfoSize;
+ UINT blockSize;
+
+ // Retrive path to exe of current running Miranda is located
+ GetModuleFileName(GetModuleHandle(NULL), szMirDir, sizeof(szMirDir));
+
+ verInfoSize = GetFileVersionInfoSizeA(szMirDir,&unused);
+ pVerInfo = /*mir_*/malloc(verInfoSize);
+ GetFileVersionInfoA(szMirDir,0,verInfoSize,pVerInfo);
+ VerQueryValueA(pVerInfo,"\\StringFileInfo\\000004b0\\ProductVersion",(PVOID*)&mirandaVerString,&blockSize);
+
+ // Remove 'miranda32.exe' from string
+ char *pos;
+ pos = strrchr(szMirDir, '\\');
+ if(pos != NULL) *pos = 0;
+ lstrcat(szMirDir,"\\");
+
+ // Get the name string of plugin's dll name whatever it named
+ static char* sztmpstr;
+ GetModuleFileName(hInst, szDllName, sizeof(szDllName));
+ sztmpstr = _strrev(szDllName);
+ pos = strchr(sztmpstr, '\\');
+ if(pos != NULL) *pos = 0;
+ strcpy(szDllName, _strrev(sztmpstr));
+
+ static char szPath[MAX_PATH];
+
+ lstrcat(szPath,szMirDir);
+ lstrcat(szPath,"plugins\\splash.ini");
+ lstrcat(szhAdvaimgPath,szMirDir);
+ lstrcat(szhAdvaimgPath,"plugins\\advaimg.dll");
+
+ #ifdef _DEBUG
+ lstrcat(szLogFile,szMirDir);
+ lstrcat(szLogFile,PlugName);
+ lstrcat(szLogFile,".log");
+ #endif
+
+ #ifdef _DEBUG
+ initLog();
+ logTimeStamp();
+ #endif
+
+ #ifdef _DEBUG
+ logMessage("Miranda version", mirandaVerString);
+ #endif
+
+ static char szMirandaBootIni[MAX_PATH];
+ lstrcat(szMirandaBootIni,szMirDir);
+ lstrcat(szMirandaBootIni,"mirandaboot.ini");
+ GetPrivateProfileString("Splash","Ini","",inBuf,sizeof(inBuf),szMirandaBootIni);
+ if (strlen(inBuf))
+ {
+ char szExpandedIniPath[MAX_PATH];
+ ExpandEnvironmentStringsA(inBuf, szExpandedIniPath,sizeof(szExpandedIniPath));
+ lstrcat(szIniFile,szExpandedIniPath);
+ }
+ else
+ {
+ FILE *fp;
+ fp = fopen(szPath, "r");
+ if (!fp)
+ {
+ #ifdef _DEBUG
+ logMessage("error! couldn't open", szPath);
+ #endif
+
+ lstrcat(szIniFile,szMirDir);
+ lstrcat(szIniFile,"mirandaboot.ini");
+ }
+ else
+ {
+ lstrcat(szIniFile,szPath);
+ fclose(fp);
+ }
+ }
+
+ ReadIniConfig();
+
+ #ifdef _DEBUG
+ logMessage("Dll Name", szDllName);
+ logMessage("Ini path",szIniFile);
+ logMessage("Advaimg path", szhAdvaimgPath);
+ #endif
+}
+
+if (bstartup & (options.active == 1)) {
+
+ if (options.runonce)
+ {
+ WritePrivateProfileString("Splash","Active","0",szIniFile);
+ WritePrivateProfileString("Splash","DisableAfterStartup","0",szIniFile);
+ }
+
+ if (hUserDll == NULL)
+ {
+ hUserDll = LoadLibrary("user32.dll");
+ if (hUserDll)
+ {
+ MyUpdateLayeredWindow = (BOOL (WINAPI *)(HWND, HDC, POINT *, SIZE *, HDC, POINT *, COLORREF, BLENDFUNCTION *, DWORD))GetProcAddress(hUserDll, "UpdateLayeredWindow");
+ }
+ }
+
+ if (hAdvaimg == NULL)
+ {
+ hAdvaimg = LoadLibrary(szhAdvaimgPath);
+ if (hAdvaimg == NULL)
+ {
+ png2dibavail = false;
+ bstartup = false;
+ }
+ if (hAdvaimg)
+ {
+ png2dibConvertor = (pfnConvertPng2dib) GetProcAddress(hAdvaimg, "mempng2dib");
+ if (png2dibConvertor == NULL)
+ {
+ FreeLibrary(hAdvaimg); hAdvaimg = NULL;
+ MessageBoxA(NULL,
+ "Your advaimg.dll is either obsolete or damaged. Get latest from Miranda alpha builds.",
+ "Error",
+ MB_OK | MB_ICONSTOP);
+ }
+ #ifdef _DEBUG
+ if (png2dibConvertor) logMessage("Loading advaimg","done");
+ #endif
+ }
+ }
+
+ //for 9x "alfa" testing
+ //MyUpdateLayeredWindow = 0;
+
+ GetPrivateProfileString("Splash","VersionPrefix","",inBuf,sizeof(inBuf),szIniFile);
+ strcpy(szPrefix,inBuf);
+
+ GetPrivateProfileString("Splash","Path","splash\\splash.png",inBuf,sizeof(inBuf),szIniFile);
+
+ char szExpandedSplashFile[MAX_PATH];
+ ExpandEnvironmentStringsA(inBuf, szExpandedSplashFile,sizeof(szExpandedSplashFile));
+ lstrcpy(inBuf, szExpandedSplashFile);
+
+ char *pos3 = 0;
+ pos3 = strrchr(inBuf, ':');
+ if (pos3 == NULL)
+ {
+ lstrcpy(szSplashFile, szMirDir);
+ }
+
+ lstrcat(szSplashFile, inBuf);
+
+ GetPrivateProfileString("Splash","Sound","sounds\\startup.wav",inBuf,sizeof(inBuf),szIniFile);
+
+ char szExpandedSoundFile[MAX_PATH];
+ ExpandEnvironmentStringsA(inBuf, szExpandedSoundFile,sizeof(szExpandedSoundFile));
+ lstrcpy(inBuf, szExpandedSoundFile);
+
+ char *pos2;
+ pos2 = strchr(inBuf, ':');
+ if (pos2 == NULL)
+ {
+ lstrcat(szSoundFile, szMirDir);
+ }
+
+ lstrcat(szSoundFile, inBuf);
+
+ #ifdef _DEBUG
+ logMessage("SoundFilePath",szSoundFile);
+ #endif
+
+ char szOldPath[MAX_PATH] = {0};
+
+ if(options.random) // randomly select a splash file
+ {
+ int filescount = 0;
+ char szSplashDir[MAX_PATH] = {0}, szSearch[MAX_PATH] = {0};
+ char* p = 0;
+ char files [255][50]; //TODO: make memory allocation dynamic
+
+ lstrcpy(szSplashDir, szSplashFile);
+ lstrcpy(szOldPath, szSplashFile);
+ // find the last \ and null it out, this leaves no trailing slash
+ p = strrchr(szSplashDir, '\\');
+ if (p) *p = 0;
+ // create the search filter
+ mir_snprintf(szSearch,sizeof(szSearch),"%s\\*.*", szSplashDir);
+ // FFFN will return filenames
+ HANDLE hFind = INVALID_HANDLE_VALUE;
+ WIN32_FIND_DATAA ffd;
+ hFind = FindFirstFileA(szSearch, &ffd);
+ if ( hFind != INVALID_HANDLE_VALUE )
+ {
+ do
+ {
+ if (!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
+ {
+ #ifdef _DEBUG
+ logMessage("Found file",ffd.cFileName);
+ #endif
+ //files = new char[strlen(ffd.cFileName)];
+ //files[filescount] = new char[strlen(ffd.cFileName)];
+ char ext[5];
+ memcpy(ext,ffd.cFileName+(strlen(ffd.cFileName)-4),5);
+
+ #ifdef _DEBUG
+ logMessage("Extention",ext);
+ #endif
+
+ if (lstrcmpi(ext,".png") & lstrcmpi(ext,".bmp"))
+ continue;
+
+ #ifdef _DEBUG
+ logMessage("File has valid ext",ext);
+ #endif
+ strcpy(files[filescount++],ffd.cFileName);
+ } //if
+ } while (FindNextFileA(hFind, &ffd));
+
+ srand((unsigned) time(NULL));
+ int r = 0;
+ if (filescount) r = (rand() % filescount) + 1;
+
+ ZeroMemory(&szSplashFile,sizeof(szSplashFile));
+ lstrcpy(szSplashFile, szSplashDir);
+ lstrcat(szSplashFile,"\\");
+ lstrcat(szSplashFile,files[r-1]);
+
+ #ifdef _DEBUG
+ logMessage("final file",szSplashFile);
+ #endif
+ FindClose(hFind);
+ } //if
+ }
+
+ // Call splash display routine
+ ShowSplash(false);
+
+ if (options.random)
+ {
+ ZeroMemory(&szSplashFile,sizeof(szSplashFile));
+ lstrcpy(szSplashFile, szOldPath);
+ }
+
+ }
+ bstartup = false;
+}
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ SplashMain();
+ return &pluginInfo;
+}
+
+extern "C" __declspec(dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion)
+{
+ SplashMain();
+ return &oldpluginInfo;
+}
+
+extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
+{
+ pluginLink = link;
+
+ hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ hSystemOKToExit = HookEvent(ME_SYSTEM_OKTOEXIT,onSystemOKToExit);
+
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ free(pVerInfo);
+
+ if (hSplashThread) CloseHandle(hSplashThread);
+
+ UnregisterClass(SPLASH_CLASS, hInst);
+
+ // Freeing loaded libraries
+ if (hUserDll) FreeLibrary(hUserDll);
+ if (hAdvaimg) FreeLibrary(hAdvaimg);
+
+ #ifdef _DEBUG
+ logMessage("Unload","Job done");
+ #endif
+
+ return 0;
+}
+
+int onSystemOKToExit(WPARAM wParam,LPARAM lParam)
+{
+ // Hooked events need to be unhooked
+ UnhookEvent(hModulesLoaded);
+ UnhookEvent(hSystemOKToExit);
+ UnhookEvent(hPlugDisableHook);
+ UnhookEvent(hOptInit);
+
+ DestroyServiceFunction(hShowSplashService);
+ #ifdef _DEBUG
+ DestroyServiceFunction(hTestService);
+ #endif
+
+ return 0;
+}
+
+int ModulesLoaded(WPARAM wParam, LPARAM lParam)
+{
+ bmodulesloaded = true; // all modules are loaded now, let other parts know about this fact
+
+ if (hwndSplash)
+ {
+ if (PostMessage(hwndSplash, WM_LOADED, 0, 0))
+ {
+ #ifdef _DEBUG
+ logMessage("Posted WM_LOADED message","done");
+ #endif
+ }
+ }
+
+ // Options initialize hook
+ hOptInit = HookEvent(ME_OPT_INITIALISE, OptInit);
+
+ hPlugDisableHook = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, PlugDisableHook);
+
+ // Service to call splash
+ hShowSplashService = CreateServiceFunction(MS_SHOWSPLASH, ShowSplashService);
+
+ #ifdef _DEBUG
+ hTestService = CreateServiceFunction("Splash/Test",TestService);
+ CLISTMENUITEM mi;
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.flags = 0;
+ mi.hIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+ mi.hotKey = 0;
+ mi.position = -0x7FFFFFFF;
+ mi.pszName = "Call Splash Service";
+ mi.pszService = "Splash/Test";
+
+ CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+ #endif
+
+ if (ServiceExists(MS_UPDATE_REGISTER))
+ {
+ // register with updater
+ Update update = {0};
+ char szVersion[16];
+
+ update.cbSize = sizeof(Update);
+
+ update.szComponentName = pluginInfo.shortName;
+ update.pbVersion = (BYTE *)CreateVersionString(pluginInfo.version, szVersion);
+ update.cpbVersion = strlen((char *)update.pbVersion);
+
+ update.szUpdateURL = UPDATER_AUTOREGISTER;
+
+ // these are the three lines that matter - the archive, the page containing the version string, and the text (or data)
+ // before the version that we use to locate it on the page
+ // (note that if the update URL and the version URL point to standard file listing entries, the backend xml
+ // data will be used to check for updates rather than the actual web page - this is not true for beta urls)
+ update.szBetaUpdateURL = "http://thief.miranda.im/advsplashscreen.zip";
+ update.szBetaVersionURL = "http://thief.miranda.im/updater/splash_version.txt";
+ update.szBetaChangelogURL = "http://thief.miranda.im";
+ update.pbBetaVersionPrefix = (BYTE *)"Splash Screen ";
+
+ update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix);
+
+ CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update);
+ }
+
+ #ifdef _DEBUG
+ logMessage("Loading modules","done");
+ #endif
+
+ return 0;
+}
+
+int PlugDisableHook(WPARAM wParam, LPARAM lParam)
+{
+ char buf [128];
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
+ if(options.inheritGS)
+ if (!lstrcmp(cws->szModule,"Skin") & !lstrcmp(cws->szSetting,"UseSound"))
+ {
+ sprintf(buf,"%d",cws->value.bVal);
+ WritePrivateProfileString("Splash","PlaySound",buf,szIniFile);
+ #ifdef _DEBUG
+ cws->value.bVal ? _DebugPopup(NULL, "Sounds enabled.", "") : _DebugPopup(NULL, "Sounds disabled.", "");
+ logMessage("Module",cws->szModule);
+ logMessage("Setting",cws->szSetting);
+ logMessage("Value",buf);
+ #endif
+ }
+ if (!lstrcmp(cws->szModule,"PluginDisable") & (!lstrcmp(cws->szSetting,szDllName)))
+ {
+ sprintf(buf,"%d",!cws->value.bVal);
+ WritePrivateProfileString("Splash","Active",buf,szIniFile);
+
+ #ifdef _DEBUG
+ cws->value.bVal ? _DebugPopup(NULL, "Disabled.", "") : _DebugPopup(NULL, "Enabled.", "");
+ logMessage("PlugDisableHook","Triggered");
+ logMessage("Module",cws->szModule);
+ logMessage("Setting",cws->szSetting);
+ logMessage("Value",buf);
+ #endif
+ }
+
+ return 0;
+}
diff --git a/splashscreen/src/msvc6.rc b/splashscreen/src/msvc6.rc
new file mode 100644
index 0000000..e79d7e3
--- /dev/null
+++ b/splashscreen/src/msvc6.rc
@@ -0,0 +1,2 @@
+#include "splash.rc"
+#include "version.rc"
diff --git a/splashscreen/src/options.cpp b/splashscreen/src/options.cpp
new file mode 100644
index 0000000..16e0d66
--- /dev/null
+++ b/splashscreen/src/options.cpp
@@ -0,0 +1,438 @@
+/*
+Splash Screen Plugin for Miranda-IM (www.miranda-im.org)
+(c) 2004-2007 nullbie, (c) 2005-2007 Thief
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+File name : $URL: http://svn.miranda.im/mainrepo/splashscreen/trunk/src/options.cpp $
+Revision : $Rev: 951 $
+Last change on : $Date: 2007-10-16 16:46:53 +0200 (Вт, 16 окт 2007) $
+Last change by : $Author: Thief $
+
+DESCRIPTION: Options dialog handling code
+
+*/
+
+#include "headers.h"
+
+extern HINSTANCE hInst;
+extern bool ShowSplash(bool preview);
+extern bool png2dibavail;
+extern char szMirDir[MAX_PATH], szIniFile[MAX_PATH], szSplashFile[MAX_PATH], szSoundFile[MAX_PATH];
+extern char szPrefix[128];
+static char szPath2Spash [MAX_PATH], szSoundFilePath[MAX_PATH];
+
+// Reads values from ini file
+void ReadIniConfig()
+{
+ static char inBuf[80];
+
+ GetPrivateProfileString("Splash","Active","1",inBuf,sizeof(inBuf),szIniFile);
+ options.active = atoi(inBuf);
+
+ GetPrivateProfileString("Splash","PlaySound","0",inBuf,sizeof(inBuf),szIniFile);
+ options.playsnd = atoi(inBuf);
+
+ GetPrivateProfileString("Splash","FadeIn","1",inBuf,sizeof(inBuf),szIniFile);
+ options.fadein = atoi(inBuf);
+
+ GetPrivateProfileString("Splash","FadeOut","1",inBuf,sizeof(inBuf),szIniFile);
+ options.fadeout = atoi(inBuf);
+
+ GetPrivateProfileString("Splash","TimeToShow","0",inBuf,sizeof(inBuf),szIniFile);
+ options.showtime = atoi(inBuf);
+
+ GetPrivateProfileString("Splash","FadeinSpeed","1",inBuf,sizeof(inBuf),szIniFile);
+ options.fisteps = atoi(inBuf);
+
+ GetPrivateProfileString("Splash","FadeoutSpeed","1",inBuf,sizeof(inBuf),szIniFile);
+ options.fosteps = atoi(inBuf);
+
+ GetPrivateProfileString("Splash","InheritGlobalSound","1",inBuf,sizeof(inBuf),szIniFile);
+ options.inheritGS = atoi(inBuf);
+
+ /*
+ GetPrivateProfileString("Splash","LoopSound","0",inBuf,sizeof(inBuf),szIniFile);
+ options.loopsnd = atoi(inBuf);
+ */
+
+ GetPrivateProfileString("Splash","ShowVersion","0",inBuf,sizeof(inBuf),szIniFile);
+ options.showversion = atoi(inBuf);
+
+ GetPrivateProfileString("Splash","Random","0",inBuf,sizeof(inBuf),szIniFile);
+ options.random = atoi(inBuf);
+
+ GetPrivateProfileString("Splash","DisableAfterStartup","0",inBuf,sizeof(inBuf),szIniFile);
+ options.runonce = atoi(inBuf);
+}
+
+BOOL CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ if (!png2dibavail)
+ {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PNG2DIBWARN), SW_SHOW);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ACTIVE), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_RANDOM), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SPLASHPATH), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSESPLASH), false);
+ }
+ ReadIniConfig();
+ char inBuf[80];
+ GetPrivateProfileString("Splash","Path","splash\\splash.png",inBuf,sizeof(inBuf),szIniFile);
+ SetWindowText(GetDlgItem(hwndDlg, IDC_SPLASHPATH),inBuf);
+ GetPrivateProfileString("Splash","Sound","sounds\\startup.wav",inBuf,sizeof(inBuf),szIniFile);
+ SetWindowText(GetDlgItem(hwndDlg, IDC_SNDPATH),inBuf);
+ GetPrivateProfileString("Splash","VersionPrefix","",inBuf,sizeof(inBuf),szIniFile);
+ SetWindowText(GetDlgItem(hwndDlg, IDC_VERSIONPREFIX),inBuf);
+ if (options.active) CheckDlgButton(hwndDlg, IDC_ACTIVE, BST_CHECKED);
+ if (options.playsnd && !options.inheritGS) CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_INDETERMINATE);
+ else if (options.playsnd) CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_CHECKED);
+ //if (options.loopsnd) CheckDlgButton(hwndDlg, IDC_LOOPSOUND, BST_CHECKED);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOOPSOUND), false);
+ if (options.fadein) CheckDlgButton(hwndDlg, IDC_FADEIN, BST_CHECKED);
+ if (options.fadeout) CheckDlgButton(hwndDlg, IDC_FADEOUT, BST_CHECKED);
+ if (options.random) CheckDlgButton(hwndDlg, IDC_RANDOM, BST_CHECKED);
+ if (options.showversion) CheckDlgButton(hwndDlg, IDC_SHOWVERSION, BST_CHECKED);
+
+ GetPrivateProfileString("Splash","TimeToShow","2000",inBuf,sizeof(inBuf),szIniFile);
+ SetWindowText(GetDlgItem(hwndDlg, IDC_SHOWTIME),inBuf);
+ GetPrivateProfileString("Splash","FadeinSpeed","5",inBuf,sizeof(inBuf),szIniFile);
+ SetWindowText(GetDlgItem(hwndDlg, IDC_FISTEP),inBuf);
+ GetPrivateProfileString("Splash","FadeoutSpeed","5",inBuf,sizeof(inBuf),szIniFile);
+ SetWindowText(GetDlgItem(hwndDlg, IDC_FOSTEP),inBuf);
+
+ SendDlgItemMessage(hwndDlg, IDC_SHOWTIME, EM_LIMITTEXT, 5, 0);
+ /*
+ SendDlgItemMessage(hwndDlg, IDC_ST_SPIN, UDM_SETRANGE32, 0, 20000);
+ SendDlgItemMessage(hwndDlg, IDC_FI_SPIN, UDM_SETRANGE32, 1, 7);
+ SendDlgItemMessage(hwndDlg, IDC_FO_SPIN, UDM_SETRANGE32, 1, 7);
+ */
+
+ return TRUE;
+ }
+
+ case WM_COMMAND:
+ {
+ switch(LOWORD(wParam))
+ {
+ case IDC_PREVIEW:
+ {
+ ShowSplash(true);
+ break;
+ }
+
+ case IDC_ACTIVE:
+ case IDC_PLAYSND:
+ case IDC_LOOPSOUND:
+ case IDC_FADEIN:
+ case IDC_FADEOUT:
+ case IDC_SHOWTIME:
+ case IDC_RANDOM:
+ case IDC_SHOWVERSION:
+ case IDC_FISTEP:
+ case IDC_FOSTEP:
+ {
+ if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN))
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), true);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), true);
+ }
+ else
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), false);
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT))
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), true);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), true);
+ }
+ else
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false);
+ }
+
+ if ((HWND)lParam != GetFocus())
+ return 0;
+ else {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+ break;
+ }
+
+ case IDC_CHOOSESPLASH:
+ {
+ static char szTempPath[MAX_PATH], initDir[MAX_PATH];
+ char *pos;
+
+ lstrcpy(initDir,szSplashFile);
+ pos = strrchr(initDir, '\\');
+ if(pos != NULL) *pos = 0;
+
+ OPENFILENAMEA ofn = {0};
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.lpstrFilter = "PNG and BMP files\0*.png;*.bmp\0\0";
+ ofn.hwndOwner = 0;
+ ofn.lpstrFile = szTempPath;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.Flags = OFN_HIDEREADONLY;
+ ofn.lpstrInitialDir = initDir;
+ *szTempPath = '\0';
+ ofn.lpstrDefExt = "";
+
+ if (GetOpenFileNameA(&ofn))
+ {
+ lstrcpy(szSplashFile,szTempPath);
+
+ #ifdef _DEBUG
+ logMessage("Set path", szSplashFile);
+ #endif
+
+ // Make path relative
+ int result = CallService(MS_UTILS_PATHTORELATIVE, (WPARAM)szTempPath, (LPARAM)szPath2Spash);
+
+ if(result && lstrlenA(szPath2Spash) > 0)
+ {
+ if (options.random)
+ {
+ char *pos;
+ pos = strrchr(szPath2Spash, '\\');
+ if (pos != NULL)
+ {
+ *pos = 0;
+ lstrcat(szPath2Spash,"\\");
+ }
+ }
+
+ SetWindowText(GetDlgItem(hwndDlg, IDC_SPLASHPATH),szPath2Spash);
+ }
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+
+ break;
+ }
+
+ case IDC_CHOOSESND:
+ {
+ static char szTempPath[MAX_PATH], initDir[MAX_PATH];
+ char *pos;
+
+ lstrcpy(initDir,szSoundFile);
+ pos = strrchr(initDir, '\\');
+ if(pos != NULL) *pos = 0;
+
+ OPENFILENAMEA ofn = {0};
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.lpstrFilter = "Sound files\0*.wav\0\0";
+ ofn.hwndOwner = 0;
+ ofn.lpstrFile = szTempPath;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.Flags = OFN_HIDEREADONLY;
+ ofn.lpstrInitialDir = initDir;
+ *szTempPath = '\0';
+ ofn.lpstrDefExt = "";
+
+ if (GetOpenFileNameA(&ofn))
+ {
+ lstrcpy(szSoundFile,szTempPath);
+
+#ifdef _DEBUG
+ logMessage("Set sound path", szSoundFile);
+#endif
+
+ // Make path relative
+ int result = CallService(MS_UTILS_PATHTORELATIVE, (WPARAM)szTempPath, (LPARAM)szSoundFilePath);
+
+ if(result && lstrlenA(szSoundFile) > 0)
+ {
+ SetWindowText(GetDlgItem(hwndDlg, IDC_SNDPATH),szSoundFilePath);
+ }
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+
+ break;
+ }
+ }
+
+ default:
+ {
+ if (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus())
+ return 0;
+ else
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ break;
+ }
+
+ case WM_NOTIFY:
+ {
+ if (((LPNMHDR)lParam)->idFrom == 0)
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ static char tmp[MAX_PATH];
+
+ GetWindowText(GetDlgItem(hwndDlg, IDC_SPLASHPATH),tmp,MAX_PATH);
+ WritePrivateProfileString("Splash","Path",tmp,szIniFile);
+
+ GetWindowText(GetDlgItem(hwndDlg, IDC_SNDPATH),tmp,MAX_PATH);
+ WritePrivateProfileString("Splash","Sound",tmp,szIniFile);
+
+ GetWindowText(GetDlgItem(hwndDlg, IDC_VERSIONPREFIX),tmp,MAX_PATH);
+ static char tmpstr[128] = {0};
+ strcat(tmpstr,"\"");
+ strcat(tmpstr,tmp);
+ strcat(tmpstr,"\"");
+ WritePrivateProfileString("Splash","VersionPrefix",tmpstr,szIniFile);
+ ZeroMemory(&tmpstr,sizeof(tmpstr));
+ strcpy(szPrefix,tmp);
+
+ GetWindowText(GetDlgItem(hwndDlg, IDC_SHOWTIME),tmp,MAX_PATH);
+ WritePrivateProfileString("Splash","TimeToShow",tmp,szIniFile);
+
+ GetWindowText(GetDlgItem(hwndDlg, IDC_FISTEP),tmp,MAX_PATH);
+ WritePrivateProfileString("Splash","FadeinSpeed",tmp,szIniFile);
+ options.fisteps = atoi(tmp);
+
+ GetWindowText(GetDlgItem(hwndDlg, IDC_FOSTEP),tmp,MAX_PATH);
+ WritePrivateProfileString("Splash","FadeoutSpeed",tmp,szIniFile);
+ options.fosteps = atoi(tmp);
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_ACTIVE))
+ {
+ WritePrivateProfileString("Splash","Active","1",szIniFile);
+ options.active = 1;
+ }
+ else
+ {
+ WritePrivateProfileString("Splash","Active","0",szIniFile);
+ options.active = 0;
+ }
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND))
+ {
+ WritePrivateProfileString("Splash","PlaySound","1",szIniFile);
+ WritePrivateProfileString("Splash","InheritGlobalSound","1",szIniFile);
+ options.playsnd = 1;
+ options.inheritGS = 1;
+ }
+ else
+ {
+ WritePrivateProfileString("Splash","PlaySound","0",szIniFile);
+ options.playsnd = 0;
+ WritePrivateProfileString("Splash","InheritGlobalSound","0",szIniFile);
+ options.inheritGS = 0;
+ }
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND) == BST_INDETERMINATE)
+ {
+ WritePrivateProfileString("Splash","PlaySound","1",szIniFile);
+ options.playsnd = 1;
+ WritePrivateProfileString("Splash","InheritGlobalSound","0",szIniFile);
+ options.inheritGS = 0;
+ }
+
+ /*
+ if (IsDlgButtonChecked(hwndDlg, IDC_LOOPSOUND))
+ {
+ WritePrivateProfileString("Splash","LoopSound","1",szIniFile);
+ options.loopsnd = 1;
+ }
+ else
+ {
+ WritePrivateProfileString("Splash","LoopSound","0",szIniFile);
+ options.loopsnd = 0;
+ }
+ */
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN))
+ {
+ WritePrivateProfileString("Splash","FadeIn","1",szIniFile);
+ options.fadein = 1;
+ }
+ else
+ {
+ WritePrivateProfileString("Splash","FadeIn","0",szIniFile);
+ options.fadein = 0;
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT))
+ {
+ WritePrivateProfileString("Splash","FadeOut","1",szIniFile);
+ options.fadeout = 1;
+ }
+ else
+ {
+ WritePrivateProfileString("Splash","FadeOut","0",szIniFile);
+ options.fadeout = 0;
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_RANDOM))
+ {
+ WritePrivateProfileString("Splash","Random","1",szIniFile);
+ options.random = 1;
+ }
+ else
+ {
+ WritePrivateProfileString("Splash","Random","0",szIniFile);
+ options.random = 0;
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_SHOWVERSION))
+ {
+ WritePrivateProfileString("Splash","ShowVersion","1",szIniFile);
+ options.showversion = 1;
+ }
+ else
+ {
+ WritePrivateProfileString("Splash","ShowVersion","0",szIniFile);
+ options.showversion = 0;
+ }
+ return TRUE;
+ }
+ }
+ }
+
+ case WM_DESTROY:
+ break;
+ }
+ return FALSE;
+}
+
+int OptInit(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp;
+
+ ZeroMemory(&odp, sizeof(odp));
+ odp.cbSize = sizeof(odp);
+ odp.position = 0;
+ odp.hInstance = hInst;
+ odp.pszGroup = Translate("Customize");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_SPLASH_OPT);
+ odp.pszTitle = Translate("Splash Screen");
+ odp.pfnDlgProc = DlgProcOptions;
+ odp.flags = ODPF_BOLDGROUPS;
+ CallService(MS_OPT_ADDPAGE, wParam, (LPARAM) &odp);
+ return 0;
+}
diff --git a/splashscreen/src/resource.h b/splashscreen/src/resource.h
new file mode 100644
index 0000000..94480d0
--- /dev/null
+++ b/splashscreen/src/resource.h
@@ -0,0 +1,36 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by splash.rc
+//
+#define IDD_SPLASH_OPT 102
+#define IDC_CHOOSESPLASH 1004
+#define IDC_SPLASHPATH 1005
+#define IDC_PREVIEW 1006
+#define IDC_ACTIVE 1007
+#define IDC_SNDPATH 1008
+#define IDC_FADEIN 1009
+#define IDC_FADEOUT 1010
+#define IDC_CHOOSESND 1011
+#define IDC_PLAYSND 1012
+#define IDC_SHOWTIME 1013
+#define IDC_ST_SPIN 1014
+#define IDC_FISTEP 1015
+#define IDC_FI_SPIN 1016
+#define IDC_FOSTEP 1017
+#define IDC_FO_SPIN 1018
+#define IDC_RANDOM 1019
+#define IDC_LOOPSOUND 1022
+#define IDC_SHOWVERSION 1023
+#define IDC_VERSIONPREFIX 1024
+#define IDC_PNG2DIBWARN 1025
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 104
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1026
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/splashscreen/src/services.cpp b/splashscreen/src/services.cpp
new file mode 100644
index 0000000..8db2cc8
--- /dev/null
+++ b/splashscreen/src/services.cpp
@@ -0,0 +1,87 @@
+/*
+ Splash Screen Plugin for Miranda-IM (www.miranda-im.org)
+ (c) 2004-2007 nullbie, (c) 2005-2007 Thief
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ File name : $URL: http://svn.miranda.im/mainrepo/splashscreen/trunk/src/services.cpp $
+ Revision : $Rev: 951 $
+ Last change on : $Date: 2007-10-16 16:46:53 +0200 (Вт, 16 окт 2007) $
+ Last change by : $Author: Thief $
+
+*/
+
+#include "headers.h"
+
+extern bool bserviceinvoked;
+extern char szSplashFile[MAX_PATH], szMirDir[MAX_PATH];
+extern bool ShowSplash(bool bpreview);
+
+int ShowSplashService(WPARAM wparam,LPARAM lparam)
+{
+ bserviceinvoked = true;
+ char szOldfn [256];
+ char* pos;
+ char* filename = (char*) wparam;
+ int timetoshow = (int) lparam;
+
+ lstrcpy(szOldfn, szSplashFile);
+ options.showtime = timetoshow;
+
+ ZeroMemory(&szSplashFile,sizeof(szSplashFile));
+ pos = strrchr(filename, ':');
+ if (pos == NULL)
+ {
+ lstrcpy(szSplashFile, szMirDir);
+ lstrcat(szSplashFile, filename);
+ }
+ else
+ {
+ lstrcpy(szSplashFile, filename);
+ }
+
+ ShowSplash(false);
+
+ //ZeroMemory(&szSplashFile,sizeof(szSplashFile));
+ lstrcpy(szSplashFile, szOldfn);
+
+ return 0;
+}
+
+#ifdef _DEBUG
+int TestService(WPARAM wParam,LPARAM lParam)
+{
+ static char szTempPath[MAX_PATH];
+
+ OPENFILENAMEA ofn={0};
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.lpstrFilter = "PNG and BMP files\0*.png;*.bmp\0\0";
+ ofn.hwndOwner=0;
+ ofn.lpstrFile = szTempPath;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.Flags = OFN_HIDEREADONLY;
+ ofn.lpstrInitialDir = szMirDir;
+ *szTempPath = '\0';
+ ofn.lpstrDefExt = "";
+
+ if (GetOpenFileNameA(&ofn))
+ {
+ CallService(MS_SHOWSPLASH,(WPARAM)szTempPath,(LPARAM)0);
+ }
+
+ return 0;
+}
+#endif
diff --git a/splashscreen/src/splash.cpp b/splashscreen/src/splash.cpp
new file mode 100644
index 0000000..a5c6a14
--- /dev/null
+++ b/splashscreen/src/splash.cpp
@@ -0,0 +1,450 @@
+/*
+Splash Screen Plugin for Miranda-IM (www.miranda-im.org)
+(c) 2004-2007 nullbie, (c) 2005-2007 Thief
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+File name : $URL: http://svn.miranda.im/mainrepo/splashscreen/trunk/src/splash.cpp $
+Revision : $Rev: 1585 $
+Last change on : $Date: 2010-04-09 12:13:29 +0300 (Пт, 09 апр 2010) $
+Last change by : $Author: ghazan $
+
+*/
+
+#include "headers.h"
+#include "splash.h"
+
+bool ShowSplash(bool bpreview)
+{
+ if (bpreview && bpreviewruns) return 0;
+
+ if (bpreview) bpreviewruns = true;
+ unsigned long timeout = 0;
+
+ SplashBmp = new MyBitmap;
+
+#ifdef _DEBUG
+ logMessage("Loading splash file", szSplashFile);
+#endif
+
+ SplashBmp->loadFromFile(szSplashFile, NULL);
+
+ DWORD threadID;
+
+#ifdef _DEBUG
+ logMessage("Thread","start");
+#endif
+
+ if (bpreview)
+ {
+ ShowWindow(hwndSplash, SW_HIDE);
+ DestroyWindow(hwndSplash);
+
+ timeout = 2000;
+#ifdef _DEBUG
+ logMessage("Preview","yes");
+#endif
+ }
+ else
+ {
+ timeout = options.showtime;
+#ifdef _DEBUG
+ char b [40];
+ sprintf(b,"%d",options.showtime);
+ logMessage("Timeout",b);
+#endif
+ }
+
+ hSplashThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SplashThread, (LPVOID)timeout, 0, &threadID);
+
+#ifdef _DEBUG
+ logMessage("Thread","end");
+#endif
+
+ CloseHandle(hSplashThread);
+ hSplashThread = NULL;
+
+ return 1;
+}
+LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_LOADED:
+ {
+#ifdef _DEBUG
+ logMessage("WM_LOADED","called");
+#endif
+
+ if (!MyUpdateLayeredWindow) ShowWindow(hwndSplash, SW_SHOWNORMAL);
+ if (!options.showtime) SetTimer(hwnd, 7, 2000, 0);
+
+ break;
+ }
+
+ case WM_LBUTTONDOWN:
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+ break;
+
+ case WM_TIMER:
+
+#ifdef _DEBUG
+ char b [40];
+ sprintf(b,"%d",wParam);
+ logMessage("Timer ID",b);
+ sprintf(b,"%d",options.showtime);
+ logMessage("ShowTime value",b);
+#endif
+
+ if (options.showtime > 0) //TimeToShow enabled
+ {
+ if (wParam == 6)
+ {
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+#ifdef _DEBUG
+ logMessage("Showtime timer","triggered");
+#endif
+ }
+ }
+ else
+ {
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+ if (wParam == 7)
+ {
+#ifdef _DEBUG
+ logMessage("On Modules Loaded timer","triggered");
+#endif
+ }
+ if (wParam == 8)
+ {
+#ifdef _DEBUG
+ logMessage("On Modules Loaded workaround","triggered");
+#endif
+ }
+ }
+
+ break;
+
+ case WM_RBUTTONDOWN:
+ {
+ ShowWindow(hwndSplash, SW_HIDE);
+ DestroyWindow(hwndSplash);
+ bpreviewruns = false; // preview is stopped.
+
+ break;
+ }
+
+ case WM_CLOSE:
+ {
+ if (MyUpdateLayeredWindow) // Win 2000+
+ {
+ RECT rc; GetWindowRect(hwndSplash, &rc);
+ POINT ptDst = { rc.left, rc.top };
+ POINT ptSrc = { 0, 0 };
+ SIZE sz = { rc.right - rc.left, rc.bottom - rc.top };
+
+ BLENDFUNCTION blend;
+ blend.BlendOp = AC_SRC_OVER;
+ blend.BlendFlags = 0;
+ blend.SourceConstantAlpha = 255;
+ blend.AlphaFormat = AC_SRC_ALPHA;
+
+ // Fade Out
+ if (options.fadeout)
+ {
+ int i;
+ for (i = 255; i>=0; i -= options.fosteps)
+ {
+ blend.SourceConstantAlpha = i;
+ MyUpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
+ Sleep(1);
+ }
+ }
+ }
+ if (bserviceinvoked) bserviceinvoked = false;
+ if (bpreviewruns) bpreviewruns = false;
+
+ DestroyWindow(hwndSplash);
+ }
+
+ case WM_MOUSEMOVE:
+ {
+ if (bserviceinvoked)
+ {
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+ }
+ break;
+ }
+
+ case WM_DESTROY:
+ {
+ PostQuitMessage(0);
+#ifdef _DEBUG
+ logMessage("WM_DESTROY","called");
+#endif
+ break;
+ }
+
+ case WM_PAINT:
+ {
+ if (!MyUpdateLayeredWindow) // Win 9x
+ {
+#ifdef _DEBUG
+ logMessage("WM_PAINT","painting..");
+#endif
+ PAINTSTRUCT ps;
+ BeginPaint(hwndSplash, &ps);
+ BitBlt(ps.hdc, 0, 0, SplashBmp->getWidth(), SplashBmp->getHeight(), tmpBmp->getDC(), 0, 0, SRCCOPY);
+ EndPaint(hwndSplash, &ps);
+ }
+ break;
+ }
+
+ ShowWindow(hwndSplash, SW_HIDE);
+ DestroyWindow(hwndSplash);
+ break;
+ }
+
+ return DefWindowProc(hwnd, message, wParam, lParam);
+}
+
+int SplashThread(void *arg)
+{
+ // Old code, doesn't support mp3 files
+ if (options.playsnd) PlaySound(szSoundFile, NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT);
+
+ /*
+ // Buggy code, dropped for now
+ if (options.playsnd)
+ {
+ char cmd[32] = "play";
+
+ // TODO: figure out if this is working.
+ if(options.loopsnd) strcat(cmd, " repeat");
+
+ #ifdef _DEBUG
+ logMessage("Command",cmd);
+ #endif
+
+ if(strlen(szSoundFile) && (mciWnd = MCIWndCreate(NULL, 0, MCIWNDF_NOPLAYBAR, szSoundFile)) != NULL)
+ {
+ SetWindowPos(mciWnd,HWND_BOTTOM,-1000,-1000,0,0,SWP_NOSIZE);
+ ShowWindow(mciWnd, SW_HIDE);
+ if(MCIWndCanPlay(mciWnd))
+ MCIWndSendString(mciWnd, cmd);
+ }
+ }
+ */
+
+ WNDCLASSEX wcl;
+ wcl.cbSize = sizeof(wcl);
+ wcl.lpfnWndProc = SplashWindowProc;
+ wcl.style = 0;
+ wcl.cbClsExtra = 0;
+ wcl.cbWndExtra = 0;
+ wcl.hInstance = hInst;
+ wcl.hIcon = NULL;
+ wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
+ wcl.lpszMenuName = NULL;
+ wcl.lpszClassName = SPLASH_CLASS;
+ wcl.hIconSm = NULL;
+ RegisterClassEx(&wcl);
+
+ RECT DesktopRect;
+ int w = GetSystemMetrics(SM_CXSCREEN);
+ int h = GetSystemMetrics(SM_CYSCREEN);
+ DesktopRect.left = 0;
+ DesktopRect.top = 0;
+ DesktopRect.right = w;
+ DesktopRect.bottom = h;
+
+ RECT WindowRect;
+ WindowRect.left = (DesktopRect.left + DesktopRect.right - SplashBmp->getWidth()) / 2;
+ WindowRect.top = (DesktopRect.top + DesktopRect.bottom - SplashBmp->getHeight()) / 2;
+ WindowRect.right = WindowRect.left + SplashBmp->getWidth();
+ WindowRect.bottom = WindowRect.top + SplashBmp->getHeight();
+
+ hwndSplash = CreateWindowEx(
+ WS_EX_TOOLWINDOW | WS_EX_TOPMOST,//dwStyleEx
+ SPLASH_CLASS, //Class name
+ NULL, //Title
+ DS_SETFONT | DS_FIXEDSYS | WS_POPUP, //dwStyle
+ WindowRect.left, // x
+ WindowRect.top, // y
+ SplashBmp->getWidth(), // Width
+ SplashBmp->getHeight(), // Height
+ HWND_DESKTOP, //Parent
+ NULL, //menu handle
+ hInst, //Instance
+ NULL);
+
+ RECT rc; GetWindowRect(hwndSplash, &rc);
+ POINT ptDst = {rc.left, rc.top};
+ POINT ptSrc = {0, 0};
+ SIZE sz = {rc.right - rc.left, rc.bottom - rc.top};
+ bool splashWithMarkers = false;
+
+ BLENDFUNCTION blend;
+ blend.BlendOp = AC_SRC_OVER;
+ blend.BlendFlags = 0;
+ blend.SourceConstantAlpha = 0;
+ blend.AlphaFormat = AC_SRC_ALPHA;
+
+ if (options.showversion)
+ {
+ // locate text markers:
+ int i, x = -1, y = -1;
+
+ int splashWidth = SplashBmp->getWidth();
+ for (i = 0; i < splashWidth; ++i)
+ if (SplashBmp->getRow(0)[i] & 0xFF000000)
+ {
+ if (x < 0)
+ {
+ x = i-1; // 1 pixel for marker line
+ splashWithMarkers = true;
+ } else
+ {
+ x = -1;
+ splashWithMarkers = false;
+ break;
+ }
+ }
+ int splashHeight = SplashBmp->getHeight();
+ for (i = 0; splashWithMarkers && (i < splashHeight); ++i)
+ if (SplashBmp->getRow(i)[0] & 0xFF000000)
+ {
+ if (y < 0)
+ {
+ y = i-1; // 1 pixel for marker line
+ splashWithMarkers = true;
+ } else
+ {
+ y = -1;
+ splashWithMarkers = false;
+ break;
+ }
+ }
+
+ char verString[256] = {0};
+ //char* ptr_verString = &verString;
+ /*
+ if (strlen(szPrefix)) strcat(verString,(char*)szPrefix);
+ strcat(verString,mirandaVerString);
+ */
+ mir_snprintf(verString, sizeof(verString), "%s%s", szPrefix, mirandaVerString);
+ LOGFONT lf = {0};
+ lf.lfHeight = 14;
+ strcpy(lf.lfFaceName, "Verdana");
+ SelectObject(SplashBmp->getDC(), CreateFontIndirect(&lf));
+ if (!splashWithMarkers)
+ {
+ SIZE v_sz = {0,0};
+ GetTextExtentPoint32(SplashBmp->getDC(),verString,strlen(verString),&v_sz);
+ x = SplashBmp->getWidth()/2-(v_sz.cx/2);
+ y = SplashBmp->getHeight()-(SplashBmp->getHeight()*(100-90)/100);
+ }
+
+ SetTextColor(SplashBmp->getDC(), (0xFFFFFFFFUL-SplashBmp->getRow(y)[x])&0x00FFFFFFUL);
+ //SplashBmp->DrawText(verString,SplashBmp->getWidth()/2-(v_sz.cx/2),SplashBmp->getHeight()-30);
+ SetBkMode(SplashBmp->getDC(), TRANSPARENT);
+ SplashBmp->DrawText(verString,x,y);
+ //free (ptr_verString);
+ }
+
+ if (MyUpdateLayeredWindow) // Win 2000+
+ {
+ SetWindowLong(hwndSplash, GWL_EXSTYLE, GetWindowLong(hwndSplash, GWL_EXSTYLE) | WS_EX_LAYERED);
+ /*
+ if (splashWithMarkers)
+ {
+ ++ptSrc.x;
+ ++ptSrc.y;
+ }
+ */
+ MyUpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
+
+ ShowWindow(hwndSplash, SW_SHOWNORMAL);
+ }
+ else // Win 9x
+ {
+ tmpBmp = new MyBitmap(SplashBmp->getWidth(),SplashBmp->getHeight());
+ HDC dtDC = GetDC(GetDesktopWindow());
+
+ BitBlt(tmpBmp->getDC(),
+ 0,
+ 0,
+ SplashBmp->getWidth(),
+ SplashBmp->getHeight(),
+ dtDC,
+ (DesktopRect.left + DesktopRect.right - SplashBmp->getWidth()) / 2,
+ (DesktopRect.top + DesktopRect.bottom - SplashBmp->getHeight()) / 2,
+ SRCCOPY);
+
+ ReleaseDC(GetDesktopWindow(), dtDC);
+
+ tmpBmp->Blend(SplashBmp, (splashWithMarkers?-1:0), (splashWithMarkers?-1:0), SplashBmp->getWidth(), SplashBmp->getHeight());
+
+ }
+
+ if (MyUpdateLayeredWindow) // Win 2000+
+ {
+ if (options.fadein)
+ {
+ // Fade in
+ int i;
+ for (i = 0; i < 255; i += options.fisteps)
+ {
+ blend.SourceConstantAlpha = i;
+ MyUpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
+ Sleep(1);
+ }
+ }
+ blend.SourceConstantAlpha = 255;
+ MyUpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
+ }
+
+ if (DWORD(arg) > 0)
+ {
+ if (SetTimer(hwndSplash, 6, DWORD(arg), 0))
+ {
+#ifdef _DEBUG
+ logMessage("Timer TimeToShow","set");
+#endif
+ }
+ }
+ else
+ if (bmodulesloaded)
+ {
+ if (SetTimer(hwndSplash, 8, 2000, 0))
+ {
+#ifdef _DEBUG
+ logMessage("Timer Modules loaded","set");
+#endif
+ }
+ }
+
+ // The Message Pump
+ MSG msg;
+ while (GetMessage(&msg, NULL, 0, 0) == TRUE) //NULL means every window in the thread; == TRUE means a safe pump.
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ ExitThread(0);
+ return 1;
+}
diff --git a/splashscreen/src/splash.h b/splashscreen/src/splash.h
new file mode 100644
index 0000000..a608343
--- /dev/null
+++ b/splashscreen/src/splash.h
@@ -0,0 +1,44 @@
+/*
+ Splash Screen Plugin for Miranda-IM (www.miranda-im.org)
+ (c) 2004-2007 nullbie, (c) 2005-2007 Thief
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ File name : $URL: http://svn.miranda.im/mainrepo/splashscreen/trunk/src/splash.h $
+ Revision : $Rev: 1585 $
+ Last change on : $Date: 2010-04-09 12:13:29 +0300 (Пт, 09 апр 2010) $
+ Last change by : $Author: ghazan $
+
+*/
+
+#ifndef __splash_h__
+#define __splash_h__
+
+extern char szSplashFile[MAX_PATH], szSoundFile[MAX_PATH];
+extern bool bserviceinvoked, bmodulesloaded;
+bool bpreviewruns;
+extern char *mirandaVerString;
+extern char szPrefix[128];
+extern HANDLE hSplashThread;
+extern HINSTANCE hInst;
+int SplashThread(void *);
+HWND hwndSplash;
+MyBitmap *SplashBmp, *tmpBmp;
+
+BOOL (WINAPI *MyUpdateLayeredWindow)
+ (HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc,
+ COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags);
+
+#endif // __splash_h__
diff --git a/splashscreen/src/splash.rc b/splashscreen/src/splash.rc
new file mode 100644
index 0000000..b71eb0a
--- /dev/null
+++ b/splashscreen/src/splash.rc
@@ -0,0 +1,152 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1251)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO MOVEABLE PURE
+BEGIN
+ IDD_SPLASH_OPT, DIALOG
+ BEGIN
+ RIGHTMARGIN, 307
+ VERTGUIDE, 32
+ VERTGUIDE, 39
+ VERTGUIDE, 58
+ VERTGUIDE, 101
+ VERTGUIDE, 130
+ VERTGUIDE, 172
+ HORZGUIDE, 119
+ HORZGUIDE, 136
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_SPLASH_OPT DIALOGEX 0, 0, 314, 240
+STYLE DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg"
+BEGIN
+ GROUPBOX "Splash Options",IDC_STATIC,20,7,275,81
+ CONTROL "Show splash",IDC_ACTIVE,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,58,26,64,10
+ CONTROL "Show random splash",IDC_RANDOM,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,130,26,163,10
+ EDITTEXT IDC_SPLASHPATH,69,39,145,13,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_CHOOSESPLASH,222,40,22,11
+ CONTROL "Play sound",IDC_PLAYSND,"Button",BS_AUTO3STATE |
+ WS_TABSTOP,58,55,64,10
+ CONTROL "Loop sound",IDC_LOOPSOUND,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,130,55,137,10
+ EDITTEXT IDC_SNDPATH,69,67,145,13,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_CHOOSESND,222,68,22,11
+ GROUPBOX "Show Miranda Version",IDC_STATIC,20,90,275,42
+ CONTROL "Enable",IDC_SHOWVERSION,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,39,109,63,8
+ LTEXT "Prefix:",IDC_STATIC,130,108,42,10
+ EDITTEXT IDC_VERSIONPREFIX,180,106,85,13,ES_AUTOHSCROLL
+ GROUPBOX "Appearance",IDC_STATIC,20,135,275,72
+ LTEXT "Display time:",IDC_STATIC,40,150,77,8
+ EDITTEXT IDC_SHOWTIME,130,149,39,12,ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "",IDC_ST_SPIN,"msctls_updown32",UDS_SETBUDDYINT |
+ UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS |
+ UDS_NOTHOUSANDS,171,149,10,10
+ LTEXT "msec",IDC_STATIC,175,150,95,9
+ CONTROL "Fade in:",IDC_FADEIN,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,39,169,80,8
+ EDITTEXT IDC_FISTEP,130,168,39,12,ES_AUTOHSCROLL
+ CONTROL "",IDC_FI_SPIN,"msctls_updown32",UDS_SETBUDDYINT |
+ UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,170,167,
+ 10,10
+ LTEXT "steps",IDC_STATIC,176,169,95,9
+ CONTROL "Fade out:",IDC_FADEOUT,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,39,188,82,8
+ EDITTEXT IDC_FOSTEP,130,186,39,12,ES_AUTOHSCROLL
+ CONTROL "",IDC_FO_SPIN,"msctls_updown32",UDS_SETBUDDYINT |
+ UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,173,186,
+ 10,10
+ LTEXT "steps",IDC_STATIC,176,187,95,9
+ LTEXT "Advaimg library not found. Please get it from nigtlies to be able to use images.",
+ IDC_PNG2DIBWARN,24,210,185,17,NOT WS_VISIBLE
+ PUSHBUTTON "Preview...",IDC_PREVIEW,218,211,75,19
+END
+
+#endif // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Unknown language: 0x22, 0x1 resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_UKR)
+#ifdef _WIN32
+LANGUAGE 0x22, 0x1
+#pragma code_page(1251)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "resource.h\0"
+END
+
+3 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "\r\n"
+END
+
+2 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "#include ""afxres.h""\r\n"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // Unknown language: 0x22, 0x1 resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/splashscreen/src/version.h b/splashscreen/src/version.h
new file mode 100644
index 0000000..5f5464d
--- /dev/null
+++ b/splashscreen/src/version.h
@@ -0,0 +1,3 @@
+#define __FILEVERSION_STRING 0,1,2,2
+#define __VERSION_STRING "0.1.2.2"
+#define __VERSION_DWORD 0x00010202
diff --git a/splashscreen/src/version.rc b/splashscreen/src/version.rc
new file mode 100644
index 0000000..b508eb2
--- /dev/null
+++ b/splashscreen/src/version.rc
@@ -0,0 +1,115 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+#include "version.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Ukrainian resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_UKR)
+#ifdef _WIN32
+LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT
+#pragma code_page(1251)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x37L
+#ifdef _DEBUG
+ FILEFLAGS 0x21L
+#else
+ FILEFLAGS 0x20L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "Comments", "Shows a splash when Miranda loads"
+ VALUE "FileDescription", "Splash Screen Plugin"
+ VALUE "FileVersion", __VERSION_STRING
+ VALUE "LegalCopyright", "Copyright © 2004-07 nullbie, 2005-09 Thief"
+ VALUE "LegalTrademarks", "GPL v2"
+ VALUE "OriginalFilename", "AdvSplashScreen.dll"
+ VALUE "ProductVersion", __VERSION_STRING
+ VALUE "SpecialBuild", "Beta"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
+
+#endif // Ukrainian resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// 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
+ "resource1.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+