mirror of
https://github.com/chylex/Nextcloud-Desktop.git
synced 2026-04-04 20:34:17 +02:00
Compare commits
169 Commits
v1.8.0-bet
...
v1.8.1-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
458f336405 | ||
|
|
3f3f27d4d3 | ||
|
|
7c9cffa5ae | ||
|
|
996223197c | ||
|
|
b8e7555977 | ||
|
|
ed80a712ab | ||
|
|
2866e56c51 | ||
|
|
2074bdbb19 | ||
|
|
d212ac7d16 | ||
|
|
d2bae21b14 | ||
|
|
4283ab3b44 | ||
|
|
c579069071 | ||
|
|
88488c695c | ||
|
|
21594e9aa9 | ||
|
|
9ffacd4ecd | ||
|
|
9d5f5ea3bc | ||
|
|
2dbd27af76 | ||
|
|
0634a4d0c6 | ||
|
|
fa80a006b8 | ||
|
|
9d88ef5432 | ||
|
|
7b99877c68 | ||
|
|
ec81cdefb0 | ||
|
|
454d5b575c | ||
|
|
785b59e6d1 | ||
|
|
9d8fc4aa4d | ||
|
|
57ac1d9ea2 | ||
|
|
d9ea6936ab | ||
|
|
c917251e9e | ||
|
|
c805c5d6e9 | ||
|
|
adcf40afc3 | ||
|
|
d986011067 | ||
|
|
5a83636f81 | ||
|
|
d475628c70 | ||
|
|
4a890eae38 | ||
|
|
760e11bc5d | ||
|
|
96ebf2b519 | ||
|
|
4a6f4919d7 | ||
|
|
b98040c7d5 | ||
|
|
1240a8163d | ||
|
|
e15b9b5358 | ||
|
|
1617c9d482 | ||
|
|
16600fe86a | ||
|
|
50ba73860c | ||
|
|
750cdc1910 | ||
|
|
f4e2c84111 | ||
|
|
4f27750711 | ||
|
|
71d9f23068 | ||
|
|
9f7aed7602 | ||
|
|
7f2213416a | ||
|
|
9b9f0bdd4d | ||
|
|
ee0aec514f | ||
|
|
c2fd7d6ebd | ||
|
|
4a893c5267 | ||
|
|
2473183f19 | ||
|
|
7d7142d7d8 | ||
|
|
cb57cda87a | ||
|
|
f2fa812b0b | ||
|
|
ef89582d7e | ||
|
|
ae74a21305 | ||
|
|
32af63764c | ||
|
|
61ff90409d | ||
|
|
ba0c3256fa | ||
|
|
b6fe5d2cff | ||
|
|
9123fac545 | ||
|
|
c6bc388001 | ||
|
|
ea985a85af | ||
|
|
2578832002 | ||
|
|
cfada67aa6 | ||
|
|
5483682281 | ||
|
|
2a8c23aac3 | ||
|
|
88bc96fc4c | ||
|
|
588129d852 | ||
|
|
0889991c38 | ||
|
|
5c87a35fe4 | ||
|
|
418185af9a | ||
|
|
4b56cc6e08 | ||
|
|
3cef771868 | ||
|
|
59b20de7cd | ||
|
|
e0ae34f01b | ||
|
|
a9a24c96fc | ||
|
|
a202203325 | ||
|
|
83c3d76966 | ||
|
|
99734f8d72 | ||
|
|
570a0bb586 | ||
|
|
450a815d61 | ||
|
|
dafc2d2b73 | ||
|
|
0bd2edd33a | ||
|
|
807267cfdb | ||
|
|
48c9222578 | ||
|
|
b5ea56df73 | ||
|
|
2fdf6dd8f2 | ||
|
|
5b8c9eb16f | ||
|
|
9c05150c12 | ||
|
|
c7eb85ef78 | ||
|
|
4df455f2e0 | ||
|
|
653a00d63d | ||
|
|
3c9acdf724 | ||
|
|
e81d1ab9b8 | ||
|
|
ad5620efb5 | ||
|
|
f455c71338 | ||
|
|
033f2cd231 | ||
|
|
c9eccd729d | ||
|
|
b1100cd9e5 | ||
|
|
8f728ddfb2 | ||
|
|
4ef0ce112c | ||
|
|
57c14a0eba | ||
|
|
89f831e7d4 | ||
|
|
917b8409ae | ||
|
|
86fd39e3a9 | ||
|
|
04db332051 | ||
|
|
06a2f58c51 | ||
|
|
b87d55758b | ||
|
|
38ef525d5e | ||
|
|
367b1fcc33 | ||
|
|
f5c930968e | ||
|
|
5264a8c7f6 | ||
|
|
6c4b7f1479 | ||
|
|
c42c9f0002 | ||
|
|
95f299f865 | ||
|
|
09749e2c7f | ||
|
|
dc33784a76 | ||
|
|
961df1fc44 | ||
|
|
e93c1ccb73 | ||
|
|
286ad0c478 | ||
|
|
e30970ff90 | ||
|
|
14e0e4a072 | ||
|
|
60da0a15e6 | ||
|
|
0f84510e6f | ||
|
|
1dd3488973 | ||
|
|
12e5306947 | ||
|
|
9249d6c2f9 | ||
|
|
d0f07ee3a9 | ||
|
|
3992fba168 | ||
|
|
4601ac8b0e | ||
|
|
a81b0db2a8 | ||
|
|
d88751bb8b | ||
|
|
f13dfc19a0 | ||
|
|
0fccf5e50d | ||
|
|
a2aab28ba6 | ||
|
|
8e7b7caf04 | ||
|
|
8cc5ff0e70 | ||
|
|
9086f09fe2 | ||
|
|
5a6eecd694 | ||
|
|
efe9f1b442 | ||
|
|
db7919dc2f | ||
|
|
4a01644625 | ||
|
|
1ca68140f6 | ||
|
|
071177cee2 | ||
|
|
c88742fad3 | ||
|
|
791a0fd01e | ||
|
|
3b12b9d81d | ||
|
|
31e4009737 | ||
|
|
8746914f3b | ||
|
|
2fa6839ac7 | ||
|
|
b09e08c06f | ||
|
|
659f5ad301 | ||
|
|
6fe7f01a8d | ||
|
|
99f51998f2 | ||
|
|
4c13992f5d | ||
|
|
396f38598f | ||
|
|
b6e24cbd45 | ||
|
|
d2848b9c26 | ||
|
|
227ed8ae07 | ||
|
|
b622981b23 | ||
|
|
36e14cfc69 | ||
|
|
668de9bf31 | ||
|
|
3f712dce02 | ||
|
|
2eaeaf33fa | ||
|
|
8e21d612d8 |
@@ -1,6 +1,6 @@
|
||||
ChangeLog
|
||||
=========
|
||||
version 1.8.0 (release 2015-02-xx)
|
||||
version 1.8.0 (release 2015-03-xx)
|
||||
* Mac OS: HIDPI support
|
||||
* Support Sharing from desktop: Added a share dialog that can be
|
||||
opened by context menu in the file managers (Win, Mac, Nautilus)
|
||||
@@ -12,7 +12,7 @@ version 1.8.0 (release 2015-02-xx)
|
||||
* Added ability to build on Windows utilizing MingGW
|
||||
* SQLite database fixes if running on FAT filesystems
|
||||
* Improved detection of changing files to upload from local
|
||||
* Preparations for the muli-account feature
|
||||
* Preparations for the multi-account feature
|
||||
* Fixed experience for Window manager without system tray
|
||||
* Build with Qt 5.4
|
||||
* Dropped libneon dependency if Qt 5.4 is available
|
||||
@@ -24,8 +24,7 @@ version 1.8.0 (release 2015-02-xx)
|
||||
* Prepared direct download
|
||||
* Added Crashreporter feature to be switched on on demand
|
||||
* A huge amount of bug fixes in all areas of the client.
|
||||
|
||||
* more than 7000 commits since 1.7.0
|
||||
* almost 700 commits since 1.7.1
|
||||
|
||||
version 1.7.1 (release 2014-12-18)
|
||||
* Documentation fixes and updates
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
set( MIRALL_VERSION_MAJOR 1 )
|
||||
set( MIRALL_VERSION_MINOR 8 )
|
||||
set( MIRALL_VERSION_PATCH 0 )
|
||||
set( MIRALL_VERSION_PATCH 1 )
|
||||
set( MIRALL_SOVERSION 0 )
|
||||
|
||||
if ( NOT DEFINED MIRALL_VERSION_SUFFIX )
|
||||
set( MIRALL_VERSION_SUFFIX "beta2") #e.g. beta1, beta2, rc1
|
||||
set( MIRALL_VERSION_SUFFIX "beta1") #e.g. beta1, beta2, rc1
|
||||
endif( NOT DEFINED MIRALL_VERSION_SUFFIX )
|
||||
|
||||
if( NOT DEFINED MIRALL_VERSION_BUILD )
|
||||
|
||||
75
admin/osx/gen_sym_files.py
Executable file
75
admin/osx/gen_sym_files.py
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import logging, os, re, subprocess, sys
|
||||
import os.path
|
||||
import pdb, pprint
|
||||
|
||||
if len(sys.argv) < 4:
|
||||
print("Usage:")
|
||||
print("\tgen_sym_files.py <path to breakpad's dump_syms> <path to owncloud.app> <symbol output dir>")
|
||||
print("")
|
||||
print("Symbols will be created in './symbols'")
|
||||
sys.exit(1)
|
||||
|
||||
dump_symsPath = sys.argv[1]
|
||||
bundlePath = sys.argv[2]
|
||||
outPath = sys.argv[3]
|
||||
macOsDir = os.path.join(bundlePath, 'Contents', 'MacOS')
|
||||
pluginsDir = os.path.join(bundlePath, 'Contents', 'PlugIns')
|
||||
|
||||
def resolvePath(input):
|
||||
resolved = re.sub(r'@\w+', macOsDir, input)
|
||||
return os.path.normpath(resolved)
|
||||
|
||||
def extractDeps(macho):
|
||||
deps = [macho]
|
||||
otool = subprocess.Popen(['otool', '-L', macho], stdout=subprocess.PIPE)
|
||||
for l in otool.communicate()[0].splitlines():
|
||||
m = re.search(r'@[^\s]+', l)
|
||||
if m:
|
||||
path = resolvePath(m.group(0))
|
||||
if not os.path.exists(path):
|
||||
logging.warning("Non-existant file found in dependencies, ignoring: [%s]", path)
|
||||
continue
|
||||
deps.append(path)
|
||||
return deps
|
||||
|
||||
def findDeps():
|
||||
deps = []
|
||||
for f in os.listdir(macOsDir):
|
||||
path = os.path.join(macOsDir, f)
|
||||
if not os.path.islink(path):
|
||||
deps += extractDeps(path)
|
||||
for root, dirs, files in os.walk(pluginsDir):
|
||||
for f in files:
|
||||
path = os.path.join(root, f)
|
||||
deps += extractDeps(path)
|
||||
return sorted(set(deps))
|
||||
|
||||
def dumpSyms(deps):
|
||||
for dep in deps:
|
||||
print("Generating symbols for [%s]" % dep)
|
||||
with open('temp.sym', 'w') as temp:
|
||||
subprocess.check_call([dump_symsPath, dep], stdout=temp)
|
||||
with open('temp.sym', 'r') as temp:
|
||||
header = temp.readline()
|
||||
fields = header.split()
|
||||
key, name = fields[3:5]
|
||||
destDir = '%s/%s/%s/' % (outPath, name, key)
|
||||
destPath = destDir + name + '.sym'
|
||||
if os.path.exists(destPath):
|
||||
logging.warning("Symbols already exist: [%s]", destPath)
|
||||
continue
|
||||
if not os.path.exists(destDir):
|
||||
os.makedirs(destDir)
|
||||
os.rename('temp.sym', destPath)
|
||||
|
||||
def strip(deps):
|
||||
for dep in deps:
|
||||
print("Stripping symbols off [%s]" % dep)
|
||||
subprocess.check_call(['strip', '-S', dep])
|
||||
|
||||
print('=== Generating symbols for [%s] in [%s]' % (bundlePath, outPath))
|
||||
deps = findDeps()
|
||||
dumpSyms(deps)
|
||||
strip(deps)
|
||||
@@ -6,3 +6,4 @@ killall @APPLICATION_EXECUTABLE@
|
||||
# Unload the Finder plugin. see issue #2105
|
||||
killall Finder
|
||||
|
||||
exit 0
|
||||
|
||||
19
admin/win/docker/build.sh
Executable file
19
admin/win/docker/build.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $(basename $0) directory_relative_to_home [uid]"
|
||||
exit
|
||||
fi
|
||||
|
||||
useradd user -u ${2:-1000}
|
||||
su - user << EOF
|
||||
cd /home/user/$1
|
||||
rm -rf build-win32
|
||||
mkdir build-win32
|
||||
cd build-win32
|
||||
../admin/win/download_runtimes.sh
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=../admin/win/Toolchain-mingw32-openSUSE.cmake -DWITH_CRASHREPORTER=ON
|
||||
make -j4
|
||||
make package
|
||||
ctest .
|
||||
EOF
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#VS2013
|
||||
base_url=http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3
|
||||
tmp_path=/tmp/.vcredist
|
||||
tmp_path=${1:-/tmp/.vcredist}
|
||||
|
||||
mkdir -p $tmp_path
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ StrCpy $PageReinstall_SAME_Field_3 "Desinstal.lar ${APPLICATION_NAME}"
|
||||
StrCpy $UNINSTALLER_APPDATA_TITLE "Desinstal.lar ${APPLICATION_NAME}"
|
||||
StrCpy $PageReinstall_SAME_MUI_HEADER_TEXT_SUBTITLE "Escolliu l'opció de manteniment per executar-ho."
|
||||
StrCpy $SEC_APPLICATION_DETAILS "Instal·lant ${APPLICATION_NAME} essencial."
|
||||
StrCpy $OPTION_SECTION_SC_SHELL_EXT_SECTION "Integració per Windows Explorer"
|
||||
StrCpy $OPTION_SECTION_SC_SHELL_EXT_DetailPrint "Instal·lant integració per Windows Explorer"
|
||||
StrCpy $OPTION_SECTION_SC_START_MENU_SECTION "Accés directe del programa al menú d'inici"
|
||||
StrCpy $OPTION_SECTION_SC_START_MENU_DetailPrint "Afegint la drecera per ${APPLICATION_NAME} al menú d'inici."
|
||||
StrCpy $OPTION_SECTION_SC_DESKTOP_SECTION "Drecera a l'escriptori"
|
||||
@@ -42,5 +44,3 @@ StrCpy $INIT_INSTALLER_RUNNING "L'instal·lador ja s'està executant."
|
||||
StrCpy $UAC_UNINSTALLER_REQUIRE_ADMIN "Aquest desinstal·lador requereix accés d'administrador, intenteu-ho de nou."
|
||||
StrCpy $INIT_UNINSTALLER_RUNNING "El desinstal·lador ja s'està executant."
|
||||
StrCpy $SectionGroup_Shortcuts "Dreceres"
|
||||
StrCpy $OPTION_SECTION_SC_SHELL_EXT_SECTION "Integration for Windows Explorer"
|
||||
StrCpy $OPTION_SECTION_SC_SHELL_EXT_DetailPrint "Installing Integration for Windows Explorer"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Auto-generated - do not modify
|
||||
StrCpy $MUI_FINISHPAGE_SHOWREADME_TEXT_STRING "Afficher les notes de version"
|
||||
StrCpy $ConfirmEndProcess_MESSAGEBOX_TEXT "Le(s) processus en cours d’exécution ${APPLICATION_EXECUTABLE} doit (doivent) être stoppé(s) afin de poursuivre.$\nVoulez-vous que le programme d’installation s’en charge pour vous ?"
|
||||
StrCpy $ConfirmEndProcess_MESSAGEBOX_TEXT "Les processus ${APPLICATION_EXECUTABLE} en cours d’exécution doivent être stoppés avant de poursuivre.$\nVoulez-vous que le programme d’installation s’en charge pour vous ?"
|
||||
StrCpy $ConfirmEndProcess_KILLING_PROCESSES_TEXT "Fermeture des processus ${APPLICATION_EXECUTABLE}."
|
||||
StrCpy $ConfirmEndProcess_KILL_NOT_FOUND_TEXT "Le processus à stopper n'a pas été trouvé !"
|
||||
StrCpy $PageReinstall_NEW_Field_1 "Une ancienne version de ${APPLICATION_NAME} est installée sur votre système. Il est recommandé de désinstaller cette version avant de continuer. Sélectionnez l'opération que vous voulez exécuter et cliquez sur Suivant pour continuer."
|
||||
|
||||
Binary file not shown.
@@ -1,35 +0,0 @@
|
||||
{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f39\fswiss\fcharset0\fprq2{\*\panose 020b0604030504040204}Verdana;}
|
||||
{\f172\froman\fcharset238\fprq2 Times New Roman CE;}{\f173\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f175\froman\fcharset161\fprq2 Times New Roman Greek;}{\f176\froman\fcharset162\fprq2 Times New Roman Tur;}
|
||||
{\f177\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f178\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f179\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f180\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}
|
||||
{\f562\fswiss\fcharset238\fprq2 Verdana CE;}{\f563\fswiss\fcharset204\fprq2 Verdana Cyr;}{\f565\fswiss\fcharset161\fprq2 Verdana Greek;}{\f566\fswiss\fcharset162\fprq2 Verdana Tur;}{\f569\fswiss\fcharset186\fprq2 Verdana Baltic;}
|
||||
{\f570\fswiss\fcharset163\fprq2 Verdana (Vietnamese);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;
|
||||
\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{
|
||||
\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;}{\*\cs10 \additive \ssemihidden Default Paragraph Font;}{\*
|
||||
\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
|
||||
\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}{\*\cs15 \additive \ul\cf2 \sbasedon10 \styrsid7485074 Hyperlink;}}
|
||||
{\*\latentstyles\lsdstimax156\lsdlockeddef0}{\*\rsidtbl \rsid6712196\rsid7485074\rsid11352300\rsid15940516}{\*\generator Microsoft Word 11.0.5604;}{\info{\title Processes v1}{\author Hardwired}{\operator Hardwired}{\creatim\yr2004\mo12\dy12\hr23\min42}
|
||||
{\revtim\yr2004\mo12\dy12\hr23\min51}{\version2}{\edmins9}{\nofpages1}{\nofwords80}{\nofchars458}{\nofcharsws537}{\vern24689}}\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180
|
||||
\dgvspace180\dghorigin1800\dgvorigin1440\dghshow1\dgvshow1
|
||||
\jexpand\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct
|
||||
\asianbrkrule\rsidroot7485074\newtblstyruls\nogrowautofit \fet0\sectd \linex0\endnhere\sectlinegrid360\sectdefaultcl\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}
|
||||
{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}
|
||||
{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain
|
||||
\qj \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid7485074 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\b\f39\insrsid7485074\charrsid7485074 Processes v1.0}{\f39\insrsid7485074\charrsid7485074 .0.1
|
||||
\par }{\f39\fs20\insrsid7485074
|
||||
\par }\pard \qj \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid15940516 {\f39\fs20\insrsid15940516 This software binaries and source-code are free for any kind of use, including commercial use. }{
|
||||
\f39\fs20\insrsid7485074\charrsid7485074 There is no restriction and no guaranty for using}{\f39\fs20\insrsid7485074\charrsid7485074 t}{\f39\fs20\insrsid7485074\charrsid7485074 his software}{\f39\fs20\insrsid7485074\charrsid7485074 and/or it
|
||||
s source-code. }{\f39\fs20\insrsid15940516
|
||||
\par I}{\f39\fs20\insrsid7485074\charrsid7485074 f you use the plug}{\f39\fs20\insrsid7485074\charrsid7485074 -}{\f39\fs20\insrsid7485074\charrsid7485074 in }{\f39\fs20\insrsid7485074\charrsid7485074 and/}{\f39\fs20\insrsid7485074\charrsid7485074 or it}{
|
||||
\f39\fs20\insrsid7485074\charrsid7485074 s}{\f39\fs20\insrsid7485074\charrsid7485074 source-code, I would }{\f39\fs20\insrsid7485074\charrsid7485074 appreciate }{\f39\fs20\insrsid7485074\charrsid7485074 if my name is mentioned.}{
|
||||
\f39\fs20\insrsid7485074\charrsid7485074
|
||||
\par }\pard \qj \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid7485074 {\f39\fs20\insrsid7485074\charrsid7485074
|
||||
\par }{\b\f39\fs20\insrsid7485074\charrsid7485074 Andrei Ciubotaru [Hardwired]
|
||||
\par }{\f39\fs20\insrsid7485074\charrsid7485074 Lead Developer ICode&Ideas SRL (}{\field\flddirty{\*\fldinst {\f39\fs20\insrsid7485074\charrsid7485074 HYPERLINK "http://www.icode.ro/" }{\f39\fs20\insrsid7485074\charrsid7485074 {\*\datafield
|
||||
00d0c9ea79f9bace118c8200aa004ba90b02000000170000001500000068007400740070003a002f002f007700770077002e00690063006f00640065002e0072006f002f000000e0c9ea79f9bace118c8200aa004ba90b2a00000068007400740070003a002f002f007700770077002e00690063006f00640065002e007200
|
||||
6f002f000000}}}{\fldrslt {\cs15\f39\fs20\ul\cf2\insrsid7485074\charrsid7485074 http://www.icode.ro/}}}{\f39\fs20\insrsid7485074\charrsid7485074 )
|
||||
\par }{\field{\*\fldinst {\f39\fs20\insrsid7485074 HYPERLINK "hardwiredteks@gmail.com" }{\f39\fs20\insrsid15940516\charrsid7485074 {\*\datafield
|
||||
00d0c9ea79f9bace118c8200aa004ba90b02000000010000000303000000000000c00000000000004600001800000068617264776972656474656b7340676d61696c2e636f6d00ffffadde000000000000000000000000000000000000000000000000}}}{\fldrslt {
|
||||
\cs15\f39\fs20\ul\cf2\insrsid7485074\charrsid7485074 hardwiredteks@gmail.com}}}{\f39\fs20\insrsid7485074\charrsid7485074 , }{\field{\*\fldinst {\f39\fs20\insrsid7485074 HYPERLINK "hardwired@icode.ro" }{\f39\fs20\insrsid15940516\charrsid7485074
|
||||
{\*\datafield 00d0c9ea79f9bace118c8200aa004ba90b02000000010000000303000000000000c0000000000000460000130000006861726477697265644069636f64652e726f00ffffadde000000000000000000000000000000000000000000000000}}}{\fldrslt {
|
||||
\cs15\f39\fs20\ul\cf2\insrsid7485074\charrsid7485074 hardwired@icode.ro}}}{\f39\fs20\insrsid7485074\charrsid7485074
|
||||
\par }}
|
||||
@@ -1,122 +0,0 @@
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
Processes (Processes.dll)
|
||||
Version: 1.0.1.0
|
||||
Release: 24.february.2005
|
||||
Description: Nullsoft Installer (NSIS) plug-in for managing?!
|
||||
Windows processes.
|
||||
|
||||
Copyright: © 2004-2005 Hardwired. No rights reserved.
|
||||
There is no restriction and no guaranty for using
|
||||
this software.
|
||||
|
||||
Author: Andrei Ciubotaru [Hardwired]
|
||||
Lead Developer ICode&Ideas SRL (http://www.icode.ro/)
|
||||
hardwiredteks@gmail.com, hardwired@icode.ro
|
||||
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
INTRODUCTION
|
||||
|
||||
The Need For Plug-in - I need it for the one of my installers.
|
||||
|
||||
Briefly: Use it when you need to find\kill a process when
|
||||
installing\uninstalling some application. Also, use it when you
|
||||
need to test the presence of a device driver.
|
||||
|
||||
|
||||
SUPPORT
|
||||
|
||||
Supported platforms are: WinNT,Win2K,WinXP and Win2003 Server.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Processes::FindProcess <process_name> ;without ".exe"
|
||||
|
||||
Searches the currently running processes for the given
|
||||
process name.
|
||||
|
||||
return: 1 - the process was found
|
||||
0 - the process was not found
|
||||
|
||||
Processes::KillProcess <process_name> ; without ".exe"
|
||||
|
||||
Searches the currently running processes for the given
|
||||
process name. If the process is found then the it gets
|
||||
killed.
|
||||
|
||||
return: 1 - the process was found and killed
|
||||
0 - the process was not found or the process
|
||||
cannot be killed (insuficient rights)
|
||||
|
||||
Processes::FindDevice <device_base_name>
|
||||
|
||||
Searches the installed devices drivers for the given
|
||||
device base name.
|
||||
(important: I said BASE NAME not FILENAME)
|
||||
|
||||
return: 1 - the device driver was found
|
||||
0 - the device driver was not found
|
||||
|
||||
|
||||
USAGE
|
||||
|
||||
First of all, does not matter where you use it. Ofcourse, the
|
||||
routines must be called inside of a Section/Function scope.
|
||||
|
||||
Processes::FindProcess "process_name"
|
||||
Pop $R0
|
||||
|
||||
StrCmp $R0 "1" make_my_day noooooo
|
||||
|
||||
make_my_day:
|
||||
...
|
||||
|
||||
noooooo:
|
||||
...
|
||||
|
||||
|
||||
Processes::KillProcess "process_name"
|
||||
Pop $R0
|
||||
|
||||
StrCmp $R0 "1" dead_meat why_wont_you_die
|
||||
|
||||
dead_meat:
|
||||
...
|
||||
|
||||
why_wont_you_die:
|
||||
...
|
||||
|
||||
|
||||
Processes::FindDevice "device_base_name"
|
||||
Pop $R0
|
||||
|
||||
StrCmp $R0 "1" blabla more_blabla
|
||||
|
||||
blabla:
|
||||
...
|
||||
|
||||
more_blabla:
|
||||
...
|
||||
|
||||
|
||||
THANKS
|
||||
|
||||
Sunil Kamath for inspiring me. I wanted to use its FindProcDLL
|
||||
but my requirements made it imposible.
|
||||
|
||||
Nullsoft for creating this very powerfull installer. One big,
|
||||
free and full-featured (hmmm... and guiless for the moment) mean
|
||||
install machine!:)
|
||||
|
||||
ME for being such a great coder...
|
||||
... HAHAHAHAHAHAHA!
|
||||
|
||||
ONE MORE THING
|
||||
|
||||
If you use the plugin or it's source-code, I would apreciate
|
||||
if my name is mentioned.
|
||||
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
@@ -1,8 +0,0 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// KillProcDLL.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
@@ -1,34 +0,0 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__780690DC_E128_403D_BC07_780D1B2CC101__INCLUDED_)
|
||||
#define AFX_STDAFX_H__780690DC_E128_403D_BC07_780D1B2CC101__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <string> // String management...
|
||||
|
||||
//From exam28.cpp
|
||||
#include <tlhelp32.h>
|
||||
//#include <iostream.h>
|
||||
|
||||
#ifdef BORLANDC
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
//To make it a NSIS Plug-In
|
||||
#include "exdll.h"
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__780690DC_E128_403D_BC07_780D1B2CC101__INCLUDED_)
|
||||
@@ -1,37 +0,0 @@
|
||||
#include <windows.h>
|
||||
#include "exdll.h"
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
|
||||
HWND g_hwndParent;
|
||||
|
||||
void __declspec(dllexport) myFunction(HWND hwndParent, int string_size,
|
||||
char *variables, stack_t **stacktop)
|
||||
{
|
||||
g_hwndParent=hwndParent;
|
||||
|
||||
EXDLL_INIT();
|
||||
|
||||
|
||||
// note if you want parameters from the stack, pop them off in order.
|
||||
// i.e. if you are called via exdll::myFunction file.dat poop.dat
|
||||
// calling popstring() the first time would give you file.dat,
|
||||
// and the second time would give you poop.dat.
|
||||
// you should empty the stack of your parameters, and ONLY your
|
||||
// parameters.
|
||||
|
||||
// do your stuff here
|
||||
{
|
||||
char buf[1024];
|
||||
wsprintf(buf,"$0=%s\n",getuservariable(INST_0));
|
||||
MessageBox(g_hwndParent,buf,0,MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
g_hInstance=hInst;
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
#ifndef _EXDLL_H_
|
||||
#define _EXDLL_H_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// only include this file from one place in your DLL.
|
||||
// (it is all static, if you use it in two places it will fail)
|
||||
//
|
||||
#define EXDLL_INIT() { \
|
||||
g_stringsize = string_size; \
|
||||
g_stacktop = stacktop; \
|
||||
g_variables = variables; }
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// For page showing plug-ins
|
||||
//
|
||||
#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8)
|
||||
#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd)
|
||||
#define NOTIFY_BYE_BYE 'x'
|
||||
|
||||
typedef struct _stack_t
|
||||
{
|
||||
struct _stack_t *next;
|
||||
char text[1]; // this should be the length of string_size
|
||||
} stack_t;
|
||||
|
||||
|
||||
static unsigned int g_stringsize;
|
||||
static stack_t **g_stacktop;
|
||||
static char *g_variables;
|
||||
|
||||
enum
|
||||
{
|
||||
INST_0, // $0
|
||||
INST_1, // $1
|
||||
INST_2, // $2
|
||||
INST_3, // $3
|
||||
INST_4, // $4
|
||||
INST_5, // $5
|
||||
INST_6, // $6
|
||||
INST_7, // $7
|
||||
INST_8, // $8
|
||||
INST_9, // $9
|
||||
INST_R0, // $R0
|
||||
INST_R1, // $R1
|
||||
INST_R2, // $R2
|
||||
INST_R3, // $R3
|
||||
INST_R4, // $R4
|
||||
INST_R5, // $R5
|
||||
INST_R6, // $R6
|
||||
INST_R7, // $R7
|
||||
INST_R8, // $R8
|
||||
INST_R9, // $R9
|
||||
INST_CMDLINE, // $CMDLINE
|
||||
INST_INSTDIR, // $INSTDIR
|
||||
INST_OUTDIR, // $OUTDIR
|
||||
INST_EXEDIR, // $EXEDIR
|
||||
INST_LANG, // $LANGUAGE
|
||||
__INST_LAST
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// utility functions (not required but often useful)
|
||||
//
|
||||
static int popstring( char *str )
|
||||
{
|
||||
stack_t *th;
|
||||
|
||||
|
||||
if( !g_stacktop ||
|
||||
!*g_stacktop )
|
||||
return 1;
|
||||
|
||||
th = (*g_stacktop);
|
||||
lstrcpy( str, th->text );
|
||||
*g_stacktop = th->next;
|
||||
GlobalFree( (HGLOBAL)th );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void pushstring( char *str )
|
||||
{
|
||||
stack_t *th;
|
||||
|
||||
|
||||
if( !g_stacktop )
|
||||
return;
|
||||
|
||||
th = (stack_t*)GlobalAlloc( GPTR, sizeof(stack_t) + g_stringsize );
|
||||
lstrcpyn( th->text, str, g_stringsize );
|
||||
th->next = *g_stacktop;
|
||||
*g_stacktop = th;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static char *getuservariable( int varnum )
|
||||
{
|
||||
if( varnum < 0 ||
|
||||
varnum >= __INST_LAST )
|
||||
return NULL;
|
||||
|
||||
return (g_variables + varnum*g_stringsize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void setuservariable( int varnum, char *var )
|
||||
{
|
||||
if( var != NULL &&
|
||||
varnum >= 0 &&
|
||||
varnum < __INST_LAST )
|
||||
lstrcpy( g_variables + varnum*g_stringsize, var );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif//_EXDLL_H_
|
||||
@@ -1,411 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
#include "processes.h"
|
||||
#include "string.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// global variables
|
||||
lpfEnumProcesses EnumProcesses;
|
||||
lpfEnumProcessModules EnumProcessModules;
|
||||
lpfGetModuleBaseName GetModuleBaseName;
|
||||
lpfEnumDeviceDrivers EnumDeviceDrivers;
|
||||
lpfGetDeviceDriverBaseName GetDeviceDriverBaseName;
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
HWND g_hwndParent;
|
||||
HINSTANCE g_hInstLib;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// main DLL entry
|
||||
BOOL WINAPI _DllMainCRTStartup( HANDLE hInst,
|
||||
ULONG ul_reason_for_call,
|
||||
LPVOID lpReserved )
|
||||
{
|
||||
g_hInstance = (struct HINSTANCE__ *)hInst;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// loads the psapi routines
|
||||
bool LoadPSAPIRoutines( void )
|
||||
{
|
||||
if( NULL == (g_hInstLib = LoadLibraryA( "PSAPI.DLL" )) )
|
||||
return false;
|
||||
|
||||
EnumProcesses = (lpfEnumProcesses) GetProcAddress( g_hInstLib, "EnumProcesses" );
|
||||
EnumProcessModules = (lpfEnumProcessModules) GetProcAddress( g_hInstLib, "EnumProcessModules" );
|
||||
GetModuleBaseName = (lpfGetModuleBaseName) GetProcAddress( g_hInstLib, "GetModuleBaseNameA" );
|
||||
EnumDeviceDrivers = (lpfEnumDeviceDrivers) GetProcAddress( g_hInstLib, "EnumDeviceDrivers" );
|
||||
GetDeviceDriverBaseName = (lpfGetDeviceDriverBaseName) GetProcAddress( g_hInstLib, "GetDeviceDriverBaseNameA" );
|
||||
|
||||
if( ( NULL == EnumProcesses ) ||
|
||||
( NULL == EnumProcessModules ) ||
|
||||
( NULL == EnumDeviceDrivers ) ||
|
||||
( NULL == GetModuleBaseName ) ||
|
||||
( NULL == GetDeviceDriverBaseName ) )
|
||||
{
|
||||
FreeLibrary( g_hInstLib );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// free the psapi routines
|
||||
bool FreePSAPIRoutines( void )
|
||||
{
|
||||
EnumProcesses = NULL;
|
||||
EnumProcessModules = NULL;
|
||||
GetModuleBaseName = NULL;
|
||||
EnumDeviceDrivers = NULL;
|
||||
|
||||
if( FALSE == FreeLibrary( g_hInstLib ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// find a process by name
|
||||
// return value: true - process was found
|
||||
// false - process not found
|
||||
bool FindProc( char *szProcess )
|
||||
{
|
||||
char szProcessName[ 1024 ];
|
||||
char szCurrentProcessName[ 1024 ];
|
||||
DWORD dPID[ 1024 ];
|
||||
DWORD dPIDSize( 1024 );
|
||||
DWORD dSize( 1024 );
|
||||
HANDLE hProcess;
|
||||
HMODULE phModule[ 1024 ];
|
||||
|
||||
|
||||
//
|
||||
// make the name lower case
|
||||
//
|
||||
memset( szProcessName, 0, 1024*sizeof(char) );
|
||||
sprintf( szProcessName, "%s", szProcess );
|
||||
strlwr( szProcessName );
|
||||
|
||||
//
|
||||
// load PSAPI routines
|
||||
//
|
||||
if( false == LoadPSAPIRoutines() )
|
||||
return false;
|
||||
|
||||
//
|
||||
// enumerate processes names
|
||||
//
|
||||
if( FALSE == EnumProcesses( dPID, dSize, &dPIDSize ) )
|
||||
{
|
||||
FreePSAPIRoutines();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// walk trough and compare see if the process is running
|
||||
//
|
||||
for( int k( dPIDSize / sizeof( DWORD ) ); k >= 0; k-- )
|
||||
{
|
||||
memset( szCurrentProcessName, 0, 1024*sizeof(char) );
|
||||
|
||||
if( NULL != ( hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, dPID[ k ] ) ) )
|
||||
{
|
||||
if( TRUE == EnumProcessModules( hProcess, phModule, sizeof(HMODULE)*1024, &dPIDSize ) )
|
||||
if( GetModuleBaseName( hProcess, phModule[ 0 ], szCurrentProcessName, 1024 ) > 0 )
|
||||
{
|
||||
strlwr( szCurrentProcessName );
|
||||
|
||||
if( NULL != strstr( szCurrentProcessName, szProcessName ) )
|
||||
{
|
||||
FreePSAPIRoutines();
|
||||
CloseHandle( hProcess );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle( hProcess );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// free PSAPI routines
|
||||
//
|
||||
FreePSAPIRoutines();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// kills a process by name
|
||||
// return value: true - process was found
|
||||
// false - process not found
|
||||
bool KillProc( char *szProcess )
|
||||
{
|
||||
char szProcessName[ 1024 ];
|
||||
char szCurrentProcessName[ 1024 ];
|
||||
DWORD dPID[ 1024 ];
|
||||
DWORD dPIDSize( 1024 );
|
||||
DWORD dSize( 1024 );
|
||||
HANDLE hProcess;
|
||||
HMODULE phModule[ 1024 ];
|
||||
|
||||
|
||||
//
|
||||
// make the name lower case
|
||||
//
|
||||
memset( szProcessName, 0, 1024*sizeof(char) );
|
||||
sprintf( szProcessName, "%s", szProcess );
|
||||
strlwr( szProcessName );
|
||||
|
||||
//
|
||||
// load PSAPI routines
|
||||
//
|
||||
if( false == LoadPSAPIRoutines() )
|
||||
return false;
|
||||
|
||||
//
|
||||
// enumerate processes names
|
||||
//
|
||||
if( FALSE == EnumProcesses( dPID, dSize, &dPIDSize ) )
|
||||
{
|
||||
FreePSAPIRoutines();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// walk trough and compare see if the process is running
|
||||
//
|
||||
for( int k( dPIDSize / sizeof( DWORD ) ); k >= 0; k-- )
|
||||
{
|
||||
memset( szCurrentProcessName, 0, 1024*sizeof(char) );
|
||||
|
||||
if( NULL != ( hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, dPID[ k ] ) ) )
|
||||
{
|
||||
if( TRUE == EnumProcessModules( hProcess, phModule, sizeof(HMODULE)*1024, &dPIDSize ) )
|
||||
if( GetModuleBaseName( hProcess, phModule[ 0 ], szCurrentProcessName, 1024 ) > 0 )
|
||||
{
|
||||
strlwr( szCurrentProcessName );
|
||||
|
||||
if( NULL != strstr( szCurrentProcessName, szProcessName ) )
|
||||
{
|
||||
FreePSAPIRoutines();
|
||||
|
||||
//
|
||||
// kill process
|
||||
//
|
||||
if( false == TerminateProcess( hProcess, 0 ) )
|
||||
{
|
||||
CloseHandle( hProcess );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// refresh systray
|
||||
//
|
||||
UpdateWindow( FindWindow( NULL, "Shell_TrayWnd" ) );
|
||||
|
||||
//
|
||||
// refresh desktop window
|
||||
//
|
||||
UpdateWindow( GetDesktopWindow() );
|
||||
|
||||
CloseHandle( hProcess );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle( hProcess );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// free PSAPI routines
|
||||
//
|
||||
FreePSAPIRoutines();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
bool FindDev( char *szDriverName )
|
||||
{
|
||||
char szDeviceName[ 1024 ];
|
||||
char szCurrentDeviceName[ 1024 ];
|
||||
LPVOID lpDevices[ 1024 ];
|
||||
DWORD dDevicesSize( 1024 );
|
||||
DWORD dSize( 1024 );
|
||||
TCHAR tszCurrentDeviceName[ 1024 ];
|
||||
DWORD dNameSize( 1024 );
|
||||
|
||||
|
||||
//
|
||||
// make the name lower case
|
||||
//
|
||||
memset( szDeviceName, 0, 1024*sizeof(char) );
|
||||
sprintf( szDeviceName, "%s", strlwr( szDriverName ) );
|
||||
|
||||
//
|
||||
// load PSAPI routines
|
||||
//
|
||||
if( false == LoadPSAPIRoutines() )
|
||||
return false;
|
||||
|
||||
//
|
||||
// enumerate devices
|
||||
//
|
||||
if( FALSE == EnumDeviceDrivers( lpDevices, dSize, &dDevicesSize ) )
|
||||
{
|
||||
FreePSAPIRoutines();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// walk trough and compare see if the device driver exists
|
||||
//
|
||||
for( int k( dDevicesSize / sizeof( LPVOID ) ); k >= 0; k-- )
|
||||
{
|
||||
memset( szCurrentDeviceName, 0, 1024*sizeof(char) );
|
||||
memset( tszCurrentDeviceName, 0, 1024*sizeof(TCHAR) );
|
||||
|
||||
if( 0 != GetDeviceDriverBaseName( lpDevices[ k ], tszCurrentDeviceName, dNameSize ) )
|
||||
{
|
||||
sprintf( szCurrentDeviceName, "%S", tszCurrentDeviceName );
|
||||
|
||||
if( 0 == strcmp( strlwr( szCurrentDeviceName ), szDeviceName ) )
|
||||
{
|
||||
FreePSAPIRoutines();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// free PSAPI routines
|
||||
//
|
||||
FreePSAPIRoutines();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
extern "C" __declspec(dllexport) void FindProcess( HWND hwndParent,
|
||||
int string_size,
|
||||
char *variables,
|
||||
stack_t **stacktop )
|
||||
{
|
||||
char szParameter[ 1024 ];
|
||||
|
||||
|
||||
g_hwndParent = hwndParent;
|
||||
|
||||
EXDLL_INIT();
|
||||
{
|
||||
popstring( szParameter );
|
||||
|
||||
if( true == FindProc( szParameter ) )
|
||||
wsprintf( szParameter, "1" );
|
||||
else
|
||||
wsprintf( szParameter, "0" );
|
||||
|
||||
setuservariable( INST_R0, szParameter );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
extern "C" __declspec(dllexport) void KillProcess( HWND hwndParent,
|
||||
int string_size,
|
||||
char *variables,
|
||||
stack_t **stacktop )
|
||||
{
|
||||
char szParameter[ 1024 ];
|
||||
|
||||
|
||||
g_hwndParent = hwndParent;
|
||||
|
||||
EXDLL_INIT();
|
||||
{
|
||||
popstring( szParameter );
|
||||
|
||||
if( true == KillProc( szParameter ) )
|
||||
wsprintf( szParameter, "1" );
|
||||
else
|
||||
wsprintf( szParameter, "0" );
|
||||
|
||||
setuservariable( INST_R0, szParameter );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
extern "C" __declspec(dllexport) void FindDevice( HWND hwndParent,
|
||||
int string_size,
|
||||
char *variables,
|
||||
stack_t **stacktop )
|
||||
{
|
||||
char szParameter[ 1024 ];
|
||||
|
||||
|
||||
g_hwndParent = hwndParent;
|
||||
|
||||
EXDLL_INIT();
|
||||
{
|
||||
popstring( szParameter );
|
||||
|
||||
if( true == FindDev( szParameter ) )
|
||||
wsprintf( szParameter, "1" );
|
||||
else
|
||||
wsprintf( szParameter, "0" );
|
||||
|
||||
setuservariable( INST_R0, szParameter );
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// PSAPI function pointers
|
||||
typedef BOOL (WINAPI *lpfEnumProcesses) ( DWORD *, DWORD, DWORD * );
|
||||
typedef BOOL (WINAPI *lpfEnumProcessModules) ( HANDLE, HMODULE *, DWORD, LPDWORD );
|
||||
typedef DWORD (WINAPI *lpfGetModuleBaseName) ( HANDLE, HMODULE, LPTSTR, DWORD );
|
||||
typedef BOOL (WINAPI *lpfEnumDeviceDrivers) ( LPVOID *, DWORD, LPDWORD );
|
||||
typedef BOOL (WINAPI *lpfGetDeviceDriverBaseName)( LPVOID, LPTSTR, DWORD );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// Internal use routines
|
||||
bool LoadPSAPIRoutines( void );
|
||||
bool FreePSAPIRoutines( void );
|
||||
|
||||
bool FindProc( char *szProcess );
|
||||
bool KillProc( char *szProcess );
|
||||
|
||||
bool FindDev( char *szDriverName );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// Exported routines
|
||||
extern "C" __declspec(dllexport) void FindProcess( HWND hwndParent,
|
||||
int string_size,
|
||||
char *variables,
|
||||
stack_t **stacktop );
|
||||
|
||||
extern "C" __declspec(dllexport) void KillProcess( HWND hwndParent,
|
||||
int string_size,
|
||||
char *variables,
|
||||
stack_t **stacktop );
|
||||
|
||||
extern "C" __declspec(dllexport) void FindDevice( HWND hwndParent,
|
||||
int string_size,
|
||||
char *variables,
|
||||
stack_t **stacktop );
|
||||
Binary file not shown.
@@ -1,103 +0,0 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "NSIS Plug-in for Windows process management. Only WinNT, Win2K, WinXP and Win2003 Server supported."
|
||||
VALUE "CompanyName", "Andrei Ciubotaru [Hardwired]"
|
||||
VALUE "FileDescription", "Windows Processes Management"
|
||||
VALUE "FileVersion", "1, 0, 0, 1"
|
||||
VALUE "InternalName", "Processes"
|
||||
VALUE "LegalCopyright", "Copyright (c) 2004 Hardwired. No rights reserved."
|
||||
VALUE "OriginalFilename", "Processes.dll"
|
||||
VALUE "ProductName", "Processes"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "processes", "processes.vcproj", "{3438467F-A719-46DC-93E5-137A8B691727}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{3438467F-A719-46DC-93E5-137A8B691727}.Debug.ActiveCfg = Debug|Win32
|
||||
{3438467F-A719-46DC-93E5-137A8B691727}.Debug.Build.0 = Debug|Win32
|
||||
{3438467F-A719-46DC-93E5-137A8B691727}.Release.ActiveCfg = Release|Win32
|
||||
{3438467F-A719-46DC-93E5-137A8B691727}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,122 +0,0 @@
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
Processes (Processes.dll)
|
||||
Version: 1.0.0.1
|
||||
Release: 12.december.2004
|
||||
Description:Nullsoft Installer (NSIS) plug-in for managing?!
|
||||
Windows processes.
|
||||
|
||||
Copyright: © 2004 Hardwired. No rights reserved.
|
||||
There is no restriction and no guaranty for using
|
||||
this software.
|
||||
|
||||
Author: Andrei Ciubotaru [Hardwired]
|
||||
Lead Developer ICode&Ideas SRL (http://www.icode.ro)
|
||||
hardwiredteks@gmail.com, hardwired@icode.ro
|
||||
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
INTRODUCTION
|
||||
|
||||
The Need For Plug-in - I need it for the one of my installers.
|
||||
|
||||
Briefly: Use it when you need to find\kill a process when
|
||||
installing\uninstalling some application. Also, use it when you
|
||||
need to test the presence of a device driver.
|
||||
|
||||
|
||||
SUPPORT
|
||||
|
||||
Supported platforms are: WinNT,Win2K,WinXP and Win2003 Server.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Processes::FindProcess <process_name.exe>
|
||||
|
||||
Searches the currently running processes for the given
|
||||
process name.
|
||||
|
||||
return: 1 - the process was found
|
||||
0 - the process was not found
|
||||
|
||||
Processes::KillProcess <process_name.exe>
|
||||
|
||||
Searches the currently running processes for the given
|
||||
process name. If the process is found then the it gets
|
||||
killed.
|
||||
|
||||
return: 1 - the process was found and killed
|
||||
0 - the process was not found or the process
|
||||
cannot be killed (insuficient rights)
|
||||
|
||||
Processes::FindDevice <device_base_name>
|
||||
|
||||
Searches the installed devices drivers for the given
|
||||
device base name.
|
||||
(important: I said BASE NAME not FILENAME)
|
||||
|
||||
return: 1 - the device driver was found
|
||||
0 - the device driver was not found
|
||||
|
||||
|
||||
USAGE
|
||||
|
||||
First of all, does not matter where you use it. Ofcourse, the
|
||||
routines must be called inside of a Section/Function scope.
|
||||
|
||||
Processes::FindProcess "process_name.exe"
|
||||
Pop $R0
|
||||
|
||||
StrCmp $R0 "1" make_my_day noooooo
|
||||
|
||||
make_my_day:
|
||||
...
|
||||
|
||||
noooooo:
|
||||
...
|
||||
|
||||
|
||||
Processes::KillProcess "process_name.exe"
|
||||
Pop $R0
|
||||
|
||||
StrCmp $R0 "1" dead_meat why_wont_you_die
|
||||
|
||||
dead_meat:
|
||||
...
|
||||
|
||||
why_wont_you_die:
|
||||
...
|
||||
|
||||
|
||||
Processes::FindDevice "device_base_name"
|
||||
Pop $R0
|
||||
|
||||
StrCmp $R0 "1" blabla more_blabla
|
||||
|
||||
blabla:
|
||||
...
|
||||
|
||||
more_blabla:
|
||||
...
|
||||
|
||||
|
||||
THANKS
|
||||
|
||||
Sunil Kamath for inspiring me. I wanted to use its FindProcDLL
|
||||
but my requirements made it imposible.
|
||||
|
||||
Nullsoft for creating this very powerfull installer. One big,
|
||||
free and full-featured (hmmm... and guiless for the moment) mean
|
||||
install machine!:)
|
||||
|
||||
ME for being such a great coder...
|
||||
... HAHAHAHAHAHAHA!
|
||||
|
||||
ONE MORE THING
|
||||
|
||||
If you use the plugin or it's source-code, I would apreciate
|
||||
if my name is mentioned.
|
||||
|
||||
----------------------------------------------------------------
|
||||
----------------------------------------------------------------
|
||||
@@ -1,222 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="processes"
|
||||
SccProjectName="processes"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FINDPROCDLL_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="3"
|
||||
PrecompiledHeaderThrough="stdafx.h"
|
||||
PrecompiledHeaderFile=".\Debug/processes.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\Debug/processes.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Debug/processes.pdb"
|
||||
ImportLibrary=".\Debug/processes.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Debug/processes.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1034"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="..\bin"
|
||||
IntermediateDirectory="..\bin\processes"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
GlobalOptimizations="TRUE"
|
||||
InlineFunctionExpansion="1"
|
||||
FavorSizeOrSpeed="1"
|
||||
OptimizeForWindowsApplication="TRUE"
|
||||
PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;FINDPROCDLL_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
StructMemberAlignment="1"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="3"
|
||||
PrecompiledHeaderThrough="stdafx.h"
|
||||
PrecompiledHeaderFile="..\bin\processes/processes.pch"
|
||||
AssemblerListingLocation="..\bin\processes/"
|
||||
ObjectFile="..\bin\processes/"
|
||||
ProgramDataBaseFileName="..\bin\processes/"
|
||||
WarningLevel="4"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="libc.lib"
|
||||
OutputFile="..\bin/Processes.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
IgnoreAllDefaultLibraries="FALSE"
|
||||
ProgramDatabaseFile="..\bin/processes.pdb"
|
||||
OptimizeForWindows98="1"
|
||||
ImportLibrary="..\bin/processes.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Release/processes.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
<File
|
||||
RelativePath="processes.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;FINDPROCDLL_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="1"
|
||||
PreprocessorDefinitions="NDEBUG;_WINDOWS;_MBCS;_USRDLL;FINDPROCDLL_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\processes.rc">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="StdAfx.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;FINDPROCDLL_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="1"
|
||||
PreprocessorDefinitions="NDEBUG;_WINDOWS;_MBCS;_USRDLL;FINDPROCDLL_EXPORTS;$(NoInherit)"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath="exdll.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\processes.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\resource.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="StdAfx.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="processes.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -1,15 +0,0 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by processes.rc
|
||||
//
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,102 +0,0 @@
|
||||
History:
|
||||
--------
|
||||
|
||||
v0.0.11d - 20090705 (AndersK)
|
||||
*Fixed UAC_RealWorldFullyLoadedDualModeExample.nsi so installing as admin will allow both modes
|
||||
|
||||
v0.0.11c - 20090124 (AndersK)
|
||||
*Checks for seclogon service on NT5 and returns ERROR_SERVICE_NOT_ACTIVE in $0 if not running
|
||||
|
||||
v0.0.11b - 20090102 (AndersK)
|
||||
*Fixed unicode compile bugs
|
||||
|
||||
v0.0.11 - 20081021 (AndersK)
|
||||
+Added UAC_GetUserShellFolderPath.nsi (Uses the new UAC::GetShellFolderPath)
|
||||
|
||||
v0.0.10a - 20081004 (AndersK)
|
||||
+Added SEE_MASK_NOZONECHECKS flag (experimental)
|
||||
|
||||
v0.0.10 - 20080812 (AndersK)
|
||||
+Added ugly hook hack to the shells run-as dialog on xp, defaults to other user
|
||||
|
||||
v0.0.9 - 20080721 (AndersK)
|
||||
*Fixed UAC_RealWorldFullyLoadedDualModeExample.nsi related bug (Thanks Case)
|
||||
|
||||
v0.0.8 - 20080310 (AndersK)
|
||||
+HTML Readme
|
||||
+Added UAC::GetOuterHwnd (used by UAC_RealWorldFullyLoadedDualModeExample.nsi)
|
||||
*Fixed UAC_RealWorldFullyLoadedDualModeExample.nsi
|
||||
*Major code cleanup in UAC.cpp
|
||||
-Removed UAC::RunElevatedAndProcessMessages (UAC::RunElevated now supports non NULL $HWNDParent)
|
||||
-Removed several useless sample scripts
|
||||
|
||||
v0.0.7e - 20080229 (AndersK)
|
||||
*Added ugly hack for hackwnd to find correct title and give us a proper taskbar so the elevation dialog does not get lost (2000,XP (This also fixed Alt-Tab icon on Vista))
|
||||
*Should compile with MSVC2005 now (Thanks Case)
|
||||
*More unicode fixes, this time even tested with NSIS Unicode (Only RunElevated and Exec tested)
|
||||
|
||||
v0.0.7d - 20080226 (AndersK)
|
||||
*Fixed a couple of unicode version bugs (Unicode version still untested)
|
||||
*Fixed weird XP string length bug (Thanks kfank)
|
||||
|
||||
v0.0.7c - 20080218 (AndersK)
|
||||
*Fixed SyncVars string length bug
|
||||
|
||||
v0.0.7b - 20080205 (AndersK)
|
||||
*Fixed DelayLoadDlls() problem on NT4
|
||||
|
||||
v0.0.7 - 20080120 (AndersK)
|
||||
+Added UAC::StackPush (For use with ExecCodeSegment)
|
||||
|
||||
v0.0.6d - 20071108 (AndersK)
|
||||
+Now syncs basic registers/variables before calling UAC::*Exec* and UAC::ExecCodeSegment (r0-r9,R0-R9,$CMDLINE,$INSTDIR,$OUTDIR,$EXEDIR,$LANGUAGE)
|
||||
+Added UAC::RunElevatedAndProcessMessages, this can be called after .onInit (Very experimental, DO NOT USE)
|
||||
+New include file with helper macros: UAC.nsh
|
||||
*Replazed Clammerz hack with a better version
|
||||
|
||||
v0.0.6c - 20071014 (AndersK)
|
||||
+Check for and split up "domain\user" style input in RunAs.cpp for CreateProcessWithLogonW
|
||||
*Added a ugly hack to trick messagebox'es in .OnInit to appear correctly on Vista (Thanks Clammerz)
|
||||
|
||||
v0.0.6b - 20070523 (AndersK)
|
||||
*Fixed showwindow flag (Thanks for the help kichik)
|
||||
|
||||
v0.0.6 - 20070512 (AndersK)
|
||||
+Added basic language support for MyRunAs dialog.
|
||||
|
||||
v0.0.5e - 20070509 (AndersK)
|
||||
*Fixed detection of UAC mode?
|
||||
+IPC window is visible (but offscreen) during elevation to help with SetForegroundWindow/Focus problems
|
||||
|
||||
v0.0.5d - 20070324 (AndersK)
|
||||
*Fixed stupid IsAdmin bug
|
||||
|
||||
v0.0.5c - 20070304 (AndersK)
|
||||
*_IsAdmin now uses CheckTokenMembership if it exists ( MSKB:Q118626 / http://blogs.msdn.com/larryosterman/archive/2007/03/14/why-does-kb-118626-use-accesscheck-to-check-if-you-re-a-member-of-the-administrators-group.aspx )
|
||||
|
||||
v0.0.5b - 20070301 (AndersK)
|
||||
*Fixed ExecCodeSegment (Thread now calls CoInitialize)
|
||||
|
||||
v0.0.5 - 20070228 (AndersK)
|
||||
+Added ExecCodeSegment (You can now call ANY code in the context of the original user)
|
||||
|
||||
v0.0.4b - 20070226 (AndersK)
|
||||
*Fixed (My)RunAs font (http://blogs.msdn.com/oldnewthing/archive/2005/02/04/366987.aspx)
|
||||
|
||||
v0.0.4 - 20070225 (AndersK)
|
||||
+Added (My)RunAs dialog, used on Vista when running as LUA with UAC off
|
||||
+Always uses /NCRC for elevated instance
|
||||
*Now compiles as UNICODE (Untested, no UnicodeNSIS to test on)
|
||||
|
||||
v0.0.3 - 20070224 (AndersK)
|
||||
+Added Exec/ExecWait
|
||||
+Added Verb & ShowWindow support for ShellExec[Wait]
|
||||
|
||||
v0.0.2 - 20070219 (AndersK)
|
||||
+Added ShellExecWait
|
||||
*IPC srv wnd now has its own thread and msg loop
|
||||
*Removed CRT dependency
|
||||
*Hopefully loads on Win95 now
|
||||
|
||||
v0.0.1 - 20070215 (AndersK)
|
||||
*Initial release
|
||||
@@ -1,14 +0,0 @@
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
|
||||
ZLIB/LIBPNG LICENSE
|
||||
-------------------
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
@@ -1,149 +0,0 @@
|
||||
/*
|
||||
Alternative to ExDll.h
|
||||
|
||||
v0.0.1 - 20060811 (AndersK)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <TChar.h>
|
||||
|
||||
|
||||
typedef TCHAR NSISCH;
|
||||
#define NSISCALL __stdcall
|
||||
|
||||
namespace NSIS {
|
||||
|
||||
__forceinline void* NSISCALL MemAlloc(SIZE_T cb) {return GlobalAlloc(LPTR,cb);}
|
||||
__forceinline void NSISCALL MemFree(void* p) {GlobalFree(p);}
|
||||
|
||||
enum {
|
||||
INST_0, // $0
|
||||
INST_1, // $1
|
||||
INST_2, // $2
|
||||
INST_3, // $3
|
||||
INST_4, // $4
|
||||
INST_5, // $5
|
||||
INST_6, // $6
|
||||
INST_7, // $7
|
||||
INST_8, // $8
|
||||
INST_9, // $9
|
||||
INST_R0, // $R0
|
||||
INST_R1, // $R1
|
||||
INST_R2, // $R2
|
||||
INST_R3, // $R3
|
||||
INST_R4, // $R4
|
||||
INST_R5, // $R5
|
||||
INST_R6, // $R6
|
||||
INST_R7, // $R7
|
||||
INST_R8, // $R8
|
||||
INST_R9, // $R9
|
||||
INST_CMDLINE, // $CMDLINE
|
||||
INST_INSTDIR, // $INSTDIR
|
||||
INST_OUTDIR, // $OUTDIR
|
||||
INST_EXEDIR, // $EXEDIR
|
||||
INST_LANG, // $LANGUAGE
|
||||
__INST_LAST,
|
||||
|
||||
VIDX_TEMP=(INST_LANG+1), //#define state_temp_dir g_usrvars[25]
|
||||
VIDX_PLUGINSDIR,//# define state_plugins_dir g_usrvars[26]
|
||||
VIDX_EXEPATH,//#define state_exe_path g_usrvars[27]
|
||||
VIDX_EXEFILENAME,//#define state_exe_file g_usrvars[28]
|
||||
VIDX_STATECLICKNEXT,//#define state_click_next g_usrvars[30]
|
||||
__VIDX_UNDOCLAST
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef struct _stack_t {
|
||||
struct _stack_t *next;
|
||||
NSISCH text[ANYSIZE_ARRAY];
|
||||
} stack_t;
|
||||
|
||||
typedef struct {
|
||||
int autoclose;
|
||||
int all_user_var;
|
||||
int exec_error;
|
||||
int abort;
|
||||
int exec_reboot;
|
||||
int reboot_called;
|
||||
int XXX_cur_insttype; // deprecated
|
||||
int XXX_insttype_changed; // deprecated
|
||||
int silent;
|
||||
int instdir_error;
|
||||
int rtl;
|
||||
int errlvl;
|
||||
//NSIS v2.3x ?
|
||||
int alter_reg_view;
|
||||
int status_update;
|
||||
} exec_flags_type;
|
||||
|
||||
typedef struct {
|
||||
exec_flags_type *exec_flags;
|
||||
int (NSISCALL *ExecuteCodeSegment)(int, HWND);
|
||||
void (NSISCALL *validate_filename)(char *);
|
||||
} extra_parameters;
|
||||
|
||||
extern UINT StrSize;
|
||||
extern stack_t **StackTop;
|
||||
extern NSISCH*Vars;
|
||||
|
||||
inline bool NSISCALL SetErrLvl(extra_parameters*pExtraParams,int ErrLevel) {return pExtraParams? ((pExtraParams->exec_flags->errlvl=ErrLevel)||true):false;}
|
||||
inline bool NSISCALL SetErrorFlag(extra_parameters*pExtraParams) {return pExtraParams? ((pExtraParams->exec_flags->exec_error=1)||true):false;}
|
||||
inline bool NSISCALL ClearErrorFlag(extra_parameters*pExtraParams) {return pExtraParams?((pExtraParams->exec_flags->exec_error=0)||true):false;}
|
||||
|
||||
__forceinline int NSISCALL ExecuteCodeSegment(extra_parameters*pExtraParams,int pos,HWND hwndProgress=NULL) {
|
||||
return pExtraParams?pExtraParams->ExecuteCodeSegment(pos,hwndProgress):(/*EXEC_ERROR*/0x7FFFFFFF);
|
||||
}
|
||||
|
||||
static NSISCH* __fastcall GetVar(const int varnum)
|
||||
{
|
||||
//ASSERT(NSIS::Vars && NSIS::StrSize);
|
||||
if (varnum < 0 || varnum >= __VIDX_UNDOCLAST) return NULL;
|
||||
return NSIS::Vars+(varnum*NSIS::StrSize);
|
||||
}
|
||||
|
||||
inline void NSISCALL SetVarUINT(const int varnum,UINT Value) {
|
||||
wsprintf(GetVar(varnum),_T("%u"),Value);
|
||||
}
|
||||
|
||||
static stack_t* NSISCALL StackPop() {
|
||||
if (NSIS::StackTop && *NSIS::StackTop) {
|
||||
stack_t*s=(*NSIS::StackTop);
|
||||
*NSIS::StackTop=(*NSIS::StackTop)->next;
|
||||
return s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
__forceinline void NSISCALL StackFreeItem(stack_t*pStackItem) {NSIS::MemFree(pStackItem);}
|
||||
|
||||
static DWORD NSISCALL StackPush(NSISCH*InStr,UINT StackStrSize=NSIS::StrSize) {
|
||||
if (!NSIS::StackTop)return ERROR_INVALID_PARAMETER;
|
||||
stack_t*sNew=(stack_t*)NSIS::MemAlloc(sizeof(stack_t)+(StackStrSize*sizeof(NSISCH)));
|
||||
if (!sNew)return ERROR_OUTOFMEMORY;
|
||||
lstrcpyn(sNew->text,InStr,StackStrSize);
|
||||
sNew->next=*NSIS::StackTop;
|
||||
*NSIS::StackTop=sNew;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
}; /* namespace */
|
||||
|
||||
#define NSISUTIL_INIT() namespace NSIS {static UINT StrSize;static stack_t **StackTop;static NSISCH*Vars;}//Call in only ONE source file
|
||||
#define NSISUTIL_INITEXPORT(_v,_strsize,_stackt) NSIS::Vars=_v;NSIS::StrSize=_strsize;NSIS::StackTop=_stackt
|
||||
|
||||
//#define NSISEXPORT4(_func,_h,_strsize,_v,_stackt) extern "C" void __declspec(dllexport) __cdecl \
|
||||
// _func (HWND _h,int _strsize,NSISCH*_v,NSIS::stack_t **_stackt) { NSISUTIL_INITEXPORT(_v,_strsize,_stackt); TRACE("EXPORT::" #_func "\n");
|
||||
//#define NSISEXPORT5(_func,_h,_strsize,_v,_stackt,_eparams) extern "C" void __declspec(dllexport) __cdecl \
|
||||
// _func (HWND _h,int _strsize,NSISCH*_v,NSIS::stack_t **_stackt,NSIS::extra_parameters* _eparams) { NSISUTIL_INITEXPORT(_v,_strsize,_stackt); TRACE("EXPORT::" #_func "\n");
|
||||
//#define NSISEXPORT NSISEXPORT5
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define EXPORTNSISFUNC extern "C" void __declspec(dllexport) __cdecl
|
||||
# else
|
||||
# error EXPORTNSISFUNC needs compiler goo, you are on your own!
|
||||
# endif
|
||||
#define NSISFUNCSTART4(_h,_strsize,_v,_stackt) {NSISUTIL_INITEXPORT(_v,_strsize,_stackt);
|
||||
#define NSISFUNCSTART5(_h,_strsize,_v,_stackt,_eparams) NSISFUNCSTART4(_h,_strsize,_v,_stackt)
|
||||
#define NSISFUNCSTART NSISFUNCSTART5
|
||||
#define NSISFUNCEND() }
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,277 +0,0 @@
|
||||
//Copyright (C) 2007 Anders Kjersem. Licensed under the zlib/libpng license, see License.txt for details.
|
||||
/*
|
||||
If UAC is disabled, the runas verb is broken (Vista RTM) so when running as LUA there is no way to elevate so
|
||||
we provide our own dialog.
|
||||
*/
|
||||
|
||||
#include "UAC.h"
|
||||
#ifdef FEAT_CUSTOMRUNASDLG
|
||||
#include <Lmcons.h>//UNLEN && GNLEN && PWLEN
|
||||
#include <WindowsX.h>
|
||||
#include "resource.h"
|
||||
#include "NSISUtil.h"
|
||||
using namespace NSIS;
|
||||
#define ERRAPP_TRYAGAIN (0x20000000|1)
|
||||
#define MYMAX_DOMAIN (2+max(GNLEN,MAX_COMPUTERNAME_LENGTH)+1)
|
||||
|
||||
|
||||
static LPCTSTR g_RunAsDlgTitle=_T("Run as");
|
||||
static LPCTSTR g_RunAsHelpText=_T("You may not have the necessary permissions to use all the features of the program you are about to run. You may run this program as a different user or continue to run the program as the current user.");
|
||||
static LPCTSTR g_RunAsCurrUsrFmt=_T("&Current user (%s)");//Max 50 chars!
|
||||
static LPCTSTR g_RunAsSpecHelp=_T("Run the program as the &following user:");
|
||||
|
||||
FORCEINLINE bool MySetDlgItemText(HWND hDlg,int id,LPCTSTR s) {return MySndDlgItemMsg(hDlg,id,WM_SETTEXT,0,(LPARAM)s)!=0;}
|
||||
|
||||
typedef struct {
|
||||
SHELLEXECUTEINFO*pSEI;
|
||||
bool AsSelf;
|
||||
} RUNASDLGDATA;
|
||||
|
||||
void MyRunAsFmtCurrUserRadio(HWND hDlg,LPCTSTR Fmt) {
|
||||
TCHAR bufFullName[MYMAX_DOMAIN+UNLEN+1];
|
||||
TCHAR buf[50+MYMAX_DOMAIN+UNLEN+1];
|
||||
*bufFullName=0;
|
||||
ULONG cch;
|
||||
if ((!_GetUserNameEx || !_GetUserNameEx(NameSamCompatible,bufFullName,&(cch=COUNTOF(bufFullName)))) &&
|
||||
!_GetUserName(bufFullName,&(cch=COUNTOF(bufFullName))) ) {
|
||||
*bufFullName=0;
|
||||
}
|
||||
wsprintf(buf,Fmt,*bufFullName?bufFullName:_T("?"));
|
||||
MySetDlgItemText(hDlg,IDC_RUNASCURR,buf);
|
||||
|
||||
// default the "User name:" to Administrator from shell32
|
||||
if (LoadString(GetModuleHandle(_T("SHELL32.dll")),21763, bufFullName, COUNTOF(bufFullName)) > 0) {
|
||||
MySetDlgItemText(hDlg,IDC_USERNAME,bufFullName);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_CUSTOMRUNASDLG_TRANSLATE
|
||||
void MyRunAsTranslateDlgString(LPCTSTR StrID,LPTSTR Ini,HWND hDlg,INT_PTR DlgItemId,int special=0) {
|
||||
TCHAR buf[MAX_PATH*2];
|
||||
DWORD len=GetPrivateProfileString(_T("MyRunAsStrings"),StrID,0,buf,ARRAYSIZE(buf),Ini);
|
||||
if (len) {
|
||||
if (IDC_RUNASCURR==special)
|
||||
MyRunAsFmtCurrUserRadio(hDlg,buf);
|
||||
else
|
||||
(DlgItemId==-1) ? SetWindowText(hDlg,buf) : MySetDlgItemText(hDlg,DlgItemId,buf);
|
||||
}
|
||||
}
|
||||
|
||||
void MyRunAsTranslateDlg(HWND hDlg) {
|
||||
DWORD len;
|
||||
TCHAR buf[MAX_PATH*2];
|
||||
HMODULE hDll=GetWindowInstance(hDlg);ASSERT(hDll);
|
||||
if ( (len=GetModuleFileName(hDll,buf,ARRAYSIZE(buf))) <1)return;
|
||||
buf[len-3]=0;
|
||||
lstrcat(buf,_T("lng"));
|
||||
MyRunAsTranslateDlgString(_T("DlgTitle"),buf,hDlg,-1);
|
||||
MyRunAsTranslateDlgString(_T("HelpText"),buf,hDlg,IDC_HELPTEXT);
|
||||
MyRunAsTranslateDlgString(_T("OptCurrUser"),buf,hDlg,IDC_RUNASCURR,IDC_RUNASCURR);
|
||||
MyRunAsTranslateDlgString(_T("OptOtherUser"),buf,hDlg,IDC_RUNASSPEC);
|
||||
MyRunAsTranslateDlgString(_T("Username"),buf,hDlg,IDC_LBLUSER);
|
||||
MyRunAsTranslateDlgString(_T("Pwd"),buf,hDlg,IDC_LBLPWD);
|
||||
MyRunAsTranslateDlgString(_T("OK"),buf,hDlg,IDOK);
|
||||
MyRunAsTranslateDlgString(_T("Cancel"),buf,hDlg,IDCANCEL);
|
||||
HWND h=GetDlgItem(hDlg,IDC_RUNASCURR);
|
||||
if (GetPrivateProfileInt(_T("MyRunAsCfg"),_T("DisableCurrUserOpt"),false,buf))EnableWindow(h,false);
|
||||
if (GetPrivateProfileInt(_T("MyRunAsCfg"),_T("HideCurrUserOpt"),false,buf))ShowWindow(h,false);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool ErrorIsLogonError(DWORD err) {
|
||||
switch (err) {
|
||||
case ERROR_LOGON_FAILURE:
|
||||
case ERROR_ACCOUNT_RESTRICTION:
|
||||
case ERROR_INVALID_LOGON_HOURS:
|
||||
case ERROR_INVALID_WORKSTATION:
|
||||
case ERROR_PASSWORD_EXPIRED:
|
||||
case ERROR_ACCOUNT_DISABLED:
|
||||
case ERROR_NONE_MAPPED:
|
||||
case ERROR_NO_SUCH_USER:
|
||||
case ERROR_INVALID_ACCOUNT_NAME:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VerifyOKBtn(HWND hDlg,RUNASDLGDATA*pRADD) {
|
||||
const bool HasText=pRADD?(pRADD->AsSelf?true:MySndDlgItemMsg(hDlg,IDC_USERNAME,WM_GETTEXTLENGTH)>0):false;
|
||||
EnableWindow(GetDlgItem(hDlg,IDOK),HasText);
|
||||
}
|
||||
|
||||
void SetDlgState(HWND hDlg,bool AsSelf,RUNASDLGDATA*pRADD) {
|
||||
if (pRADD)pRADD->AsSelf=AsSelf;
|
||||
MySndDlgItemMsg(hDlg,IDC_RUNASCURR,BM_SETCHECK,AsSelf?BST_CHECKED:BST_UNCHECKED);
|
||||
MySndDlgItemMsg(hDlg,IDC_RUNASSPEC,BM_SETCHECK,!AsSelf?BST_CHECKED:BST_UNCHECKED);
|
||||
int ids[]={IDC_USERNAME,IDC_PASSWORD,IDC_LBLUSER,IDC_LBLPWD};
|
||||
for (int i=0; i<COUNTOF(ids);++i)EnableWindow(GetDlgItem(hDlg,ids[i]),!AsSelf);
|
||||
VerifyOKBtn(hDlg,pRADD);
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK MyRunAsDlgProc(HWND hwnd,UINT uMsg,WPARAM wp,LPARAM lp) {
|
||||
RUNASDLGDATA*pRADD=(RUNASDLGDATA*)GetWindowLongPtr(hwnd,GWLP_USERDATA);
|
||||
switch(uMsg) {
|
||||
//case WM_DESTROY:
|
||||
// break;
|
||||
case WM_CLOSE:
|
||||
return DestroyWindow(hwnd);
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
pRADD=(RUNASDLGDATA*)lp;ASSERT(pRADD);
|
||||
SetWindowLongPtr(hwnd,GWLP_USERDATA,lp);
|
||||
Edit_LimitText(GetDlgItem(hwnd,IDC_USERNAME),UNLEN+1+MYMAX_DOMAIN); //room for "foo@BAR" or "BAR\foo"
|
||||
Edit_LimitText(GetDlgItem(hwnd,IDC_PASSWORD),PWLEN);
|
||||
const HINSTANCE hSh32=GetModuleHandle(_T("SHELL32.dll"));
|
||||
const HICON hIco=(HICON)LoadImage(hSh32,MAKEINTRESOURCE(194),IMAGE_ICON,32,32,LR_SHARED);
|
||||
MySndDlgItemMsg(hwnd,IDC_SHICON,STM_SETICON,(WPARAM)hIco);
|
||||
SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)g_RunAsDlgTitle);
|
||||
MySetDlgItemText(hwnd,IDC_HELPTEXT,g_RunAsHelpText);
|
||||
MyRunAsFmtCurrUserRadio(hwnd,g_RunAsCurrUsrFmt);
|
||||
MySetDlgItemText(hwnd,IDC_RUNASSPEC,g_RunAsSpecHelp);
|
||||
#ifdef FEAT_CUSTOMRUNASDLG_TRANSLATE
|
||||
MyRunAsTranslateDlg(hwnd);
|
||||
#endif
|
||||
SetDlgState(hwnd,false,pRADD);
|
||||
|
||||
#if defined(BUILD_DBG) && 0 //auto login used during testing ;)
|
||||
SetDlgItemText(hwnd,IDC_USERNAME,_T("root"));
|
||||
SetDlgItemText(hwnd,IDC_PASSWORD,_T("???"));
|
||||
Sleep(1);PostMessage(hwnd,WM_COMMAND,IDOK,0);
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch(HIWORD(wp)) {
|
||||
case EN_CHANGE:
|
||||
VerifyOKBtn(hwnd,pRADD);
|
||||
break;
|
||||
case EN_SETFOCUS:
|
||||
case BN_CLICKED:
|
||||
if (LOWORD(wp)<=IDCANCEL)break;
|
||||
SetDlgState(hwnd,LOWORD(wp)==IDC_RUNASCURR,pRADD);
|
||||
return FALSE;
|
||||
}
|
||||
INT_PTR exitcode=!pRADD?-1:IDCANCEL;
|
||||
switch(LOWORD(wp)) {
|
||||
case IDOK:
|
||||
if (pRADD) {
|
||||
SHELLEXECUTEINFO&sei=*pRADD->pSEI;
|
||||
PROCESS_INFORMATION pi={0};
|
||||
DWORD ec=NO_ERROR;
|
||||
WCHAR*wszExec;//Also used as TCHAR buffer in AsSelf mode
|
||||
bool PerformTCharFmt=pRADD->AsSelf;
|
||||
//const DWORD CommonStartupInfoFlags=STARTF_FORCEONFEEDBACK;
|
||||
#ifdef UNICODE
|
||||
PerformTCharFmt=true;
|
||||
#endif
|
||||
wszExec=(WCHAR*)NSIS::MemAlloc( (pRADD->AsSelf?sizeof(TCHAR):sizeof(WCHAR)) *(lstrlen(sei.lpFile)+1+lstrlen(sei.lpParameters)+1));
|
||||
if (!wszExec)ec=ERROR_OUTOFMEMORY;
|
||||
if (PerformTCharFmt)wsprintf((TCHAR*)wszExec,_T("%s%s%s"),sei.lpFile,((sei.lpParameters&&*sei.lpParameters)?_T(" "):_T("")),sei.lpParameters);
|
||||
if (!ec) {
|
||||
if (pRADD->AsSelf) {
|
||||
STARTUPINFO si={sizeof(si)};
|
||||
TRACEF("MyRunAs:CreateProcess:%s|\n",wszExec);
|
||||
ec=(CreateProcess(0,(TCHAR*)wszExec,0,0,false,0,0,0,&si,&pi)?NO_ERROR:GetLastError());
|
||||
}
|
||||
else {
|
||||
//All Wide strings!
|
||||
WCHAR wszPwd[PWLEN+1];
|
||||
WCHAR wszUName[UNLEN+1+MYMAX_DOMAIN+1];
|
||||
STARTUPINFOW siw={sizeof(siw)};
|
||||
WCHAR*p;
|
||||
#ifndef UNICODE
|
||||
//Build unicode string, we already know the buffer is big enough so no error handling
|
||||
p=wszExec;
|
||||
MultiByteToWideChar(CP_THREAD_ACP,0,sei.lpFile,-1,p,0xFFFFFF);
|
||||
if (sei.lpParameters && *sei.lpParameters) {
|
||||
p+=lstrlen(sei.lpFile);*p++=L' ';*p=0;
|
||||
MultiByteToWideChar(CP_THREAD_ACP,0,sei.lpParameters,-1,p,0xFFFFFF);
|
||||
}
|
||||
#endif
|
||||
SendMessageW(GetDlgItem(hwnd,IDC_USERNAME),WM_GETTEXT,COUNTOF(wszUName),(LPARAM)wszUName);
|
||||
SendMessageW(GetDlgItem(hwnd,IDC_PASSWORD),WM_GETTEXT,COUNTOF(wszPwd),(LPARAM)wszPwd);
|
||||
|
||||
//Try to find [\\]domain\user and split into username and domain strings
|
||||
WCHAR*pUName=wszUName,*pDomain=0;
|
||||
p=wszUName;
|
||||
//if (*p==p[1]=='\\')pUName=(p+=2);else \ //Should we still split things up if the string starts with \\ ? Is it possible to use \\machine\user at all?
|
||||
++p;//Don't parse "\something", require at least one char before backslash "?[*\]something"
|
||||
while(*p && *p!='\\')++p;
|
||||
if (*p=='\\') {
|
||||
pDomain=pUName;
|
||||
pUName=p+1;*p=0;
|
||||
}
|
||||
|
||||
TRACEF("MyRunAs:CreateProcessWithLogonW:%ws|%ws|%ws|%ws|\n",pUName,pDomain?pDomain:L"NO?DOMAIN",wszPwd,wszExec);
|
||||
ec=(_CreateProcessWithLogonW(pUName,pDomain?pDomain:0,wszPwd,LOGON_WITH_PROFILE,0,wszExec,0,0,0,&siw,&pi)?NO_ERROR:GetLastError());
|
||||
TRACEF("MyRunAs:CreateProcessWithLogonW: ret=%u\n",ec);
|
||||
SecureZeroMemory(wszPwd,sizeof(wszPwd));//if (wszPwd) {volatile WCHAR*_p=wszPwd;for(;_p&&*_p;++_p)*_p=1;if (_p)*wszPwd=0;}//Burn password (And attempt to prevent compiler from removing it)
|
||||
if (ec && ErrorIsLogonError(ec)) {
|
||||
LPTSTR szMsg;
|
||||
DWORD ret=FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,0,ec,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),(LPTSTR)&szMsg,0,0);
|
||||
if (ret) {
|
||||
ec=ERRAPP_TRYAGAIN;
|
||||
MessageBox(hwnd,szMsg,0,MB_ICONWARNING);
|
||||
LocalFree(szMsg);
|
||||
}
|
||||
else ec=GetLastError();
|
||||
}
|
||||
}
|
||||
}
|
||||
NSIS::MemFree(wszExec);
|
||||
if (pi.hThread)CloseHandle(pi.hThread);
|
||||
if (ERRAPP_TRYAGAIN==ec)break;
|
||||
if (ec) {
|
||||
SetLastError(ec);
|
||||
exitcode=-1;
|
||||
}
|
||||
else {
|
||||
pRADD->pSEI->hProcess=pi.hProcess;
|
||||
exitcode=IDOK;
|
||||
}
|
||||
}
|
||||
case IDCANCEL:
|
||||
EndDialog(hwnd,exitcode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DWORD MyRunAs(HINSTANCE hInstDll,SHELLEXECUTEINFO&sei) {
|
||||
INT_PTR ec;
|
||||
ASSERT(sei.cbSize>=sizeof(SHELLEXECUTEINFO) && hInstDll);
|
||||
if (ec=DelayLoadDlls())return ec;
|
||||
ASSERT(_CreateProcessWithLogonW && _GetUserName);
|
||||
RUNASDLGDATA radd={0};
|
||||
radd.pSEI=&sei;
|
||||
ec=DialogBoxParam(hInstDll,MAKEINTRESOURCE(IDD_MYRUNAS),sei.hwnd,MyRunAsDlgProc,(LPARAM)&radd);
|
||||
TRACEF("MyRunAs returned %d (%s|%s)\n",ec,sei.lpFile,sei.lpParameters);
|
||||
switch(ec) {
|
||||
case 0:
|
||||
return ERROR_INVALID_HANDLE;//DialogBoxParam returns 0 on bad hwnd
|
||||
case IDOK:
|
||||
return NO_ERROR;
|
||||
case IDCANCEL:
|
||||
return ERROR_CANCELLED;
|
||||
}
|
||||
//TODO:BUGBUG: on vista, the last error seems to get lost, should probably put it in RUNASDLGDATA and always return IDOK
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
|
||||
#ifdef BUILD_DBG
|
||||
// RunDll exports are __stdcall, we dont care about that for this debug export, rundll32.exe is able to handle this mistake
|
||||
extern "C" void __declspec(dllexport) __cdecl DBGRDMyRunAs(HWND hwnd,HINSTANCE hinst,LPTSTR lpCmdLine,int nCmdShow) {
|
||||
SHELLEXECUTEINFO sei={sizeof(sei)};
|
||||
sei.lpFile=_T("Notepad.exe");//sei.lpParameters=_T("param1");
|
||||
TRACEF("ec=%d\n",MyRunAs(GetModuleHandle(_T("UAC.dll")),sei));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FEAT_CUSTOMRUNASDLG */
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html><head>
|
||||
<title>UAC plug-in readme</title>
|
||||
<script type="text/javascript">
|
||||
function NavGL(q){window.open("http://www.google.com/search?hl=en&btnI=I&num=2&q="+escape(q));return 0;}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
html,body {background-color:#FFF; color:#000;}
|
||||
a:link, a:visited, a:active {color:#00F;}
|
||||
h2 {border-bottom:0.1em solid #000;}
|
||||
#docHdrHdln{text-align:center;}
|
||||
.importanttxt {color:#e00;}
|
||||
.code {font-family:monospace;}
|
||||
.nsisvar {color:#C00;}
|
||||
.str {color:#390}
|
||||
.inifile {background-color:#EEE;border:1px solid #000;padding:0.2em;}
|
||||
.inicomment {background-color:#f5f5c5;color:#555;}
|
||||
table.piexport {text-align:left;margin-bottom:1em;}
|
||||
table.piexport td {vertical-align:top;}
|
||||
table.piexport table.ret {padding:0;margin:0;border:0;}
|
||||
</style>
|
||||
</head><body>
|
||||
<h1 id="docHdrHdln">UAC plug-in</h1>
|
||||
|
||||
|
||||
<code><pre>
|
||||
Interactive User (MediumIL) Admin user(HighIL)
|
||||
+++[Setup.exe]++++++++++++++ +++[Setup.exe]++++++++++++++
|
||||
+ + + +
|
||||
+ ***[.OnInit]************ + + ***[.OnInit]************ +
|
||||
+ * UAC::RunElevated >---+-+------>+ * * +
|
||||
+ * NSIS.Quit() * + + * * +
|
||||
+ ************************ + + ***********||*********** +
|
||||
+ + + || +
|
||||
+ + + \/ +
|
||||
+ ***[Sections]*********** + + ***[Sections]*********** +
|
||||
+ * * + /--+-+-< UAC::Exec * +
|
||||
+ ************************ + | + ************************ +
|
||||
+ + | + +
|
||||
+ Win32.CreateProcess() <-+----/ + +
|
||||
+ + + +
|
||||
++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++
|
||||
</pre></code>
|
||||
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#exports">Plugin Functions</a>
|
||||
<li><a href="#lang">Language support</a>
|
||||
<li><a href="#knownissues">Known Issues</a>
|
||||
<li><a href="#glossary">Glossary</a>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="exports"><h2>Plugin Functions</h2></a><div class="CntSec"><p>
|
||||
Every function will try to emulate the basic NSIS instruction (of similar name) when UAC::RunElevated has not "succeeded" or running on a system that does not support elevation (Win9x/NT4)</p>
|
||||
|
||||
<table class="piexport"><tr><th colspan=2>UAC::RunElevated</th></tr>
|
||||
<tr><td>Parameters:</td><td></td></tr>
|
||||
<tr><td>Returns:</td><td>
|
||||
<table class="ret">
|
||||
<tr><td><span class="nsisvar">$0</span></td><td>Win32 error code (0 on success, 1223 if user aborted elevation dialog, anything else should be treated as a fatal error)</td></tr>
|
||||
<tr><td><span class="nsisvar">$1</span></td><td><span class="code">If <span class="nsisvar">$0</span>==0</span>:
|
||||
<table class="ret">
|
||||
<tr><td>0</td><td>UAC is not supported by the OS</td></tr>
|
||||
<tr><td>1</td><td>Started a elevated child process, the current process should act like a wrapper (Call Quit without any further processing)</td></tr>
|
||||
<tr><td>2</td><td>The process is already running @ HighIL (Member of admin group)</td></tr>
|
||||
<tr><td>3</td><td>You should call RunElevated again (This can happen if a user without admin priv. is used in the runas dialog)</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr><td><span class="nsisvar">$2</span></td><td><span class="code">If <span class="nsisvar">$0</span>==0 && <span class="nsisvar">$1</span>==1</span>: ExitCode of the elevated fork process (The NSIS errlvl is also set)</td></tr>
|
||||
<tr><td><span class="nsisvar">$3</span></td><td><span class="code">If <span class="nsisvar">$0</span>==0</span>: 1 if the user is a member of the admin group or 0 otherwise</td></tr>
|
||||
</table></td></tr>
|
||||
<tr><td>Description:</td><td>Allows non-admin/UAC.LUA users to re-spawn the installer as another user and UAC.Admin users to elevate.</td></tr>
|
||||
</table>
|
||||
<!--table class="piexport"><tr><th colspan=2>UAC::RunElevatedAndProcessMessages <i style="font-size:smaller;">(Experimental)</i></th></tr>
|
||||
<tr><td>Parameters:</td><td></td></tr>
|
||||
<tr><td>Returns:</td><td><i>See UAC::RunElevated</i></td></tr>
|
||||
<tr><td>Description:</td><td>Version of UAC::RunElevated that can be called from a page</td></tr>
|
||||
</table-->
|
||||
|
||||
<table class="piexport"><tr><th colspan=2>UAC::Unload</th></tr>
|
||||
<tr><td>Parameters:</td><td></td></tr>
|
||||
<tr><td>Returns:</td><td></td></tr>
|
||||
<tr><td>Description:</td><td>Cleanup, you must call this function in .OnInstFailed, .onUserAbort and .OnInstSuccess</td></tr>
|
||||
</table>
|
||||
|
||||
<table class="piexport"><tr>
|
||||
<th colspan=2>UAC::Exec</th></tr>
|
||||
<tr><td>Parameters:</td><td><INT:ShowWindow> <STR:App> <STR:Parameters> <STR:WorkingDir></td></tr>
|
||||
<tr><td>Returns:</td><td>
|
||||
<table class="ret">
|
||||
<tr><td><span class="nsisvar">$0</span></td><td>Win32 error code, 0 on success (ErrorFlag is also set on error)</td></tr>
|
||||
</table></td></tr>
|
||||
</table>
|
||||
<table class="piexport"><tr>
|
||||
<th colspan=2>UAC::ExecWait</th></tr>
|
||||
<tr><td>Parameters:</td><td><INT:ShowWindow> <STR:App> <STR:Parameters> <STR:WorkingDir></td></tr>
|
||||
<tr><td>Returns:</td><td>
|
||||
<table class="ret">
|
||||
<tr><td><span class="nsisvar">$0</span></td><td>Win32 error code, 0 on success (ErrorFlag is also set on error)</td></tr>
|
||||
<tr><td><span class="nsisvar">$1</span></td><td>Exitcode of new process</td></tr>
|
||||
</table></td></tr>
|
||||
</table>
|
||||
<table class="piexport"><tr>
|
||||
<th colspan=2>UAC::ShellExec</th></tr>
|
||||
<tr><td>Parameters:</td><td><STR:Verb> <INT:ShowWindow> <STR:App> <STR:Parameters> <STR:WorkingDir></td></tr>
|
||||
<tr><td>Returns:</td><td>
|
||||
<table class="ret">
|
||||
<tr><td><span class="nsisvar">$0</span></td><td>Win32 error code, 0 on success (ErrorFlag is also set on error)</td></tr>
|
||||
</table></td></tr>
|
||||
</table>
|
||||
<table class="piexport"><tr>
|
||||
<th colspan=2>UAC::ShellExecWait</th></tr>
|
||||
<tr><td>Parameters:</td><td><STR:Verb> <INT:ShowWindow> <STR:App> <STR:Parameters> <STR:WorkingDir></td></tr>
|
||||
<tr><td>Returns:</td><td>
|
||||
<table class="ret">
|
||||
<tr><td><span class="nsisvar">$0</span></td><td>Win32 error code, 0 on success (ErrorFlag is also set on error)</td></tr>
|
||||
<tr><td><span class="nsisvar">$1</span></td><td>Exitcode of new process</td></tr>
|
||||
</table></td></tr>
|
||||
</table>
|
||||
|
||||
<table class="piexport"><tr><th colspan=2>UAC::IsAdmin</th></tr>
|
||||
<tr><td>Parameters:</td><td></td></tr>
|
||||
<tr><td>Returns:</td><td><span class="nsisvar">$0</span> (BOOL) result</td></tr>
|
||||
<tr><td>Description:</td><td>Check current thread/process token for a non-deny admin group SID entry</td></tr>
|
||||
</table>
|
||||
|
||||
<table class="piexport"><tr><th colspan=2>UAC::ExecCodeSegment</th></tr>
|
||||
<tr><td>Parameters:</td><td><INT:NSISFunctionAddress></td></tr>
|
||||
<tr><td>Returns:</td><td>[None] (ErrorFlag is set on error)</td></tr>
|
||||
<tr><td>Description:</td><td>Calls NSIS function in LUA/outer instance (If you use instructions that alter the UI or the stack/variables in the code segment (StrCpy,Push/Pop/Exch,DetailPrint etc.) they will affect the hidden wrapper installer and not "your" installer instance)</td></tr>
|
||||
</table>
|
||||
|
||||
<table class="piexport"><tr><th colspan=2>UAC::StackPush</th></tr>
|
||||
<tr><td>Parameters:</td><td><STR:String></td></tr>
|
||||
<tr><td>Returns:</td><td>[None] (ErrorFlag is set on error)</td></tr>
|
||||
<tr><td>Description:</td><td>Push to outer instance stack (For use with UAC::ExecCodeSegment)</td></tr>
|
||||
</table>
|
||||
|
||||
<table class="piexport"><tr><th colspan=2>UAC::GetOuterHwnd</th></tr>
|
||||
<tr><td>Parameters:</td><td></td></tr>
|
||||
<tr><td>Returns:</td><td><span class="nsisvar">$0</span> HWNDPARENT of outer instance</td></tr>
|
||||
<tr><td>Description:</td><td>For use with ${UAC.RunElevatedAndProcessMessages}</td></tr>
|
||||
</table>
|
||||
|
||||
<table class="piexport"><tr><th colspan=2>UAC::SupportsUAC</th></tr>
|
||||
<tr><td>Parameters:</td><td></td></tr>
|
||||
<tr><td>Returns:</td><td><span class="nsisvar">$0</span> !=0 if supported</td></tr>
|
||||
<tr><td>Description:</td><td>Check if the OS supports UAC (And the user has UAC turned on) <span class="importanttxt">This function only tests if UAC is active, will return 0 on NT5 even though runas is implemented on those platforms, will also return 0 on NT6+ if UAC is off. You should only call this function during testing, NOT to determine if you can call UAC::RunElevated</span></td></tr>
|
||||
</table>
|
||||
|
||||
<table class="piexport"><tr><th colspan=2>UAC::GetElevationType</th></tr>
|
||||
<tr><td>Parameters:</td><td></td></tr>
|
||||
<tr><td>Returns:</td><td>
|
||||
<table class="ret">
|
||||
<tr><td><span class="nsisvar">$0</span></td><td><a href="#" OnClick="return NavGL('TOKEN_ELEVATION_TYPE Enumeration')">TOKEN_ELEVATION_TYPE</a>:
|
||||
<table class="ret">
|
||||
<tr><td>0</td><td>Unsupported/Failed (ErrorFlag is also set)</td></tr>
|
||||
<tr><td>1</td><td>TokenElevationTypeDefault: User is not using a split token (UAC disabled)</td></tr>
|
||||
<tr><td>2</td><td>TokenElevationTypeFull: UAC enabled, the (current) process is elevated</td></tr>
|
||||
<tr><td>3</td><td>TokenElevationTypeLimited: UAC enabled, the process is not elevated</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table></td></tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="lang"><h2>Language support</h2></a><div class="CntSec">
|
||||
<p>If the plugin is built with FEAT_CUSTOMRUNASDLG_TRANSLATE (Enabled by default),
|
||||
you can extract a file named <span class="str">UAC.LNG</span> to <span class="nsisvar">$pluginsdir</span>.
|
||||
It is a ini file with the following sections:
|
||||
</p><pre class="inifile">
|
||||
[MyRunAsCfg]
|
||||
<span class="inicomment">;Set to 1 to disable the radio button</span>
|
||||
DisableCurrUserOpt=
|
||||
<span class="inicomment">;Set to 1 to hide the radio button</span>
|
||||
HideCurrUserOpt=
|
||||
|
||||
[MyRunAsStrings]
|
||||
DlgTitle=Hello There!
|
||||
HelpText=Just do your thing!
|
||||
<span class="inicomment">;Label for current user radio button, %s is replaced with result of GetUserNameEx(NameSamCompatible,...)</span>
|
||||
OptCurrUser=Self service (%s)
|
||||
OptOtherUser=Run as someone:
|
||||
UserName=Who:
|
||||
Pwd=PIN:
|
||||
OK=Okey!
|
||||
Cancel=No Way</pre>
|
||||
</div>
|
||||
|
||||
<a name="knownissues"><h2>Known Issues</h2></a><div class="CntSec">
|
||||
<ul>
|
||||
<li>UACPI.KI#1: DetailPrint in outer process is ignored
|
||||
<li>UACPI.KI#2: Elevation can fail if the installer is located on a remote share that requires authentication
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<a name="glossary"><h2>Glossary</h2></a><div class="CntSec">
|
||||
<ul>
|
||||
<li>AAM: Admin Approval Mode
|
||||
<li>IL: Integrity level (Part of the new MIC/WIC security levels added to NT6)
|
||||
<li>LUA: Limited/Least-privilege User Account
|
||||
<li>MIC: <a href="http://en.wikipedia.org/wiki/Mandatory_Integrity_Control">Mandatory Integrity Controls</a> (Now known as WIC)
|
||||
<li>UAC: User Account Control (Part of the UAP umbrella)
|
||||
<li>UAP: User Account Protection
|
||||
<li>WIC: <a href="http://www.securityfocus.com/infocus/1887">Windows Integrity Controls</a>
|
||||
<li>Win32 error code: Standard windows error codes, ERROR_???
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</body></html>
|
||||
@@ -1,191 +0,0 @@
|
||||
/*
|
||||
=======================
|
||||
UAC helper include file
|
||||
.......................
|
||||
|
||||
Macros starting with UAC.I should only be called from the installer and vice versa for UAC.U macros.
|
||||
|
||||
*/
|
||||
!ifndef UAC_HDR__INC
|
||||
!define UAC_HDR__INC
|
||||
!include LogicLib.nsh
|
||||
|
||||
!define UAC.RunElevatedAndProcessMessages 'UAC::RunElevated '
|
||||
!define UAC.Unload 'UAC::Unload '
|
||||
!define UAC.StackPush 'UAC::StackPush '
|
||||
|
||||
/*!macro _UAC.BuildOnInitElevationFunc _funcprefix
|
||||
Function ${_funcprefix}onInit
|
||||
!ifmacrodef
|
||||
FunctionEnd
|
||||
!macroend*/
|
||||
|
||||
!macro _UAC.GenerateSimpleFunction _funcprefix _funcName _funcCode
|
||||
Function ${_funcprefix}${_funcName}
|
||||
${_funcCode}
|
||||
#messagebox mb_ok "${_funcprefix}${_funcName}"
|
||||
FunctionEnd
|
||||
!macroend
|
||||
|
||||
!macro _UAC.TryDef _d _v
|
||||
!ifndef ${_d}
|
||||
!define ${_d} "${_v}"
|
||||
!endif
|
||||
!macroend
|
||||
|
||||
!macro _UAC.InitStrings _modeprefix
|
||||
!insertmacro _UAC.TryDef UACSTR.UnDataFile "UAC.dat"
|
||||
!insertmacro _UAC.TryDef UACSTR.${_modeprefix}ElvWinErr "Unable to elevate , error $0"
|
||||
!ifNdef __UNINSTALL__
|
||||
!insertmacro _UAC.TryDef UACSTR.${_modeprefix}ElvAbortReqAdmin "This installer requires admin access, aborting!"
|
||||
!insertmacro _UAC.TryDef UACSTR.${_modeprefix}ElvMustTryAgain "This installer requires admin access, try again"
|
||||
!else
|
||||
!insertmacro _UAC.TryDef UACSTR.${_modeprefix}ElvAbortReqAdmin "This uninstaller requires admin access, aborting!"
|
||||
!insertmacro _UAC.TryDef UACSTR.${_modeprefix}ElvMustTryAgain "This uninstaller requires admin access, try again"
|
||||
!endif
|
||||
!macroend
|
||||
|
||||
!ifmacroNdef _UAC.GenerateUninstallerTango
|
||||
!macro _UAC.GenerateUninstallerTango UninstallerFileName
|
||||
!ifdef __GLOBAL__
|
||||
!error "UAC: Needs to be called inside a function"
|
||||
!endif
|
||||
!ifNdef __UNINSTALL__
|
||||
!error "UAC: _UAC.GenerateUninstallerTango should only be called by uninstaller, see http://forums.winamp.com/showthread.php?threadid=280330"
|
||||
!endif
|
||||
!ifNdef UAC_UNINSTALLERTANGOFORALLPLATFORMS
|
||||
!include WinVer.nsh
|
||||
!endif
|
||||
!insertmacro _UAC.InitStrings 'U.'
|
||||
ReadIniStr $0 "$ExeDir\${UACSTR.UnDataFile}" UAC "Un.Ready"
|
||||
${IF} $0 != 1
|
||||
!ifNdef UAC_UNINSTALLERTANGOFORALLPLATFORMS
|
||||
${AndIf} ${AtLeastWinVista}
|
||||
!endif
|
||||
InitPluginsDir
|
||||
WriteIniStr "$PluginsDir\${UACSTR.UnDataFile}" UAC "Un.Ready" 1
|
||||
CopyFiles /SILENT "$EXEPATH" "$PluginsDir\${UninstallerFileName}"
|
||||
StrCpy $0 ""
|
||||
${IfThen} ${Silent} ${|} StrCpy $0 "/S " ${|}
|
||||
ExecWait '"$PluginsDir\${UninstallerFileName}" $0/NCRC _?=$INSTDIR' $0
|
||||
SetErrorLevel $0
|
||||
Quit
|
||||
${EndIf}
|
||||
!macroend
|
||||
!endif
|
||||
|
||||
!ifmacroNdef _UAC.GenerateOnInitElevationCode
|
||||
!macro _UAC.GenerateOnInitElevationCode _modeprefix
|
||||
!ifndef __FUNCTION__
|
||||
!error "UAC: Needs to be called inside a function"
|
||||
!endif
|
||||
!insertmacro _UAC.InitStrings ${_modeprefix}
|
||||
!define _UAC.GOIECUniq L${__LINE__}
|
||||
UAC_Elevate_${_UAC.GOIECUniq}:
|
||||
UAC::RunElevated
|
||||
StrCmp 1223 $0 UAC_ElevationAborted_${_UAC.GOIECUniq} ; UAC dialog aborted by user?
|
||||
StrCmp 0 $0 0 UAC_Err_${_UAC.GOIECUniq} ; Error?
|
||||
StrCmp 1 $1 0 UAC_Success_${_UAC.GOIECUniq} ;Are we the real deal or just the wrapper?
|
||||
Quit
|
||||
UAC_Err_${_UAC.GOIECUniq}:
|
||||
MessageBox mb_iconstop "${UACSTR.${_modeprefix}ElvWinErr}"
|
||||
Abort
|
||||
UAC_ElevationAborted_${_UAC.GOIECUniq}:
|
||||
MessageBox mb_iconstop "${UACSTR.${_modeprefix}ElvAbortReqAdmin}"
|
||||
Abort
|
||||
UAC_Success_${_UAC.GOIECUniq}:
|
||||
# if $0==0 && $3==1, we are a member of the admin group (Any OS)
|
||||
# if $0==0 && $1==0, UAC not supported (Probably <NT6), run as normal?
|
||||
# if $0==0 && $1==3, we can try to elevate again
|
||||
StrCmp 1 $3 /*+4*/ UAC_Done_${_UAC.GOIECUniq} ;Admin?
|
||||
StrCmp 3 $1 0 UAC_ElevationAborted_${_UAC.GOIECUniq} ;Try again or abort?
|
||||
MessageBox mb_iconexclamation "${UACSTR.${_modeprefix}ElvMustTryAgain}" ;Inform user...
|
||||
goto UAC_Elevate_${_UAC.GOIECUniq} ;...lets try again
|
||||
UAC_Done_${_UAC.GOIECUniq}:
|
||||
!undef _UAC.GOIECUniq
|
||||
!macroend
|
||||
!endif
|
||||
|
||||
!define UAC.I.Elevate.AdminOnly '!insertmacro UAC.I.Elevate.AdminOnly '
|
||||
!macro UAC.I.Elevate.AdminOnly
|
||||
!insertmacro _UAC.GenerateOnInitElevationCode 'I.'
|
||||
!macroend
|
||||
|
||||
!define UAC.U.Elevate.AdminOnly '!insertmacro UAC.U.Elevate.AdminOnly '
|
||||
!macro UAC.U.Elevate.AdminOnly _UninstallerName
|
||||
!ifNdef UAC_DISABLEUNINSTALLERTANGO
|
||||
!insertmacro _UAC.GenerateUninstallerTango "${_UninstallerName}"
|
||||
!endif
|
||||
!insertmacro _UAC.GenerateOnInitElevationCode 'U.'
|
||||
!macroend
|
||||
|
||||
!define UAC.AutoCodeUnload '!insertmacro UAC.AutoCodeUnload '
|
||||
!macro UAC.AutoCodeUnload _HasUninstaller
|
||||
!insertmacro _UAC.GenerateSimpleFunction "" .OnInstFailed '${UAC.Unload}'
|
||||
!insertmacro _UAC.GenerateSimpleFunction "" .OnInstSuccess '${UAC.Unload}'
|
||||
!ifNdef MUI_INCLUDED
|
||||
!insertmacro _UAC.GenerateSimpleFunction "" .onUserAbort '${UAC.Unload}'
|
||||
!else
|
||||
!ifNdef MUI_CUSTOMFUNCTION_ABORT
|
||||
!error "UAC: must call $$ {UAC.Unload} in MUI_CUSTOMFUNCTION_ABORT!"
|
||||
!endif
|
||||
!endif
|
||||
!if "${_HasUninstaller}" != ""
|
||||
!insertmacro _UAC.GenerateSimpleFunction "un" .onUninstFailed '${UAC.Unload}'
|
||||
!insertmacro _UAC.GenerateSimpleFunction "un" .onUninstSuccess '${UAC.Unload}'
|
||||
!ifNdef MUI_INCLUDED
|
||||
!insertmacro _UAC.GenerateSimpleFunction "un" .onUserAbort '${UAC.Unload}'
|
||||
!else
|
||||
!ifNdef MUI_CUSTOMFUNCTION_ABORT
|
||||
!error "UAC: must call $$ {UAC.Unload} in MUI_CUSTOMFUNCTION_(UN)ABORT!"
|
||||
!endif
|
||||
!endif
|
||||
!endif
|
||||
!macroend
|
||||
|
||||
!define UAC.FastCallFunctionAsUser '!insertmacro UAC.FastCallFunctionAsUser '
|
||||
!macro UAC.FastCallFunctionAsUser _func _var
|
||||
GetFunctionAddress ${_var} ${_func}
|
||||
UAC::ExecCodeSegment ${_var}
|
||||
!macroend
|
||||
!define UAC.CallFunctionAsUser '!insertmacro UAC.CallFunctionAsUser '
|
||||
!macro UAC.CallFunctionAsUser _func
|
||||
push $R9
|
||||
!insertmacro UAC.FastCallFunctionAsUser ${_func} $R9
|
||||
pop $R9
|
||||
!macroend
|
||||
|
||||
!define UAC.FastCallGetOuterInstanceHwndParent UAC::GetOuterHwnd
|
||||
!define UAC.GetOuterInstanceHwndParent '!insertmacro UAC.GetOuterInstanceHwndParent '
|
||||
!macro UAC.GetOuterInstanceHwndParent _var
|
||||
push $0
|
||||
${UAC.FastCallGetOuterInstanceHwndParent}
|
||||
Exch $0
|
||||
Pop ${_var}
|
||||
!macroend
|
||||
|
||||
|
||||
|
||||
!macro _UAC.DumpEx _disp _f _fp _v
|
||||
${_f} ${_fp}
|
||||
DetailPrint "${_disp}=${_v}"
|
||||
!macroend
|
||||
!macro _UAC.Dump _f _fp _v
|
||||
!insertmacro _UAC.DumpEx `${_f}` `${_f}` `${_fp}` `${_v}`
|
||||
!macroend
|
||||
!macro _UAC.DbgDetailPrint
|
||||
push $0
|
||||
push $1
|
||||
System::Call /NoUnload "advapi32::GetUserName(t.r0,*i${NSIS_MAX_STRLEN})"
|
||||
System::Call "Kernel32::GetComputerName(t.r1,*i${NSIS_MAX_STRLEN})"
|
||||
DetailPrint "$1\$0"
|
||||
;!insertmacro _UAC.DumpEx "User" System::Call "advapi32::GetUserName(t.r0,*i${NSIS_MAX_STRLEN})" $0
|
||||
!insertmacro _UAC.DumpEx "CmdLine" "" "" "$CmdLine"
|
||||
!insertmacro _UAC.Dump UAC::IsAdmin "" $0
|
||||
!insertmacro _UAC.Dump UAC::SupportsUAC "" $0
|
||||
!insertmacro _UAC.Dump UAC::GetElevationType "" $0
|
||||
pop $1
|
||||
pop $0
|
||||
!macroend
|
||||
|
||||
!endif /* ifndef UAC_HDR__INC */
|
||||
@@ -1,62 +0,0 @@
|
||||
RequestExecutionLevel user /* RequestExecutionLevel REQUIRED! */
|
||||
!define APPNAME "UAC_AdminOnly"
|
||||
Name "${APPNAME}"
|
||||
OutFile "${APPNAME}.exe"
|
||||
ShowInstDetails show
|
||||
|
||||
!include UAC.nsh ;<<< New headerfile that does everything for you ;)
|
||||
!include LogicLib.nsh
|
||||
|
||||
!define UACSTR.I.ElvAbortReqAdmin "This fancy app requires admin rights fool" ;custom error string, see _UAC.InitStrings macro in uac.nsh for more
|
||||
|
||||
Function .OnInit
|
||||
${UAC.I.Elevate.AdminOnly}
|
||||
FunctionEnd
|
||||
|
||||
Function .OnInstFailed
|
||||
${UAC.Unload}
|
||||
FunctionEnd
|
||||
Function .OnInstSuccess
|
||||
${UAC.Unload}
|
||||
FunctionEnd
|
||||
|
||||
Function ExecCodeSegmentTest
|
||||
${If} "$1" != "666, the # of the beast"
|
||||
MessageBox mb_ok "uh oh"
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Section "Info"
|
||||
!insertmacro _UAC.DbgDetailPrint
|
||||
|
||||
StrCpy $1 "666, the # of the beast"
|
||||
!insertmacro UAC.CallFunctionAsUser ExecCodeSegmentTest
|
||||
SectionEnd
|
||||
|
||||
page InstFiles
|
||||
|
||||
/* LEGACY CODE: (now uses magic code from UAC.nsh)
|
||||
Function .OnInit
|
||||
UAC_Elevate:
|
||||
UAC::RunElevated
|
||||
StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
|
||||
StrCmp 0 $0 0 UAC_Err ; Error?
|
||||
StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
|
||||
Quit
|
||||
UAC_Err:
|
||||
MessageBox mb_iconstop "Unable to elevate , error $0"
|
||||
Abort
|
||||
UAC_ElevationAborted:
|
||||
/*System::Call "user32::CreateWindowEx(i ${WS_EX_TRANSPARENT}|${WS_EX_LAYERED}, t 'Button', t 'blah', i 0, i 10, i 10, i 10, i 10, i 0, i 0, i 0) i .r0"
|
||||
ShowWindow $0 ${SW_SHOW}
|
||||
System::Call "user32::SetForegroundWindow(i r0) i."
|
||||
System::Call "user32::DestroyWindow(i r0) i."
|
||||
* /
|
||||
MessageBox mb_iconstop "This installer requires admin access, aborting!"
|
||||
Abort
|
||||
UAC_Success:
|
||||
StrCmp 1 $3 +4 ;Admin?
|
||||
StrCmp 3 $1 0 UAC_ElevationAborted ;Try again or abort?
|
||||
MessageBox mb_iconstop "This installer requires admin access, try again" ;Inform user...
|
||||
goto UAC_Elevate ;... and try again
|
||||
FunctionEnd*/
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
This sample will try to elevate, but it will also allow non admin users to continue if they click cancel in the elevation dialog
|
||||
*/
|
||||
|
||||
RequestExecutionLevel user /* RequestExecutionLevel REQUIRED! */
|
||||
!define APPNAME "UAC_AllowLUA"
|
||||
Name "${APPNAME}"
|
||||
OutFile "${APPNAME}.exe"
|
||||
ShowInstDetails show
|
||||
!include UAC.nsh
|
||||
|
||||
|
||||
Function .OnInstFailed
|
||||
UAC::Unload ;Must call unload!
|
||||
FunctionEnd
|
||||
Function .OnInstSuccess
|
||||
UAC::Unload ;Must call unload!
|
||||
FunctionEnd
|
||||
|
||||
Function .OnInit
|
||||
UAC::RunElevated
|
||||
;MessageBox mb_iconinformation "Debug: UAC::RunElevated: $\n0(Error)=$0 $\n1(UACMode)=$1 $\n2=$2 $\nadmin=$3$\n$\n$CmdLine"
|
||||
StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
|
||||
StrCmp 0 $0 0 UAC_Err ; Error?
|
||||
StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
|
||||
Quit
|
||||
UAC_Err:
|
||||
MessageBox mb_iconstop "Unable to elevate , error $0"
|
||||
Abort
|
||||
UAC_ElevationAborted:
|
||||
# elevation was aborted, we still run as normal
|
||||
UAC_Success:
|
||||
FunctionEnd
|
||||
|
||||
|
||||
|
||||
Section "Info"
|
||||
!insertmacro _UAC.DbgDetailPrint
|
||||
SectionEnd
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Page InstFiles
|
||||
@@ -1,30 +0,0 @@
|
||||
RequestExecutionLevel user /* RequestExecutionLevel REQUIRED! */
|
||||
!define APPNAME "UAC_GetUserShellFolderPath"
|
||||
Name "${APPNAME}"
|
||||
OutFile "${APPNAME}.exe"
|
||||
ShowInstDetails show
|
||||
|
||||
!include UAC.nsh
|
||||
!include LogicLib.nsh
|
||||
|
||||
page instfiles
|
||||
|
||||
Function .onInit
|
||||
${UAC.I.Elevate.AdminOnly}
|
||||
FunctionEnd
|
||||
|
||||
!ifndef CSIDL_PERSONAL
|
||||
!define CSIDL_PERSONAL 0x0005 ;My Documents
|
||||
!endif
|
||||
Section
|
||||
|
||||
/*
|
||||
You can specify a fallback value in the 2nd parameter, it is used if the installer is not elevated
|
||||
or running on NT4/Win9x or on errors.
|
||||
If you just want to check for success, use "" as the 2nd parameter and compare $0 with ""
|
||||
*/
|
||||
UAC::GetShellFolderPath ${CSIDL_PERSONAL} $Documents
|
||||
DetailPrint MyDocs=$0
|
||||
|
||||
|
||||
SectionEnd
|
||||
@@ -1,235 +0,0 @@
|
||||
/*
|
||||
This sample supports two modes, installing as a normal user (single user install) AND as admin (all users install)
|
||||
This sample uses the registry plugin, so you need to download that if you don't already have it
|
||||
*/
|
||||
|
||||
!define APPNAME "UAC_RealWorldFullyLoadedDualMode"
|
||||
!define ELEVATIONTITLE "${APPNAME}: Elevate" ;displayed during elevation on our custom page
|
||||
!define UNINSTALLER_NAME "Uninstall ${APPNAME}.exe"
|
||||
!define UNINSTALLER_REGSECTION "${APPNAME}"
|
||||
!define RegPath.MSUninstall "Software\Microsoft\Windows\CurrentVersion\Uninstall"
|
||||
Name "${APPNAME}"
|
||||
OutFile "${APPNAME}.exe"
|
||||
ShowInstDetails show
|
||||
SetCompressor LZMA
|
||||
RequestExecutionLevel user /* RequestExecutionLevel REQUIRED! */
|
||||
!include MUI.nsh
|
||||
!include UAC.nsh
|
||||
!include LogicLib.nsh
|
||||
!include Registry.nsh
|
||||
!include nsDialogs.nsh ;for our custom page
|
||||
!include FileFunc.nsh ;we need to parse the command line
|
||||
|
||||
!insertmacro GetParameters
|
||||
!insertmacro GetOptions
|
||||
|
||||
!define MUI_CUSTOMFUNCTION_ABORT onAbort
|
||||
!define MUI_CUSTOMFUNCTION_GUIINIT onGuiInit
|
||||
!define MUI_COMPONENTSPAGE_NODESC
|
||||
!define MUI_FINISHPAGE_NOAUTOCLOSE
|
||||
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\llama-blue.ico"
|
||||
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\llama-blue.ico"
|
||||
!define MUI_WELCOMEPAGE_TITLE_3LINES
|
||||
|
||||
var InstMode # 0: Single user, 1:All users, >1:elevated instance, perform page jump
|
||||
var hKey # Reg hive
|
||||
var hSelModeAdminRadio
|
||||
var StartMenuFolder
|
||||
|
||||
!macro SetMode IsAdmin
|
||||
!if "${IsAdmin}" > 0
|
||||
SetShellVarContext all
|
||||
StrCpy $InstMode 1
|
||||
StrCpy $hKey HKLM
|
||||
!else
|
||||
SetShellVarContext current
|
||||
StrCpy $InstMode 0
|
||||
StrCpy $hKey HKCU
|
||||
!endif
|
||||
!macroend
|
||||
|
||||
Function .OnInit
|
||||
!insertmacro SetMode 0
|
||||
${GetParameters} $R9
|
||||
${GetOptions} "$R9" UAC $0 ;look for special /UAC:???? parameter (sort of undocumented)
|
||||
${Unless} ${Errors}
|
||||
UAC::IsAdmin
|
||||
${If} $0 < 1
|
||||
SetErrorLevel 666 ;special return value for outer instance so it knows we did not have admin rights
|
||||
Quit
|
||||
${EndIf}
|
||||
!insertmacro SetMode 1
|
||||
StrCpy $InstMode 2
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function onGuiInit
|
||||
${If} $InstMode >= 2
|
||||
${UAC.GetOuterInstanceHwndParent} $0
|
||||
${If} $0 <> 0
|
||||
System::Call /NOUNLOAD "*(i,i,i,i)i.r1"
|
||||
System::Call /NOUNLOAD 'user32::GetWindowRect(i $0,i r1)i.r2'
|
||||
${If} $2 <> 0
|
||||
System::Call /NOUNLOAD "*$1(i.r2,i.r3)"
|
||||
System::Call /NOUNLOAD 'user32::SetWindowPos(i $hwndParent,i0,ir2,ir3,i0,i0,i 4|1)'
|
||||
${EndIf}
|
||||
ShowWindow $hwndParent ${SW_SHOW}
|
||||
ShowWindow $0 ${SW_HIDE} ;hide outer instance installer window
|
||||
System::Free $1
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function Un.OnInit
|
||||
!insertmacro SetMode 0
|
||||
ReadRegDWORD $0 HKLM "${RegPath.MSUninstall}\${UNINSTALLER_REGSECTION}" InstMode ;We saved the "mode" in the installer
|
||||
${If} $0 U> 0
|
||||
; If it was installed for all users, we have to be admin to uninstall it
|
||||
${UAC.U.Elevate.AdminOnly} "${UNINSTALLER_NAME}"
|
||||
!insertmacro SetMode 1
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function onAbort
|
||||
${UAC.Unload}
|
||||
FunctionEnd
|
||||
|
||||
${UAC.AutoCodeUnload} 1 ;Auto-generate .OnInstFailed and .OnInstSuccess functions
|
||||
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipPageInElvModePreCB
|
||||
!insertmacro MUI_PAGE_WELCOME
|
||||
Page Custom ModeSelectionPageCreate ModeSelectionPageLeave
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE CmpntsPreCB
|
||||
!insertmacro MUI_PAGE_COMPONENTS
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE DirPreCB
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
!insertmacro MUI_PAGE_STARTMENU 1 $StartMenuFolder
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
!define MUI_FINISHPAGE_TITLE_3LINES
|
||||
!define MUI_FINISHPAGE_RUN
|
||||
!define MUI_FINISHPAGE_RUN_FUNCTION FinishRunCB
|
||||
!insertmacro MUI_PAGE_FINISH
|
||||
!define MUI_WELCOMEPAGE_TITLE_3LINES
|
||||
!insertmacro MUI_UNPAGE_WELCOME
|
||||
!insertmacro MUI_UNPAGE_INSTFILES
|
||||
!insertmacro MUI_LANGUAGE "English"
|
||||
|
||||
Function CmpntsPreCB
|
||||
GetDlgItem $0 $hwndparent 3
|
||||
${IfThen} $InstMode >= 1 ${|} EnableWindow $0 0 ${|} ;prevent user from going back and selecting single user so noobs don't end up installing as the wrong user
|
||||
FunctionEnd
|
||||
|
||||
Function SkipPageInElvModePreCB
|
||||
${IfThen} $InstMode > 1 ${|} Abort ${|} ;skip this page so we get to the mode selection page
|
||||
FunctionEnd
|
||||
|
||||
Function ModeSelectionPageCreate
|
||||
${If} $InstMode > 1
|
||||
StrCpy $InstMode 1
|
||||
Abort ;skip this page and contine where the "parent" would have gone
|
||||
${EndIf}
|
||||
!insertmacro MUI_HEADER_TEXT_PAGE "Select install type" "Blah blah blah blah"
|
||||
nsDialogs::Create /NOUNLOAD 1018
|
||||
Pop $0
|
||||
${NSD_CreateLabel} 0 20u 75% 20u "Blah blah blah blah select install type..."
|
||||
Pop $0
|
||||
System::Call "advapi32::GetUserName(t.r0, *i ${NSIS_MAX_STRLEN}r1) i.r2"
|
||||
${NSD_CreateRadioButton} 0 40u 75% 15u "Single User ($0)"
|
||||
Pop $0
|
||||
${IfThen} $InstMode U< 1 ${|} SendMessage $0 ${BM_SETCHECK} 1 0 ${|}
|
||||
${NSD_CreateRadioButton} 0 60u 75% 15u "All users"
|
||||
Pop $hSelModeAdminRadio
|
||||
${IfThen} $InstMode U> 0 ${|} SendMessage $hSelModeAdminRadio ${BM_SETCHECK} 1 0 ${|}
|
||||
nsDialogs::Show
|
||||
FunctionEnd
|
||||
|
||||
!macro EnableCtrl dlg id state
|
||||
push $language
|
||||
GetDlgItem $language ${dlg} ${id}
|
||||
EnableWindow $language ${state}
|
||||
pop $language
|
||||
!macroend
|
||||
|
||||
Function ModeSelectionPageLeave
|
||||
SendMessage $hSelModeAdminRadio ${BM_GETCHECK} 0 0 $9
|
||||
UAC::IsAdmin
|
||||
${If} $9 U> 0
|
||||
${If} $0 <> 0
|
||||
!insertmacro SetMode 1
|
||||
${Else}
|
||||
System::Call /NoUnload 'user32::GetWindowText(i $HwndParent,t.R1,i ${NSIS_MAX_STRLEN})' ;get original window title
|
||||
System::Call /NoUnload 'user32::SetWindowText(i $HwndParent,t "${ELEVATIONTITLE}")' ;set out special title
|
||||
StrCpy $2 "" ;reset special return, only gets set when sub process is executed, not when user cancels
|
||||
!insertmacro EnableCtrl $HWNDParent 1 0 ;Disable next button, just because it looks good ;)
|
||||
${UAC.RunElevatedAndProcessMessages}
|
||||
!insertmacro EnableCtrl $HWNDParent 1 1
|
||||
System::Call 'user32::SetWindowText(i $HwndParent,t "$R1")' ;restore title
|
||||
${If} $2 = 666 ;our special return, the new process was not admin after all
|
||||
MessageBox mb_iconExclamation "You need to login with an account that is a member of the admin group to continue..."
|
||||
Abort
|
||||
${ElseIf} $0 = 1223 ;cancel
|
||||
Abort
|
||||
${Else}
|
||||
${If} $0 <> 0
|
||||
${If} $0 = 1062
|
||||
MessageBox mb_iconstop "Unable to elevate, Secondary Logon service not running!"
|
||||
${Else}
|
||||
MessageBox mb_iconstop "Unable to elevate, error $0 ($1,$2,$3)"
|
||||
${EndIf}
|
||||
Abort
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
Quit ;We now have a new process, the install will continue there, we have nothing left to do here
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function DirPreCB
|
||||
${If} $InstDir == ""
|
||||
${If} $InstMode U> 0
|
||||
StrCpy $InstDir "$ProgramFiles\${APPNAME}"
|
||||
${Else}
|
||||
StrCpy $InstDir "$APPDATA\${APPNAME}"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function FinishRunCB
|
||||
UAC::Exec "" "Notepad.exe" "$Windir\Win.INI" "$InstDir"
|
||||
FunctionEnd
|
||||
|
||||
Function CreateSMShortcuts
|
||||
CreateShortcut "$SMPrograms\${APPNAME}.lnk" "$Windir\Notepad.exe"
|
||||
FunctionEnd
|
||||
Function CreateDeskShortcuts
|
||||
CreateShortcut "$Desktop\${APPNAME}.lnk" "$Windir\Notepad.exe"
|
||||
FunctionEnd
|
||||
|
||||
Section "!Required files"
|
||||
SectionIn RO
|
||||
SetOutPath -
|
||||
!insertmacro _UAC.DbgDetailPrint ;some debug info, useful during testing
|
||||
;Install files here...
|
||||
WriteUninstaller "$InstDir\${UNINSTALLER_NAME}"
|
||||
${registry::Write} "$hKey\${RegPath.MSUninstall}\${UNINSTALLER_REGSECTION}" DisplayName "${APPNAME}" REG_SZ $0
|
||||
${registry::Write} "$hKey\${RegPath.MSUninstall}\${UNINSTALLER_REGSECTION}" UninstallString "$InstDir\${UNINSTALLER_NAME}" REG_SZ $0
|
||||
${registry::Write} "$hKey\${RegPath.MSUninstall}\${UNINSTALLER_REGSECTION}" InstMode $InstMode REG_DWORD $0
|
||||
${registry::Unload}
|
||||
SectionEnd
|
||||
|
||||
Section "Startmenu Shortcuts"
|
||||
${UAC.CallFunctionAsUser} CreateSMShortcuts
|
||||
SectionEnd
|
||||
Section "Desktop Shortcut"
|
||||
${UAC.CallFunctionAsUser} CreateDeskShortcuts
|
||||
SectionEnd
|
||||
|
||||
Section Uninstall
|
||||
Delete "$InstDir\${UNINSTALLER_NAME}"
|
||||
Delete "$SMPrograms\${APPNAME}.lnk"
|
||||
Delete "$Desktop\${APPNAME}.lnk"
|
||||
|
||||
RMDir "$InstDir"
|
||||
${registry::DeleteKey} "$hKey\${RegPath.MSUninstall}\${UNINSTALLER_REGSECTION}" $0
|
||||
${registry::Unload}
|
||||
SectionEnd
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
This script was made in response to http://forums.winamp.com/showthread.php?threadid=280330
|
||||
It is a ugly hack and is mostly here just to have a solution right now.
|
||||
Hopefully, NSIS will add support for changing the RequestExecutionLevel of the uninstaller
|
||||
This code inspired the _UAC.GenerateUninstallerTango macro (called by ${UAC.U.Elevate.AdminOnly} unless you define UAC_DISABLEUNINSTALLERTANGO)
|
||||
*/
|
||||
|
||||
RequestExecutionLevel user /* RequestExecutionLevel REQUIRED! */
|
||||
!define APPNAME "UAC_Uninstaller"
|
||||
Name "${APPNAME}"
|
||||
OutFile "${APPNAME}.exe"
|
||||
ShowInstDetails show
|
||||
!include LogicLib.nsh
|
||||
|
||||
!define UNINSTALLER_UACDATA "uac.ini"
|
||||
!define UNINSTALLER_NAME "Uninstall FooBarBaz"
|
||||
|
||||
Function un.onInit
|
||||
ReadIniStr $0 "$ExeDir\${UNINSTALLER_UACDATA}" UAC "Un.First"
|
||||
${IF} $0 != 1
|
||||
;SetSilent silent
|
||||
InitPluginsDir
|
||||
WriteIniStr "$PluginsDir\${UNINSTALLER_UACDATA}" UAC "Un.First" 1
|
||||
CopyFiles /SILENT "$EXEPATH" "$PluginsDir\${UNINSTALLER_NAME}.exe"
|
||||
StrCpy $0 ""
|
||||
${IfThen} ${Silent} ${|} StrCpy $0 "/S " ${|}
|
||||
ExecWait '"$PluginsDir\${UNINSTALLER_NAME}.exe" $0/NCRC _?=$INSTDIR' $0
|
||||
SetErrorLevel $0
|
||||
Quit
|
||||
${EndIf}
|
||||
|
||||
# UAC code goes here ...
|
||||
FunctionEnd
|
||||
|
||||
Section
|
||||
WriteUninstaller "$exedir\${UNINSTALLER_NAME}.exe"
|
||||
SetAutoClose true
|
||||
DetailPrint "Uninstalling..."
|
||||
Sleep 1111
|
||||
Exec '"$exedir\${UNINSTALLER_NAME}.exe"'
|
||||
SectionEnd
|
||||
|
||||
Section uninstall
|
||||
MessageBox mb_ok "My filename is: $EXEFILE"
|
||||
Delete "$instdir\${UNINSTALLER_NAME}.exe"
|
||||
Delete "$instdir\${APPNAME}.exe" ;delete generated installer aswell, this is just a sample script
|
||||
SectionEnd
|
||||
|
||||
page InstFiles
|
||||
@@ -1,24 +0,0 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by resource.rc
|
||||
//
|
||||
#define IDD_MYRUNAS 101
|
||||
#define IDC_RUNASCURR 1000
|
||||
#define IDC_RUNASSPEC 1001
|
||||
#define IDC_SHICON 1002
|
||||
#define IDC_HELPTEXT 1003
|
||||
#define IDC_USERNAME 1004
|
||||
#define IDC_PASSWORD 1005
|
||||
#define IDC_LBLUSER 1007
|
||||
#define IDC_LBLPWD 1008
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1009
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,109 +0,0 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
#include "uac.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_MYRUNAS DIALOG DISCARDABLE 0, 0, 250, 145
|
||||
STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_SETFOREGROUND | DS_FIXEDSYS |
|
||||
DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "&OK",IDOK,132,122,50,14
|
||||
PUSHBUTTON "Ca&ncel",IDCANCEL,188,122,50,14
|
||||
ICON "",IDC_SHICON,7,7,20,20
|
||||
LTEXT "",IDC_HELPTEXT,34,7,204,35
|
||||
CONTROL "",IDC_RUNASCURR,"Button",BS_AUTORADIOBUTTON,20,49,218,
|
||||
10
|
||||
CONTROL "",IDC_RUNASSPEC,"Button",BS_AUTORADIOBUTTON,20,65,218,
|
||||
10
|
||||
LTEXT "&User name:",IDC_LBLUSER,20,84,42,16
|
||||
EDITTEXT IDC_USERNAME,63,83,175,14,ES_AUTOHSCROLL
|
||||
LTEXT "&Password:",IDC_LBLPWD,20,102,42,20
|
||||
EDITTEXT IDC_PASSWORD,63,100,175,14,ES_PASSWORD | ES_AUTOHSCROLL
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_MYRUNAS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 238
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 136
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"#include ""uac.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,169 +0,0 @@
|
||||
//Copyright (C) 2007 Anders Kjersem. Licensed under the zlib/libpng license, see License.txt for details.
|
||||
#pragma once
|
||||
/** /#define BUILD_DBGRELEASE // Include simple debug output in release version */
|
||||
/** /#define BUILD_DBGSELECTELVMODE //Test MyRunAs*/
|
||||
|
||||
/** /#define UNICODE // Unicode build */
|
||||
/**/#define FEAT_CUSTOMRUNASDLG // Include custom runas dialog */
|
||||
/**/#define FEAT_CUSTOMRUNASDLG_TRANSLATE //*/
|
||||
/**/#define FEAT_MSRUNASDLGMODHACK // Default to other user radio button */
|
||||
|
||||
|
||||
#if !defined(APSTUDIO_INVOKED) && !defined(RC_INVOKED)
|
||||
|
||||
#if (defined(_MSC_VER) && !defined(_DEBUG))
|
||||
#pragma comment(linker,"/opt:nowin98")
|
||||
#pragma comment(linker,"/ignore:4078")
|
||||
#pragma comment(linker,"/merge:.rdata=.text")
|
||||
|
||||
//#pragma intrinsic(memset) //http://www.codeguru.com/forum/showthread.php?t=371491&page=2&pp=15 | http://www.ddj.com/windows/184416623
|
||||
#endif
|
||||
|
||||
#if defined(UNICODE) && !defined(_UNICODE)
|
||||
#define _UNICODE
|
||||
#endif
|
||||
#ifdef _UNICODE
|
||||
#define TFUNCSUFFIX W
|
||||
#else
|
||||
#define TFUNCSUFFIX A
|
||||
#endif
|
||||
#define _PCJOIN(a,b) a##b
|
||||
#define PCJOIN(a,b) _PCJOIN(a,b)
|
||||
|
||||
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <ShellAPI.h>
|
||||
#include <TChar.h>
|
||||
#include "NSISUtil.h"
|
||||
|
||||
#ifndef SEE_MASK_NOZONECHECKS
|
||||
#define SEE_MASK_NOZONECHECKS 0x00800000
|
||||
#endif
|
||||
|
||||
#define COUNTOF(___c) ( sizeof(___c)/sizeof(___c[0]) )
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE COUNTOF
|
||||
#endif
|
||||
#define FORCEINLINE __forceinline
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
extern void* __cdecl memset(void*mem,int c,size_t len);
|
||||
#endif
|
||||
|
||||
FORCEINLINE LRESULT MySndDlgItemMsg(HWND hDlg,int id,UINT Msg,WPARAM wp=0,LPARAM lp=0) {return SendMessage(GetDlgItem(hDlg,id),Msg,wp,lp);}
|
||||
#ifndef UAC_NOCUSTOMIMPLEMENTATIONS
|
||||
FORCEINLINE HANDLE WINAPI GetCurrentProcess(){return ((HANDLE)(-1));}
|
||||
FORCEINLINE HANDLE WINAPI GetCurrentThread(){return ((HANDLE)(-2));}
|
||||
|
||||
#define MyTStrLen lstrlen
|
||||
|
||||
#undef lstrcpy
|
||||
#define lstrcpy MyTStrCpy
|
||||
FORCEINLINE LPTSTR MyTStrCpy(LPTSTR s1,LPCTSTR s2) {return PCJOIN(lstr,PCJOIN(cpyn,TFUNCSUFFIX))(s1,s2,0x7FFFFFFF);}
|
||||
|
||||
#undef lstrcat
|
||||
#define lstrcat MyTStrCat
|
||||
LPTSTR MyTStrCat(LPTSTR s1,LPCTSTR s2)
|
||||
#ifdef UAC_INITIMPORTS
|
||||
{return s1?MyTStrCpy(&s1[MyTStrLen(s1)],s2):NULL;}
|
||||
#else
|
||||
;
|
||||
#endif //UAC_INITIMPORTS
|
||||
|
||||
#endif //UAC_NOCUSTOMIMPLEMENTATIONS
|
||||
|
||||
|
||||
//DelayLoaded functions:
|
||||
typedef BOOL (WINAPI*ALLOWSETFOREGROUNDWINDOW)(DWORD dwProcessId);
|
||||
typedef BOOL (WINAPI*OPENPROCESSTOKEN)(HANDLE ProcessHandle,DWORD DesiredAccess,PHANDLE TokenHandle);
|
||||
typedef BOOL (WINAPI*OPENTHREADTOKEN)(HANDLE ThreadHandle,DWORD DesiredAccess,BOOL OpenAsSelf,PHANDLE TokenHandle);
|
||||
typedef BOOL (WINAPI*GETTOKENINFORMATION)(HANDLE hToken,TOKEN_INFORMATION_CLASS TokInfoClass,LPVOID TokInfo,DWORD TokInfoLenh,PDWORD RetLen);
|
||||
typedef BOOL (WINAPI*ALLOCATEANDINITIALIZESID)(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,BYTE nSubAuthorityCount,DWORD sa0,DWORD sa1,DWORD sa2,DWORD sa3,DWORD sa4,DWORD sa5,DWORD sa6,DWORD sa7,PSID*pSid);
|
||||
typedef PVOID (WINAPI*FREESID)(PSID pSid);
|
||||
typedef BOOL (WINAPI*EQUALSID)(PSID pSid1,PSID pSid2);
|
||||
typedef BOOL (WINAPI*CHECKTOKENMEMBERSHIP)(HANDLE TokenHandle,PSID SidToCheck,PBOOL IsMember);
|
||||
#ifdef FEAT_CUSTOMRUNASDLG
|
||||
typedef BOOL (WINAPI*GETUSERNAME)(LPTSTR lpBuffer,LPDWORD nSize);
|
||||
typedef BOOL (WINAPI*CREATEPROCESSWITHLOGONW)(LPCWSTR lpUsername,LPCWSTR lpDomain,LPCWSTR lpPassword,DWORD dwLogonFlags,LPCWSTR lpApplicationName,LPWSTR lpCommandLine,DWORD dwCreationFlags,LPVOID pEnv,LPCWSTR WorkDir,LPSTARTUPINFOW pSI,LPPROCESS_INFORMATION pPI);
|
||||
#define SECURITY_WIN32
|
||||
#include <Security.h>//NameSamCompatible
|
||||
typedef BOOLEAN (WINAPI*GETUSERNAMEEX)(EXTENDED_NAME_FORMAT NameFormat,LPTSTR lpNameBuffer,PULONG nSize);
|
||||
#endif
|
||||
#ifdef UAC_INITIMPORTS
|
||||
ALLOWSETFOREGROUNDWINDOW _AllowSetForegroundWindow=0;
|
||||
OPENPROCESSTOKEN _OpenProcessToken=0;
|
||||
OPENTHREADTOKEN _OpenThreadToken=0;
|
||||
GETTOKENINFORMATION _GetTokenInformation=0;
|
||||
ALLOCATEANDINITIALIZESID _AllocateAndInitializeSid=0;
|
||||
FREESID _FreeSid=0;
|
||||
EQUALSID _EqualSid=0;
|
||||
CHECKTOKENMEMBERSHIP _CheckTokenMembership=0;
|
||||
#ifdef FEAT_CUSTOMRUNASDLG
|
||||
GETUSERNAME _GetUserName=0;
|
||||
GETUSERNAMEEX _GetUserNameEx=0;
|
||||
CREATEPROCESSWITHLOGONW _CreateProcessWithLogonW=0;
|
||||
#endif
|
||||
#else
|
||||
#ifdef FEAT_CUSTOMRUNASDLG
|
||||
extern GETUSERNAME _GetUserName;
|
||||
extern GETUSERNAMEEX _GetUserNameEx;
|
||||
extern CREATEPROCESSWITHLOGONW _CreateProcessWithLogonW;
|
||||
#endif
|
||||
#endif /* UAC_INITIMPORTS */
|
||||
|
||||
|
||||
extern DWORD DelayLoadDlls();
|
||||
#ifdef FEAT_CUSTOMRUNASDLG
|
||||
extern DWORD MyRunAs(HINSTANCE hInstDll,SHELLEXECUTEINFO&sei);
|
||||
#endif
|
||||
|
||||
#if !defined(NTDDI_VISTA) || defined(BUILD_OLDSDK)
|
||||
//#if !defined(NTDDI_VERSION) || (NTDDI_VERSION < 0x06000000) || !defined(NTDDI_VISTA)
|
||||
//#if !defined(TOKEN_ELEVATION_TYPE) || defined(BUILD_OLDSDK)
|
||||
enum TOKEN_ELEVATION_TYPE {
|
||||
TokenElevationTypeDefault = 1,
|
||||
TokenElevationTypeFull,
|
||||
TokenElevationTypeLimited
|
||||
};
|
||||
enum _TOKEN_INFORMATION_CLASS___VISTA {
|
||||
TokenElevationType = (TokenOrigin+1),
|
||||
TokenLinkedToken,
|
||||
TokenElevation,
|
||||
TokenHasRestrictions,
|
||||
TokenAccessInformation,
|
||||
TokenVirtualizationAllowed,
|
||||
TokenVirtualizationEnabled,
|
||||
TokenIntegrityLevel,
|
||||
TokenUIAccess,
|
||||
TokenMandatoryPolicy,
|
||||
TokenLogonSid,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_DEBUG) || defined(BUILD_DBGRELEASE)
|
||||
//Simple debug helpers:
|
||||
#define BUILD_DBG
|
||||
/** /#define BUILD_XPTEST //Pretend UAC exists and "elevate" with NT runas */
|
||||
#define DBG_RESETDBGVIEW() do{HWND hDbgView=FindWindowA("dbgviewClass",0);PostMessage(hDbgView,WM_COMMAND,40020,0);if(0)SetForegroundWindow(hDbgView);}while(0)
|
||||
#define _pp_MakeStr_(x) #x
|
||||
#define pp_MakeStr(x) _pp_MakeStr_(x)
|
||||
#define TRACE OutputDebugStringA
|
||||
#define DBGONLY(_x) _x
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(_x) do{if(!(_x)){MessageBoxA(GetActiveWindow(),#_x##"\n\n"##__FILE__##":"## pp_MakeStr(__LINE__),"SimpleAssert",0);/*TRACE(#_x##"\n"##__FILE__##":" pp_MakeStr(__LINE__)"\n");*/}}while(0)
|
||||
#endif
|
||||
#define VERIFY(_x) ASSERT(_x)
|
||||
static void TRACEF(const char*fmt,...) {va_list a;va_start(a,fmt);static TCHAR b[1024*4];if (sizeof(TCHAR)!=sizeof(char)){static TCHAR fmtBuf[COUNTOF(b)];VERIFY(wsprintf(fmtBuf,_T("%hs"),fmt)<COUNTOF(fmtBuf));fmt=(LPCSTR)fmtBuf;}wvsprintf(b,(TCHAR*)fmt,a);OutputDebugString(b);}
|
||||
#else
|
||||
#define TRACE /*(void)0*/
|
||||
#define DBGONLY(_x)
|
||||
#define ASSERT(_x)
|
||||
#define VERIFY(_x) ((void)(_x))
|
||||
#define TRACEF TRACE
|
||||
#endif /* DEBUG */
|
||||
|
||||
#endif /* APSTUDIO_INVOKED */
|
||||
|
||||
2
binary
2
binary
Submodule binary updated: 01d73965dc...1fb9ddfa9a
@@ -441,7 +441,6 @@ Section "${APPLICATION_NAME}" SEC_APPLICATION
|
||||
File "${MING_BIN}\libGLESv2.dll"
|
||||
File "${MING_BIN}\libjpeg-8.dll"
|
||||
File "${MING_BIN}\libpcre16-0.dll"
|
||||
File "${MING_BIN}\libproxy.dll"
|
||||
File "${MING_BIN}\libsqlite3-0.dll"
|
||||
File "${MING_BIN}\libcrypto-10.dll"
|
||||
File "${MING_BIN}\libssl-10.dll"
|
||||
|
||||
@@ -576,7 +576,8 @@ int csync_commit(CSYNC *ctx) {
|
||||
_csync_clean_ctx(ctx);
|
||||
|
||||
ctx->remote.read_from_db = 0;
|
||||
ctx->read_from_db_disabled = 0;
|
||||
ctx->read_remote_from_db = true;
|
||||
ctx->db_is_empty = false;
|
||||
|
||||
|
||||
/* Create new trees */
|
||||
@@ -773,10 +774,3 @@ int csync_set_module_property(CSYNC* ctx, const char* key, void* value)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int csync_set_read_from_db(CSYNC* ctx, int enabled)
|
||||
{
|
||||
ctx->read_from_db_disabled = !enabled;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -550,11 +550,6 @@ void csync_resume(CSYNC *ctx);
|
||||
*/
|
||||
int csync_abort_requested(CSYNC *ctx);
|
||||
|
||||
/**
|
||||
* Specify if it is allowed to read the remote tree from the DB (default to enabled)
|
||||
*/
|
||||
int csync_set_read_from_db(CSYNC* ctx, int enabled);
|
||||
|
||||
char *csync_normalize_etag(const char *);
|
||||
time_t oc_httpdate_parse( const char *date );
|
||||
|
||||
|
||||
@@ -151,11 +151,12 @@ CSYNC_EXCLUDE_TYPE csync_excluded(CSYNC *ctx, const char *path, int filetype) {
|
||||
return match;
|
||||
}
|
||||
|
||||
// See http://support.microsoft.com/kb/74496
|
||||
static const char *win_reserved_words[] = {"CON","PRN","AUX", "NUL",
|
||||
"COM1", "COM2", "COM3", "COM4",
|
||||
"LPT1", "LPT2", "LPT3", "CLOCK$" };
|
||||
|
||||
// See http://support.microsoft.com/kb/74496 and
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
|
||||
// Additionally, we ignore '$Recycle.Bin', see https://github.com/owncloud/client/issues/2955
|
||||
static const char* win_reserved_words[] = {"CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5",
|
||||
"COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4",
|
||||
"LPT5", "LPT6", "LPT7", "LPT8", "LPT9", "CLOCK$", "$Recycle.Bin" };
|
||||
|
||||
bool csync_is_windows_reserved_word(const char* filename) {
|
||||
|
||||
|
||||
@@ -151,7 +151,17 @@ struct csync_s {
|
||||
int status;
|
||||
volatile int abort;
|
||||
void *rename_info;
|
||||
int read_from_db_disabled;
|
||||
|
||||
/**
|
||||
* Specify if it is allowed to read the remote tree from the DB (default to enabled)
|
||||
*/
|
||||
bool read_remote_from_db;
|
||||
|
||||
/**
|
||||
* If true, the DB is considered empty and all reads are skipped. (default is false)
|
||||
* This is useful during the initial local discovery as it speeds it up significantly.
|
||||
*/
|
||||
bool db_is_empty;
|
||||
|
||||
struct csync_owncloud_ctx_s *owncloud_context;
|
||||
|
||||
|
||||
@@ -156,8 +156,8 @@ static int _csync_merge_algorithm_visitor(void *obj, void *data) {
|
||||
}
|
||||
|
||||
if( tmp ) {
|
||||
if( tmp->path ) {
|
||||
len = strlen( tmp->path );
|
||||
len = strlen( tmp->path );
|
||||
if( len > 0 ) {
|
||||
h = c_jhash64((uint8_t *) tmp->path, len, 0);
|
||||
/* First, check that the file is NOT in our tree (another file with the same name was added) */
|
||||
node = c_rbtree_find(ctx->current == REMOTE_REPLICA ? ctx->remote.tree : ctx->local.tree, &h);
|
||||
|
||||
@@ -298,7 +298,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx,
|
||||
csync_file_stat_t *st = NULL;
|
||||
int rc;
|
||||
|
||||
if( !ctx ) {
|
||||
if( !ctx || ctx->db_is_empty ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_file_id(CSYNC *ctx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( !ctx ) {
|
||||
if( !ctx || ctx->db_is_empty ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( !ctx ) {
|
||||
if( !ctx || ctx->db_is_empty ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ int csync_statedb_get_below_path( CSYNC *ctx, const char *path ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( !ctx ) {
|
||||
if( !ctx || ctx->db_is_empty ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
||||
|| !c_streq(fs->remotePerm, tmp->remotePerm)))
|
||||
|| (ctx->current == LOCAL_REPLICA && fs->inode != tmp->inode);
|
||||
if (type == CSYNC_FTW_TYPE_DIR && ctx->current == REMOTE_REPLICA
|
||||
&& !metadata_differ && !ctx->read_from_db_disabled) {
|
||||
&& !metadata_differ && ctx->read_remote_from_db) {
|
||||
/* If both etag and file id are equal for a directory, read all contents from
|
||||
* the database.
|
||||
* The metadata comparison ensure that we fetch all the file id or permission when
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "c_lib.h"
|
||||
#include "csync.h"
|
||||
#include "csync_log.h"
|
||||
|
||||
csync_vio_file_stat_t *csync_vio_file_stat_new(void) {
|
||||
csync_vio_file_stat_t *file_stat = (csync_vio_file_stat_t *) c_malloc(sizeof(csync_vio_file_stat_t));
|
||||
@@ -30,7 +31,9 @@ csync_vio_file_stat_t *csync_vio_file_stat_new(void) {
|
||||
csync_vio_file_stat_t* csync_vio_file_stat_copy(csync_vio_file_stat_t *file_stat) {
|
||||
csync_vio_file_stat_t *file_stat_cpy = csync_vio_file_stat_new();
|
||||
memcpy(file_stat_cpy, file_stat, sizeof(csync_vio_file_stat_t));
|
||||
file_stat_cpy->etag = c_strdup(file_stat_cpy->etag);
|
||||
if (file_stat_cpy->fields & CSYNC_VIO_FILE_STAT_FIELDS_ETAG) {
|
||||
file_stat_cpy->etag = c_strdup(file_stat_cpy->etag);
|
||||
}
|
||||
if (file_stat_cpy->directDownloadCookies) {
|
||||
file_stat_cpy->directDownloadCookies = c_strdup(file_stat_cpy->directDownloadCookies);
|
||||
}
|
||||
@@ -68,6 +71,7 @@ void csync_vio_file_stat_set_file_id( csync_vio_file_stat_t *dst, const char* sr
|
||||
void csync_vio_set_file_id( char* dst, const char *src ) {
|
||||
if( src && dst ) {
|
||||
if( strlen(src) > FILE_ID_BUF_SIZE ) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Ignoring file_id because it is too long: %s", src);
|
||||
strcpy(dst, "");
|
||||
} else {
|
||||
strcpy(dst, src);
|
||||
|
||||
@@ -151,9 +151,9 @@ ownCloud Client provides the ability to add custom patterns.
|
||||
|
||||
By default, the ownCloud Client ignores the following files:
|
||||
|
||||
- Files matched by one of the patterns defined in :ref:`ignoredFilesEditor-label`.
|
||||
- Files containing characters that do not work on certain file systems (`\, /, :, ?, *, ", >, <, |`).
|
||||
* Files starting in ``.csync_journal.db*``, as these files are reserved for journalling.
|
||||
* Files matched by one of the patterns defined in the Ignored Files Editor
|
||||
* Files containing characters that do not work on certain file systems ``(`\, /, :, ?, *, ", >, <, |`)``.
|
||||
* Files starting in ``.csync_journal.db``, as these files are reserved for journalling.
|
||||
|
||||
If a pattern selected using a checkbox in the `ignoredFilesEditor-label` (or if
|
||||
a line in the exclude file starts with the character `]` directly followed by
|
||||
@@ -204,3 +204,69 @@ journal. This function can be used to recreate the journal database.
|
||||
|
||||
.. note:: We recommend that you use this function only when advised to do so by
|
||||
ownCloud support staff.
|
||||
|
||||
Custom WebDAV Properties
|
||||
------------------------
|
||||
|
||||
In the communication between client and server a couple of custom WebDAV properties
|
||||
were introduced. They are either needed for sync functionality or help have a positive
|
||||
effect on synchronization performance.
|
||||
|
||||
This chapter describes additional xml elements which the server returns in response
|
||||
to a successful PROPFIND request on a file or directory. The elements are returned in
|
||||
the namespace oc.
|
||||
|
||||
Server Side Permissions
|
||||
------------------------
|
||||
|
||||
The XML element ``<oc:permissions>`` represents the permission- and sharing state of the
|
||||
item. It is a list of characters, and each of the chars has a meaning as outlined
|
||||
in the table below:
|
||||
|
||||
+----+----------------+-------------------------------------------+
|
||||
|Code| Resource | Description |
|
||||
+----+----------------+-------------------------------------------+
|
||||
| S | File or Folder | is shared |
|
||||
+----+----------------+-------------------------------------------+
|
||||
| R | File or Folder | can share (includes reshare) |
|
||||
+----+----------------+-------------------------------------------+
|
||||
| M | File or Folder | is mounted (like on DropBox, Samba, etc.) |
|
||||
+----+----------------+-------------------------------------------+
|
||||
| W | File | can write file |
|
||||
+----+----------------+-------------------------------------------+
|
||||
| C | Folder |can create file in folder |
|
||||
+----+----------------+-------------------------------------------+
|
||||
| K | Folder | can create folder (mkdir) |
|
||||
+----+----------------+-------------------------------------------+
|
||||
| D | File or Folder |can delete file or folder |
|
||||
+----+----------------+-------------------------------------------+
|
||||
| N | File or Folder | can rename file or folder |
|
||||
+----+----------------+-------------------------------------------+
|
||||
| V | File or Folder | can move file or folder |
|
||||
+----+----------------+-------------------------------------------+
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
<oc:permissions>RDNVCK</oc:permissions>
|
||||
|
||||
File- or Directory Size
|
||||
-----------------------
|
||||
|
||||
The XML element ``<oc:size>`` represents the file- or directory size in bytes. For
|
||||
directories, the size of the whole file tree underneath the directory is accumulated.
|
||||
|
||||
Example:
|
||||
|
||||
<oc:size>2429176697</oc:size>
|
||||
|
||||
FileID
|
||||
------
|
||||
|
||||
The XML element ``<oc:id>`` represents the so called file ID. It is a non volatile string id
|
||||
that stays constant as long as the file exists. It is not changed if the file changes or
|
||||
is renamed or moved.
|
||||
|
||||
Example:
|
||||
|
||||
<oc:id>00000020oc5cfy6qqizm</oc:id>
|
||||
|
||||
@@ -18,6 +18,9 @@ and then use their package managers to install the desktop sync client. Linux
|
||||
users will also update their sync clients via package manager, and the client
|
||||
will display a notification when an update is available.
|
||||
|
||||
Linux users must also have a password manager enabled, such as GNOME Keyring or
|
||||
KWallet, so that the sync client can login automatically.
|
||||
|
||||
Improvements and New Features
|
||||
-----------------------------
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class SocketConnect(GObject.GObject):
|
||||
print("Sending failed.")
|
||||
self.reconnect()
|
||||
else:
|
||||
print "Cannot send, not connected!"
|
||||
print("Cannot send, not connected!")
|
||||
|
||||
def addListener(self, listener):
|
||||
self._listeners.append(listener)
|
||||
@@ -85,7 +85,7 @@ class SocketConnect(GObject.GObject):
|
||||
self.connected = True
|
||||
print("Setting connected to %r" % self.connected )
|
||||
self._watch_id = GObject.io_add_watch(self._sock, GObject.IO_IN, self._handle_notify)
|
||||
print "Socket watch id: "+str(self._watch_id)
|
||||
print("Socket watch id: "+str(self._watch_id))
|
||||
return False # don't run again
|
||||
except Exception as e:
|
||||
print("Could not connect to unix socket." + str(e))
|
||||
@@ -175,7 +175,7 @@ class MenuExtension(GObject.GObject, Nautilus.MenuProvider):
|
||||
|
||||
def menu_share(self, menu, file):
|
||||
filename = get_local_path(file.get_uri())
|
||||
print "Share file "+filename
|
||||
print("Share file "+filename)
|
||||
socketConnect.sendCommand("SHARE:"+filename+"\n")
|
||||
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ IFACEMETHODIMP OCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT
|
||||
|
||||
assert(!info.shareMenuTitle.empty());
|
||||
MENUITEMINFO mii = { sizeof(mii) };
|
||||
mii.fMask = MIIM_BITMAP | MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_STATE;
|
||||
mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_STATE;
|
||||
mii.wID = idCmdFirst + IDM_SHARE;
|
||||
mii.fType = MFT_STRING;
|
||||
mii.dwTypeData = &info.shareMenuTitle[0];
|
||||
|
||||
@@ -83,7 +83,6 @@
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;OCCONTEXTMENU_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\OCUtil;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@@ -101,8 +100,8 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;OCCONTEXTMENU_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\OCUtil;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;_USING_V110_SDK71_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -132,6 +131,7 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\OCUtil;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;_USING_V110_SDK71_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>..\$(Configuration)\$(Platform);</AdditionalLibraryDirectories>
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>..\OCUtil;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;_USING_V110_SDK71_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@@ -145,6 +146,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>..\OCUtil;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;_USING_V110_SDK71_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
* details.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "CommunicationSocket.h"
|
||||
#include "UtilConstants.h"
|
||||
#include "StringUtil.h"
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@@ -118,6 +119,8 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PreprocessorDefinitions>NDEBUG;_USING_V110_SDK71_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@@ -133,6 +136,8 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PreprocessorDefinitions>NDEBUG;_USING_V110_SDK71_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@@ -159,6 +164,8 @@
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StringUtil.cpp" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -194,6 +194,9 @@ void parseOptions( const QStringList& app_args, CmdOptions *options )
|
||||
if (options->target_url.startsWith("http"))
|
||||
options->target_url.replace(0, 4, "owncloud");
|
||||
options->source_dir = args.takeLast();
|
||||
if (!options->source_dir.endsWith('/')) {
|
||||
options->source_dir.append('/');
|
||||
}
|
||||
if( !QFile::exists( options->source_dir )) {
|
||||
std::cerr << "Source dir '" << qPrintable(options->source_dir) << "' does not exist." << std::endl;
|
||||
exit(1);
|
||||
@@ -442,7 +445,9 @@ restart_sync:
|
||||
if (!f.open(QFile::ReadOnly)) {
|
||||
qCritical() << "Could not open file containing the list of unsynced folders: " << options.unsyncedfolders;
|
||||
} else {
|
||||
selectiveSyncList = QString::fromUtf8(f.readAll()).split('\n');
|
||||
// filter out empty lines and comments
|
||||
selectiveSyncList = QString::fromUtf8(f.readAll()).split('\n').filter(QRegExp("\\S+")).filter(QRegExp("^[^#]"));
|
||||
|
||||
for (int i = 0; i < selectiveSyncList.count(); ++i) {
|
||||
if (!selectiveSyncList.at(i).endsWith(QLatin1Char('/'))) {
|
||||
selectiveSyncList[i].append(QLatin1Char('/'));
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
#include "account.h"
|
||||
#include "simplesslerrorhandler.h"
|
||||
|
||||
bool SimpleSslErrorHandler::handleErrors(QList<QSslError> errors, QList<QSslCertificate> *certs, OCC::AccountPtr account)
|
||||
bool SimpleSslErrorHandler::handleErrors(QList<QSslError> errors, const QSslConfiguration &conf, QList<QSslCertificate> *certs, OCC::AccountPtr account)
|
||||
{
|
||||
(void) account;
|
||||
(void) conf;
|
||||
|
||||
if (!certs) {
|
||||
qDebug() << "Certs parameter required but is NULL!";
|
||||
|
||||
@@ -20,7 +20,7 @@ class QSslCertificate;
|
||||
|
||||
class SimpleSslErrorHandler : public OCC::AbstractSslErrorHandler {
|
||||
public:
|
||||
bool handleErrors(QList<QSslError> errors, QList<QSslCertificate> *certs, OCC::AccountPtr) Q_DECL_OVERRIDE;
|
||||
bool handleErrors(QList<QSslError> errors, const QSslConfiguration &conf, QList<QSslCertificate> *certs, OCC::AccountPtr) Q_DECL_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // SIMPLESSLERRORHANDLER_H
|
||||
|
||||
@@ -50,4 +50,16 @@ if(NOT BUILD_LIBRARIES_ONLY)
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
# FIXME: The following lines are dup in src/gui and src/cmd because it needs to be done after both are installed
|
||||
#FIXME: find a nice solution to make the second if(BUILD_OWNCLOUD_OSX_BUNDLE) unnecessary
|
||||
# currently it needs to be done because the code right above needs to be executed no matter
|
||||
# if building a bundle or not and the install_qt4_executable needs to be called afterwards
|
||||
if(BUILD_OWNCLOUD_OSX_BUNDLE)
|
||||
get_target_property (QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
|
||||
install(CODE "
|
||||
message(STATUS \"Deploying (Qt) dependencies and fixing library pathes...\")
|
||||
execute_process(COMMAND \"${CMAKE_SOURCE_DIR}/admin/osx/macdeployqt.py\" ${CMAKE_INSTALL_PREFIX}/${OWNCLOUD_OSX_BUNDLE} ${QT_QMAKE_EXECUTABLE})
|
||||
" COMPONENT RUNTIME)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -154,10 +154,19 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||
|
||||
qt_add_translation(client_I18N ${TRANSLATIONS})
|
||||
|
||||
IF( WIN32 )
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.rc
|
||||
@ONLY)
|
||||
set(client_version ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||
ENDIF()
|
||||
|
||||
set( final_src
|
||||
${MIRALL_RC_SRC}
|
||||
${client_SRCS}
|
||||
${client_UI_SRCS}
|
||||
${client_version}
|
||||
${guiMoc}
|
||||
${client_I18N}
|
||||
${3rdparty_SRC}
|
||||
|
||||
@@ -43,7 +43,9 @@ void AccountStateManager::setAccountState(AccountState *accountState)
|
||||
emit accountStateRemoved(_accountState);
|
||||
}
|
||||
_accountState = accountState;
|
||||
emit accountStateAdded(accountState);
|
||||
if (accountState) {
|
||||
emit accountStateAdded(accountState);
|
||||
}
|
||||
}
|
||||
|
||||
void AccountStateManager::slotAccountAdded(AccountPtr account)
|
||||
@@ -54,13 +56,15 @@ void AccountStateManager::slotAccountAdded(AccountPtr account)
|
||||
AccountState::AccountState(AccountPtr account)
|
||||
: QObject(account.data())
|
||||
, _account(account)
|
||||
, _quotaInfo(new QuotaInfo(this))
|
||||
, _quotaInfo(0)
|
||||
, _state(AccountState::Disconnected)
|
||||
, _connectionStatus(ConnectionValidator::Undefined)
|
||||
, _waitingForNewCredentials(false)
|
||||
{
|
||||
qRegisterMetaType<AccountState*>("AccountState*");
|
||||
|
||||
_quotaInfo = new QuotaInfo(this); // Need to be initialized when 'this' is fully initialized
|
||||
|
||||
connect(account.data(), SIGNAL(invalidCredentials()),
|
||||
SLOT(slotInvalidCredentials()));
|
||||
connect(account.data(), SIGNAL(credentialsFetched(AbstractCredentials*)),
|
||||
@@ -179,6 +183,15 @@ void AccountState::checkConnectivity()
|
||||
conValidator->checkAuthentication();
|
||||
} else {
|
||||
// Check the server and then the auth.
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
// There seems to be a bug in Qt on Windows where QNAM sometimes stops
|
||||
// working correctly after the computer woke up from sleep. See #2895 #2899
|
||||
// and #2973.
|
||||
// As an attempted workaround, reset the QNAM regularly if the account is
|
||||
// disconnected.
|
||||
account()->resetNetworkAccessManager();
|
||||
#endif
|
||||
conValidator->checkServerAndAuth();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,10 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(WITH_CRASHREPORTER)
|
||||
#include <libcrashreporter-handler/Handler.h>
|
||||
#endif
|
||||
|
||||
#include <QTranslator>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
@@ -106,6 +110,11 @@ Application::Application(int &argc, char **argv) :
|
||||
if (isRunning())
|
||||
return;
|
||||
|
||||
#if defined(WITH_CRASHREPORTER)
|
||||
if (ConfigFile().crashReporter())
|
||||
_crashHandler.reset(new CrashReporter::Handler( QDir::tempPath(), true, CRASHREPORTER_EXECUTABLE ));
|
||||
#endif
|
||||
|
||||
setupLogging();
|
||||
setupTranslations();
|
||||
|
||||
@@ -149,8 +158,8 @@ Application::Application(int &argc, char **argv) :
|
||||
slotAccountStateAdded(ai);
|
||||
}
|
||||
|
||||
connect(FolderMan::instance()->socketApi(), SIGNAL(shareCommandReceived(QString, QString)),
|
||||
_gui, SLOT(slotShowShareDialog(QString, QString)));
|
||||
connect(FolderMan::instance()->socketApi(), SIGNAL(shareCommandReceived(QString, QString, bool)),
|
||||
_gui, SLOT(slotShowShareDialog(QString, QString, bool)));
|
||||
|
||||
// startup procedure.
|
||||
connect(&_checkConnectionTimer, SIGNAL(timeout()), this, SLOT(slotCheckConnection()));
|
||||
@@ -171,7 +180,8 @@ Application::Application(int &argc, char **argv) :
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
// qDebug() << "* OCC shutdown";
|
||||
// Remove the account from the account manager so it can be deleted.
|
||||
AccountManager::instance()->setAccount(AccountPtr());
|
||||
}
|
||||
|
||||
void Application::slotLogin()
|
||||
@@ -394,7 +404,10 @@ void Application::parseOptions(const QStringList &options)
|
||||
} else if (option == QLatin1String("--confdir")) {
|
||||
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
|
||||
QString confDir = it.next();
|
||||
ConfigFile::setConfDir( confDir );
|
||||
if (!ConfigFile::setConfDir( confDir )) {
|
||||
std::cerr << "Invalid path passed to --confdir" << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
} else {
|
||||
showHelp();
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ class QMessageBox;
|
||||
class QSystemTrayIcon;
|
||||
class QSocket;
|
||||
|
||||
namespace CrashReporter {
|
||||
class Handler;
|
||||
}
|
||||
|
||||
namespace OCC {
|
||||
class Theme;
|
||||
class Folder;
|
||||
@@ -109,6 +113,9 @@ private:
|
||||
|
||||
QTimer _checkConnectionTimer;
|
||||
|
||||
#if defined(WITH_CRASHREPORTER)
|
||||
QScopedPointer<CrashReporter::Handler> _crashHandler;
|
||||
#endif
|
||||
QScopedPointer<FolderMan> _folderManager;
|
||||
|
||||
friend class ownCloudGui; // for _startupNetworkError
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "account.h"
|
||||
#include "accountmigrator.h"
|
||||
#include "accountstate.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include <CoreServices/CoreServices.h>
|
||||
@@ -105,7 +106,6 @@ void FolderMan::unloadFolder( const QString& alias )
|
||||
_socketApi->slotUnregisterPath(alias);
|
||||
}
|
||||
|
||||
_folderChangeSignalMapper->removeMappings(f);
|
||||
if( _folderWatchers.contains(alias)) {
|
||||
_folderWatchers.remove(alias);
|
||||
}
|
||||
@@ -852,9 +852,10 @@ bool FolderMan::startFromScratch( const QString& localFolder )
|
||||
|
||||
// Make a backup of the folder/file.
|
||||
QString newName = getBackupName( parentDir.absoluteFilePath( folderName ) );
|
||||
if( !parentDir.rename( fi.absoluteFilePath(), newName ) ) {
|
||||
QString renameError;
|
||||
if( !FileSystem::rename( fi.absoluteFilePath(), newName, &renameError ) ) {
|
||||
qDebug() << "startFromScratch: Could not rename" << fi.absoluteFilePath()
|
||||
<< "to" << newName;
|
||||
<< "to" << newName << "error:" << renameError;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -872,6 +873,13 @@ void FolderMan::setDirtyProxy(bool value)
|
||||
foreach( Folder *f, _folderMap.values() ) {
|
||||
if(f) {
|
||||
f->setProxyDirty(value);
|
||||
|
||||
if (f->accountState() && f->accountState()->account()
|
||||
&& f->accountState()->account()->networkAccessManager()) {
|
||||
// Need to do this have us not use the old determined system proxy
|
||||
f->accountState()->account()->networkAccessManager()->setProxy(
|
||||
QNetworkProxy(QNetworkProxy::DefaultProxy));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "networkjobs.h"
|
||||
#include "account.h"
|
||||
#include "selectivesyncdialog.h"
|
||||
#include "creds/abstractcredentials.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
@@ -238,10 +239,19 @@ FolderWizardRemotePath::FolderWizardRemotePath(AccountPtr account)
|
||||
|
||||
connect(_ui.addFolderButton, SIGNAL(clicked()), SLOT(slotAddRemoteFolder()));
|
||||
connect(_ui.refreshButton, SIGNAL(clicked()), SLOT(slotRefreshFolders()));
|
||||
connect(_ui.folderTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), SIGNAL(completeChanged()));
|
||||
connect(_ui.folderTreeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), SIGNAL(completeChanged()));
|
||||
connect(_ui.folderTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem*)), SLOT(slotItemExpanded(QTreeWidgetItem*)));
|
||||
connect(_ui.folderTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), SLOT(slotCurrentItemChanged(QTreeWidgetItem*)));
|
||||
connect(_ui.folderEntry, SIGNAL(textEdited(QString)), SLOT(slotFolderEntryEdited(QString)));
|
||||
|
||||
_lscolTimer.setInterval(500);
|
||||
_lscolTimer.setSingleShot(true);
|
||||
connect(&_lscolTimer, SIGNAL(timeout()), SLOT(slotLsColFolderEntry()));
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
_ui.folderTreeWidget->header()->setSectionResizeMode(0,QHeaderView::ResizeToContents);
|
||||
// Make sure that there will be a scrollbar when the contents is too wide
|
||||
_ui.folderTreeWidget->header()->setStretchLastSection(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void FolderWizardRemotePath::slotAddRemoteFolder()
|
||||
@@ -287,14 +297,20 @@ void FolderWizardRemotePath::slotCreateRemoteFolderFinished(QNetworkReply::Netwo
|
||||
qDebug() << "** webdav mkdir request finished";
|
||||
showWarn(tr("Folder was successfully created on %1.").arg(Theme::instance()->appNameGUI()));
|
||||
slotRefreshFolders();
|
||||
_ui.folderEntry->setText(static_cast<MkColJob *>(sender())->path());
|
||||
slotLsColFolderEntry();
|
||||
}
|
||||
}
|
||||
|
||||
void FolderWizardRemotePath::slotHandleNetworkError(QNetworkReply *reply)
|
||||
{
|
||||
qDebug() << "** webdav mkdir request failed:" << reply->error();
|
||||
showWarn(tr("Failed to create the folder on %1. Please check manually.")
|
||||
.arg(Theme::instance()->appNameGUI()));
|
||||
if( reply && !_account->credentials()->stillValid(reply) ) {
|
||||
showWarn(tr("Authentication failed accessing %1").arg(Theme::instance()->appNameGUI()));
|
||||
} else {
|
||||
showWarn(tr("Failed to create the folder on %1. Please check manually.")
|
||||
.arg(Theme::instance()->appNameGUI()));
|
||||
}
|
||||
}
|
||||
|
||||
static QTreeWidgetItem* findFirstChild(QTreeWidgetItem *parent, const QString& text)
|
||||
@@ -310,27 +326,58 @@ static QTreeWidgetItem* findFirstChild(QTreeWidgetItem *parent, const QString& t
|
||||
|
||||
void FolderWizardRemotePath::recursiveInsert(QTreeWidgetItem *parent, QStringList pathTrail, QString path)
|
||||
{
|
||||
QFileIconProvider prov;
|
||||
QIcon folderIcon = prov.icon(QFileIconProvider::Folder);
|
||||
if (pathTrail.size() == 0) {
|
||||
if (path.endsWith('/')) {
|
||||
path.chop(1);
|
||||
}
|
||||
parent->setToolTip(0, path);
|
||||
parent->setData(0, Qt::UserRole, path);
|
||||
} else {
|
||||
QTreeWidgetItem *item = findFirstChild(parent, pathTrail.first());
|
||||
if (!item) {
|
||||
item = new QTreeWidgetItem(parent);
|
||||
item->setIcon(0, folderIcon);
|
||||
item->setText(0, pathTrail.first());
|
||||
item->setData(0, Qt::UserRole, pathTrail.first());
|
||||
item->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
|
||||
}
|
||||
if (pathTrail.isEmpty())
|
||||
return;
|
||||
|
||||
pathTrail.removeFirst();
|
||||
recursiveInsert(item, pathTrail, path);
|
||||
const QString parentPath = parent->data(0, Qt::UserRole).toString();
|
||||
const QString folderName = pathTrail.first();
|
||||
QString folderPath;
|
||||
if (parentPath == QLatin1String("/")) {
|
||||
folderPath = folderName;
|
||||
} else {
|
||||
folderPath = parentPath + "/" + folderName;
|
||||
}
|
||||
QTreeWidgetItem *item = findFirstChild(parent, folderName);
|
||||
if (!item) {
|
||||
item = new QTreeWidgetItem(parent);
|
||||
QFileIconProvider prov;
|
||||
QIcon folderIcon = prov.icon(QFileIconProvider::Folder);
|
||||
item->setIcon(0, folderIcon);
|
||||
item->setText(0, folderName);
|
||||
item->setData(0, Qt::UserRole, folderPath);
|
||||
item->setToolTip(0, folderPath);
|
||||
item->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
|
||||
}
|
||||
|
||||
pathTrail.removeFirst();
|
||||
recursiveInsert(item, pathTrail, path);
|
||||
}
|
||||
|
||||
bool FolderWizardRemotePath::selectByPath(QString path)
|
||||
{
|
||||
if (path.startsWith(QLatin1Char('/'))) {
|
||||
path = path.mid(1);
|
||||
}
|
||||
if (path.endsWith(QLatin1Char('/'))) {
|
||||
path.chop(1);
|
||||
}
|
||||
|
||||
QTreeWidgetItem *it = _ui.folderTreeWidget->topLevelItem(0);
|
||||
if (!path.isEmpty()) {
|
||||
const QStringList pathTrail = path.split(QLatin1Char('/'));
|
||||
foreach (const QString& path, pathTrail) {
|
||||
if (!it) {
|
||||
return false;
|
||||
}
|
||||
it = findFirstChild(it, path);
|
||||
}
|
||||
}
|
||||
if (!it) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_ui.folderTreeWidget->setCurrentItem(it);
|
||||
return true;
|
||||
}
|
||||
|
||||
void FolderWizardRemotePath::slotUpdateDirectories(const QStringList &list)
|
||||
@@ -362,6 +409,7 @@ void FolderWizardRemotePath::slotRefreshFolders()
|
||||
SLOT(slotUpdateDirectories(QStringList)));
|
||||
job->start();
|
||||
_ui.folderTreeWidget->clear();
|
||||
_ui.folderEntry->clear();
|
||||
}
|
||||
|
||||
void FolderWizardRemotePath::slotItemExpanded(QTreeWidgetItem *item)
|
||||
@@ -374,6 +422,49 @@ void FolderWizardRemotePath::slotItemExpanded(QTreeWidgetItem *item)
|
||||
job->start();
|
||||
}
|
||||
|
||||
void FolderWizardRemotePath::slotCurrentItemChanged(QTreeWidgetItem *item)
|
||||
{
|
||||
if (item) {
|
||||
QString dir = item->data(0, Qt::UserRole).toString();
|
||||
if (!dir.startsWith(QLatin1Char('/'))) {
|
||||
dir.prepend(QLatin1Char('/'));
|
||||
}
|
||||
_ui.folderEntry->setText(dir);
|
||||
}
|
||||
|
||||
emit completeChanged();
|
||||
}
|
||||
|
||||
void FolderWizardRemotePath::slotFolderEntryEdited(const QString& text)
|
||||
{
|
||||
if (selectByPath(text)) {
|
||||
_lscolTimer.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
_ui.folderTreeWidget->setCurrentItem(0);
|
||||
_lscolTimer.start(); // avoid sending a request on each keystroke
|
||||
}
|
||||
|
||||
void FolderWizardRemotePath::slotLsColFolderEntry()
|
||||
{
|
||||
QString path = _ui.folderEntry->text();
|
||||
if (path.startsWith(QLatin1Char('/')))
|
||||
path = path.mid(1);
|
||||
|
||||
LsColJob *job = new LsColJob(_account, path, this);
|
||||
job->setProperties(QList<QByteArray>() << "resourcetype");
|
||||
connect(job, SIGNAL(directoryListingSubfolders(QStringList)),
|
||||
SLOT(slotTypedPathFound(QStringList)));
|
||||
job->start();
|
||||
}
|
||||
|
||||
void FolderWizardRemotePath::slotTypedPathFound(const QStringList& subpaths)
|
||||
{
|
||||
slotUpdateDirectories(subpaths);
|
||||
selectByPath(_ui.folderEntry->text());
|
||||
}
|
||||
|
||||
FolderWizardRemotePath::~FolderWizardRemotePath()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -86,11 +86,17 @@ protected slots:
|
||||
void slotUpdateDirectories(const QStringList&);
|
||||
void slotRefreshFolders();
|
||||
void slotItemExpanded(QTreeWidgetItem*);
|
||||
void slotCurrentItemChanged(QTreeWidgetItem*);
|
||||
void slotFolderEntryEdited(const QString& text);
|
||||
void slotLsColFolderEntry();
|
||||
void slotTypedPathFound(const QStringList& subpaths);
|
||||
private:
|
||||
void recursiveInsert(QTreeWidgetItem *parent, QStringList pathTrail, QString path);
|
||||
bool selectByPath(QString path);
|
||||
Ui_FolderWizardTargetPage _ui;
|
||||
bool _warnWasVisible;
|
||||
AccountPtr _account;
|
||||
QTimer _lscolTimer;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="3" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="folderEntry"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QFrame" name="warnFrame">
|
||||
<property name="palette">
|
||||
<palette>
|
||||
@@ -179,7 +182,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
||||
@@ -28,13 +28,6 @@
|
||||
|
||||
#include "updater/updater.h"
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#ifdef WITH_CRASHREPORTER
|
||||
#include "configfile.h"
|
||||
#include <libcrashreporter-handler/Handler.h>
|
||||
#endif
|
||||
|
||||
#include <QTimer>
|
||||
#include <QMessageBox>
|
||||
|
||||
@@ -59,13 +52,6 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
OCC::Application app(argc, argv);
|
||||
|
||||
|
||||
#ifdef WITH_CRASHREPORTER
|
||||
CrashReporter::Handler* handler = new CrashReporter::Handler( QDir::tempPath(), true, CRASHREPORTER_EXECUTABLE );
|
||||
ConfigFile cfgFile;
|
||||
handler->setActive(cfgFile.crashReporter());
|
||||
#endif
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
|
||||
@@ -642,7 +642,7 @@ void ownCloudGui::raiseDialog( QWidget *raiseWidget )
|
||||
}
|
||||
|
||||
|
||||
void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &localPath)
|
||||
void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &localPath, bool resharingAllowed)
|
||||
{
|
||||
AccountPtr account = AccountManager::instance()->account();
|
||||
if (!account) {
|
||||
@@ -651,7 +651,7 @@ void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &l
|
||||
}
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Opening share dialog";
|
||||
ShareDialog *w = new ShareDialog(account, sharePath, localPath);
|
||||
ShareDialog *w = new ShareDialog(account, sharePath, localPath, resharingAllowed);
|
||||
w->getShares();
|
||||
w->setAttribute( Qt::WA_DeleteOnClose, true );
|
||||
raiseDialog(w);
|
||||
|
||||
@@ -70,7 +70,7 @@ public slots:
|
||||
void slotHelp();
|
||||
void slotOpenPath(const QString& path);
|
||||
void slotAccountStateChanged();
|
||||
void slotShowShareDialog(const QString &sharePath, const QString &localPath);
|
||||
void slotShowShareDialog(const QString &sharePath, const QString &localPath, bool resharingAllowed);
|
||||
|
||||
private slots:
|
||||
void slotDisplayIdle();
|
||||
|
||||
@@ -145,6 +145,9 @@ void OwncloudSetupWizard::slotDetermineAuthType(const QString &urlString)
|
||||
}
|
||||
AccountPtr account = _ocWizard->account();
|
||||
account->setUrl(url);
|
||||
// Reset the proxy which might had been determined previously in ConnectionValidator::checkServerAndAuth()
|
||||
// when there was a previous account.
|
||||
account->networkAccessManager()->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
|
||||
// Set fake credentials beforfe we check what credential it actually is.
|
||||
account->setCredentials(CredentialsFactory::create("dummy"));
|
||||
CheckServerJob *job = new CheckServerJob(_ocWizard->account(), this);
|
||||
@@ -214,11 +217,53 @@ void OwncloudSetupWizard::testOwnCloudConnect()
|
||||
auto *job = new PropfindJob(account, "/", this);
|
||||
job->setIgnoreCredentialFailure(true);
|
||||
job->setProperties(QList<QByteArray>() << "getlastmodified");
|
||||
connect(job, SIGNAL(result(QVariantMap)), _ocWizard, SLOT(successfulStep()));
|
||||
connect(job, SIGNAL(networkError(QNetworkReply*)), this, SLOT(slotConnectionCheck(QNetworkReply*)));
|
||||
connect(job, SIGNAL(result(QVariantMap)), _ocWizard, SLOT(successfulStep()));
|
||||
connect(job, SIGNAL(finishedWithError()), this, SLOT(slotAuthError()));
|
||||
connect(job, SIGNAL(networkError(QNetworkReply*)), this, SLOT(slotAuthNetworkError(QNetworkReply*)));
|
||||
job->start();
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::slotAuthError()
|
||||
{
|
||||
QString errorMsg;
|
||||
|
||||
PropfindJob* job = qobject_cast<PropfindJob*>(sender());
|
||||
if (!job) {
|
||||
qWarning() << "Can't check for authed redirects. This slot should be invoked from PropfindJob!";
|
||||
return;
|
||||
}
|
||||
|
||||
// If there were redirects on the *authed* requests, also store
|
||||
// the updated server URL, similar to redirects on status.php.
|
||||
QUrl redirectUrl = job->reply()->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
|
||||
if (!redirectUrl.isEmpty()) {
|
||||
qDebug() << "authed request was redirected to" << redirectUrl.toString();
|
||||
|
||||
// strip the expected path
|
||||
QString path = redirectUrl.path();
|
||||
static QString expectedPath = "/" + _ocWizard->account()->davPath();
|
||||
if (path.endsWith(expectedPath)) {
|
||||
path.chop(expectedPath.size());
|
||||
redirectUrl.setPath(path);
|
||||
|
||||
qDebug() << "setting account url to" << redirectUrl.toString();
|
||||
_ocWizard->account()->setUrl(redirectUrl);
|
||||
testOwnCloudConnect();
|
||||
return;
|
||||
} else {
|
||||
errorMsg = tr("The authenticated request to the server was redirected to "
|
||||
"'%1'. The URL is bad, the server is misconfigured.")
|
||||
.arg(redirectUrl.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMsg.isEmpty()) {
|
||||
errorMsg = tr("There was an invalid response to an authenticated webdav request");
|
||||
}
|
||||
_ocWizard->displayError(errorMsg, false);
|
||||
_ocWizard->show();
|
||||
}
|
||||
|
||||
bool OwncloudSetupWizard::checkDowngradeAdvised(QNetworkReply* reply)
|
||||
{
|
||||
if(reply->url().scheme() != QLatin1String("https")) {
|
||||
@@ -242,7 +287,7 @@ bool OwncloudSetupWizard::checkDowngradeAdvised(QNetworkReply* reply)
|
||||
return true;
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::slotConnectionCheck(QNetworkReply* reply)
|
||||
void OwncloudSetupWizard::slotAuthNetworkError(QNetworkReply* reply)
|
||||
{
|
||||
QString msg = reply->errorString();
|
||||
switch (reply->error()) {
|
||||
@@ -291,7 +336,7 @@ void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders(const QString& localFo
|
||||
}
|
||||
if (nextStep) {
|
||||
EntityExistsJob *job = new EntityExistsJob(_ocWizard->account(), _ocWizard->account()->davPath() + remoteFolder, this);
|
||||
connect(job, SIGNAL(exists(QNetworkReply*)), SLOT(slotAuthCheckReply(QNetworkReply*)));
|
||||
connect(job, SIGNAL(exists(QNetworkReply*)), SLOT(slotRemoteFolderExists(QNetworkReply*)));
|
||||
job->start();
|
||||
} else {
|
||||
finalizeSetup( false );
|
||||
@@ -299,7 +344,7 @@ void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders(const QString& localFo
|
||||
}
|
||||
|
||||
// ### TODO move into EntityExistsJob once we decide if/how to return gui strings from jobs
|
||||
void OwncloudSetupWizard::slotAuthCheckReply(QNetworkReply *reply)
|
||||
void OwncloudSetupWizard::slotRemoteFolderExists(QNetworkReply *reply)
|
||||
{
|
||||
bool ok = true;
|
||||
QString error;
|
||||
@@ -519,8 +564,10 @@ bool DetermineAuthTypeJob::finished()
|
||||
} else if (redirection.toString().endsWith(account()->davPath())) {
|
||||
// do a new run
|
||||
_redirects++;
|
||||
resetTimeout();
|
||||
setReply(getRequest(redirection));
|
||||
setupConnections(reply());
|
||||
return false; // don't discard
|
||||
} else {
|
||||
QRegExp shibbolethyWords("SAML|wayf");
|
||||
|
||||
|
||||
@@ -62,10 +62,11 @@ private slots:
|
||||
void slotNoOwnCloudFoundAuthTimeout(const QUrl&url);
|
||||
|
||||
void slotConnectToOCUrl(const QString&);
|
||||
void slotConnectionCheck(QNetworkReply*);
|
||||
void slotAuthNetworkError(QNetworkReply*);
|
||||
void slotAuthError();
|
||||
|
||||
void slotCreateLocalAndRemoteFolders(const QString&, const QString&);
|
||||
void slotAuthCheckReply(QNetworkReply*);
|
||||
void slotRemoteFolderExists(QNetworkReply*);
|
||||
void slotCreateRemoteFolderFinished(QNetworkReply::NetworkError);
|
||||
void slotAssistantFinished( int );
|
||||
void slotSkipFolderConfiguration();
|
||||
|
||||
@@ -73,16 +73,10 @@ ProtocolWidget::ProtocolWidget(QWidget *parent) :
|
||||
_copyBtn->setToolTip( tr("Copy the activity list to the clipboard."));
|
||||
_copyBtn->setEnabled(false);
|
||||
connect(_copyBtn, SIGNAL(clicked()), SLOT(copyToClipboard()));
|
||||
|
||||
ConfigFile cfg;
|
||||
cfg.restoreGeometryHeader(_ui->_treeWidget->header());
|
||||
}
|
||||
|
||||
ProtocolWidget::~ProtocolWidget()
|
||||
{
|
||||
ConfigFile cfg;
|
||||
cfg.saveGeometryHeader(_ui->_treeWidget->header() );
|
||||
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
@@ -137,6 +131,20 @@ void ProtocolWidget::slotRetrySync()
|
||||
folderMan->slotScheduleAllFolders();
|
||||
}
|
||||
|
||||
void ProtocolWidget::showEvent(QShowEvent *ev)
|
||||
{
|
||||
ConfigFile cfg;
|
||||
cfg.restoreGeometryHeader(_ui->_treeWidget->header());
|
||||
QWidget::showEvent(ev);
|
||||
}
|
||||
|
||||
void ProtocolWidget::hideEvent(QHideEvent *ev)
|
||||
{
|
||||
ConfigFile cfg;
|
||||
cfg.saveGeometryHeader(_ui->_treeWidget->header() );
|
||||
QWidget::hideEvent(ev);
|
||||
}
|
||||
|
||||
void ProtocolWidget::cleanIgnoreItems(const QString& folder)
|
||||
{
|
||||
int itemCnt = _ui->_treeWidget->topLevelItemCount();
|
||||
@@ -159,16 +167,11 @@ void ProtocolWidget::cleanIgnoreItems(const QString& folder)
|
||||
|
||||
QString ProtocolWidget::timeString(QDateTime dt, QLocale::FormatType format) const
|
||||
{
|
||||
QLocale loc = QLocale::system();
|
||||
QString timeStr;
|
||||
|
||||
if( format == QLocale::NarrowFormat ) {
|
||||
timeStr = loc.toString(dt, QLocale::NarrowFormat);
|
||||
} else {
|
||||
timeStr = loc.toString(dt, format);
|
||||
}
|
||||
|
||||
return timeStr;
|
||||
const QLocale loc = QLocale::system();
|
||||
QString dtFormat = loc.dateTimeFormat(format);
|
||||
static const QRegExp re("(HH|H|hh|h):mm(?!:s)");
|
||||
dtFormat.replace(re, "\\1:mm:ss");
|
||||
return loc.toString(dt, dtFormat);
|
||||
}
|
||||
|
||||
void ProtocolWidget::slotOpenFile( QTreeWidgetItem *item, int )
|
||||
@@ -201,33 +204,28 @@ QTreeWidgetItem* ProtocolWidget::createCompletedTreewidgetItem(const QString& fo
|
||||
QDateTime timestamp = QDateTime::currentDateTime();
|
||||
const QString timeStr = timeString(timestamp);
|
||||
const QString longTimeStr = timeString(timestamp, QLocale::LongFormat);
|
||||
QIcon icon;
|
||||
QString message;
|
||||
|
||||
columns << timeStr;
|
||||
columns << fixupFilename(item._file);
|
||||
columns << folder;
|
||||
if (Progress::isWarningKind(item._status)) {
|
||||
message= item._errorString;
|
||||
columns << message;
|
||||
if (item._status == SyncFileItem::NormalError || item._status == SyncFileItem::FatalError) {
|
||||
icon = Theme::instance()->syncStateIcon(SyncResult::Error);
|
||||
} else {
|
||||
icon = Theme::instance()->syncStateIcon(SyncResult::Problem);
|
||||
}
|
||||
|
||||
} else {
|
||||
// if the error string is set, it's prefered because it is a usefull user message.
|
||||
// at least should be...
|
||||
if(item._errorString.isEmpty()) {
|
||||
message = Progress::asResultString(item);
|
||||
} else {
|
||||
message = item._errorString;
|
||||
}
|
||||
columns << message;
|
||||
if (Progress::isSizeDependent(item._instruction)) {
|
||||
columns << Utility::octetsToString( item._size );
|
||||
}
|
||||
// If the error string is set, it's prefered because it is a useful user message.
|
||||
QString message = item._errorString;
|
||||
if (message.isEmpty()) {
|
||||
message = Progress::asResultString(item);
|
||||
}
|
||||
columns << message;
|
||||
|
||||
QIcon icon;
|
||||
if (item._status == SyncFileItem::NormalError
|
||||
|| item._status == SyncFileItem::FatalError) {
|
||||
icon = Theme::instance()->syncStateIcon(SyncResult::Error);
|
||||
} else if (Progress::isWarningKind(item._status)) {
|
||||
icon = Theme::instance()->syncStateIcon(SyncResult::Problem);
|
||||
}
|
||||
|
||||
if (Progress::isSizeDependent(item._instruction)) {
|
||||
columns << Utility::octetsToString( item._size );
|
||||
}
|
||||
|
||||
QTreeWidgetItem *twitem = new QTreeWidgetItem(columns);
|
||||
|
||||
@@ -39,8 +39,6 @@ public:
|
||||
explicit ProtocolWidget(QWidget *parent = 0);
|
||||
~ProtocolWidget();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void slotProgressInfo( const QString& folder, const Progress::Info& progress );
|
||||
void slotOpenFile( QTreeWidgetItem* item, int );
|
||||
@@ -49,6 +47,10 @@ protected slots:
|
||||
void copyToClipboard();
|
||||
void slotRetrySync();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *);
|
||||
void hideEvent(QHideEvent *);
|
||||
|
||||
signals:
|
||||
void guiLog(const QString&, const QString&);
|
||||
|
||||
|
||||
@@ -26,10 +26,33 @@
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
#include <QScopedValueRollback>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QLabel>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
|
||||
class SelectiveSyncTreeViewItem : public QTreeWidgetItem {
|
||||
public:
|
||||
SelectiveSyncTreeViewItem(int type = QTreeWidgetItem::Type)
|
||||
: QTreeWidgetItem(type) { }
|
||||
SelectiveSyncTreeViewItem(const QStringList &strings, int type = QTreeWidgetItem::Type)
|
||||
: QTreeWidgetItem(strings, type) { }
|
||||
SelectiveSyncTreeViewItem(QTreeWidget *view, int type = QTreeWidgetItem::Type)
|
||||
: QTreeWidgetItem(view, type) { }
|
||||
SelectiveSyncTreeViewItem(QTreeWidgetItem *parent, int type = QTreeWidgetItem::Type)
|
||||
: QTreeWidgetItem(parent, type) { }
|
||||
|
||||
private:
|
||||
bool operator<(const QTreeWidgetItem &other)const {
|
||||
int column = treeWidget()->sortColumn();
|
||||
if (column == 1) {
|
||||
return data(1, Qt::UserRole).toLongLong() < other.data(1, Qt::UserRole).toLongLong();
|
||||
}
|
||||
return QTreeWidgetItem::operator <(other);
|
||||
}
|
||||
};
|
||||
|
||||
SelectiveSyncTreeView::SelectiveSyncTreeView(AccountPtr account, QWidget* parent)
|
||||
: QTreeWidget(parent), _inserting(false), _account(account)
|
||||
{
|
||||
@@ -101,9 +124,9 @@ void SelectiveSyncTreeView::recursiveInsert(QTreeWidgetItem* parent, QStringList
|
||||
parent->setToolTip(0, path);
|
||||
parent->setData(0, Qt::UserRole, path);
|
||||
} else {
|
||||
QTreeWidgetItem *item = findFirstChild(parent, pathTrail.first());
|
||||
SelectiveSyncTreeViewItem *item = static_cast<SelectiveSyncTreeViewItem*>(findFirstChild(parent, pathTrail.first()));
|
||||
if (!item) {
|
||||
item = new QTreeWidgetItem(parent);
|
||||
item = new SelectiveSyncTreeViewItem(parent);
|
||||
if (parent->checkState(0) == Qt::Checked
|
||||
|| parent->checkState(0) == Qt::PartiallyChecked) {
|
||||
item->setCheckState(0, Qt::Checked);
|
||||
@@ -138,7 +161,7 @@ void SelectiveSyncTreeView::slotUpdateDirectories(const QStringList&list)
|
||||
QScopedValueRollback<bool> isInserting(_inserting);
|
||||
_inserting = true;
|
||||
|
||||
QTreeWidgetItem *root = topLevelItem(0);
|
||||
SelectiveSyncTreeViewItem *root = static_cast<SelectiveSyncTreeViewItem*>(topLevelItem(0));
|
||||
|
||||
if (!root && list.size() <= 1) {
|
||||
_loading->setText(tr("No subfolders currently on the server."));
|
||||
@@ -149,7 +172,7 @@ void SelectiveSyncTreeView::slotUpdateDirectories(const QStringList&list)
|
||||
}
|
||||
|
||||
if (!root) {
|
||||
root = new QTreeWidgetItem(this);
|
||||
root = new SelectiveSyncTreeViewItem(this);
|
||||
root->setText(0, _rootName);
|
||||
root->setIcon(0, Theme::instance()->applicationIcon());
|
||||
root->setData(0, Qt::UserRole, QString());
|
||||
|
||||
@@ -42,6 +42,9 @@ namespace {
|
||||
|
||||
namespace OCC {
|
||||
|
||||
//
|
||||
// Whenever you change something here check both settingsdialog.cpp and settingsdialogmac.cpp !
|
||||
//
|
||||
SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) :
|
||||
QDialog(parent)
|
||||
, _ui(new Ui::SettingsDialog)
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
|
||||
namespace OCC {
|
||||
|
||||
//
|
||||
// Whenever you change something here check both settingsdialog.cpp and settingsdialogmac.cpp !
|
||||
//
|
||||
SettingsDialogMac::SettingsDialogMac(ownCloudGui *gui, QWidget *parent)
|
||||
: MacPreferencesWindow(parent)
|
||||
{
|
||||
@@ -82,6 +85,10 @@ SettingsDialogMac::SettingsDialogMac(ownCloudGui *gui, QWidget *parent)
|
||||
connect( folderMan, SIGNAL(folderSyncStateChange(QString)),
|
||||
this, SLOT(slotSyncStateChange(QString)));
|
||||
|
||||
connect( _accountSettings, SIGNAL(folderChanged()), gui, SLOT(slotFoldersChanged()));
|
||||
connect( _accountSettings, SIGNAL(openFolderAlias(const QString&)),
|
||||
gui, SLOT(slotFolderOpenAction(QString)));
|
||||
|
||||
connect( ProgressDispatcher::instance(), SIGNAL(progressInfo(QString, Progress::Info)),
|
||||
_accountSettings, SLOT(slotSetProgress(QString, Progress::Info)) );
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "folder.h"
|
||||
#include "theme.h"
|
||||
#include "syncresult.h"
|
||||
#include "configfile.h"
|
||||
|
||||
#include "QProgressIndicator.h"
|
||||
#include <QBuffer>
|
||||
@@ -33,19 +34,22 @@ namespace {
|
||||
|
||||
namespace OCC {
|
||||
|
||||
ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath, QWidget *parent) :
|
||||
ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath, bool resharingAllowed, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
_ui(new Ui::ShareDialog),
|
||||
_account(account),
|
||||
_sharePath(sharePath),
|
||||
_localPath(localPath),
|
||||
_passwordJobRunning(false),
|
||||
_public_share_id(0)
|
||||
_public_share_id(0),
|
||||
_resharingAllowed(resharingAllowed)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setObjectName("SharingDialog"); // required as group for saveGeometry call
|
||||
|
||||
_ui->setupUi(this);
|
||||
_ui->pushButton_copy->setIcon(QIcon::fromTheme("edit-copy"));
|
||||
_ui->pushButton_copy->setText(tr("Copy Link"));
|
||||
_ui->pushButton_copy->setEnabled(false);
|
||||
connect(_ui->pushButton_copy, SIGNAL(clicked(bool)), SLOT(slotPushButtonCopyLinkPressed()));
|
||||
|
||||
QPushButton *closeButton = _ui->buttonBox->button(QDialogButtonBox::Close);
|
||||
@@ -60,43 +64,54 @@ ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QSt
|
||||
_pi_date = new QProgressIndicator();
|
||||
_ui->horizontalLayout_shareLink->addWidget(_pi_link);
|
||||
_ui->horizontalLayout_password->addWidget(_pi_password);
|
||||
_ui->horizontalLayout_expire->addWidget(_pi_date);
|
||||
// _ui->horizontalLayout_expire->addWidget(_pi_date);
|
||||
|
||||
connect(_ui->checkBox_shareLink, SIGNAL(clicked()), this, SLOT(slotCheckBoxShareLinkClicked()));
|
||||
connect(_ui->checkBox_password, SIGNAL(clicked()), this, SLOT(slotCheckBoxPasswordClicked()));
|
||||
connect(_ui->lineEdit_password, SIGNAL(returnPressed()), this, SLOT(slotPasswordReturnPressed()));
|
||||
connect(_ui->lineEdit_password, SIGNAL(textChanged(QString)), this, SLOT(slotPasswordChanged(QString)));
|
||||
connect(_ui->pushButton_setPassword, SIGNAL(clicked(bool)), SLOT(slotPasswordReturnPressed()));
|
||||
connect(_ui->checkBox_expire, SIGNAL(clicked()), this, SLOT(slotCheckBoxExpireClicked()));
|
||||
connect(_ui->calendar, SIGNAL(clicked(QDate)), SLOT(slotCalendarClicked(QDate)));
|
||||
connect(_ui->calendar, SIGNAL(dateChanged(QDate)), SLOT(slotCalendarClicked(QDate)));
|
||||
|
||||
_ui->pushButton_setPassword->setEnabled(false);
|
||||
_ui->widget_shareLink->hide();
|
||||
_ui->lineEdit_password->hide();
|
||||
_ui->pushButton_setPassword->hide();
|
||||
_ui->calendar->hide();
|
||||
|
||||
_ui->calendar->setDate(QDate::currentDate().addDays(1));
|
||||
_ui->calendar->setEnabled(false);
|
||||
|
||||
QFileInfo f_info(_localPath);
|
||||
QFileIconProvider icon_provider;
|
||||
QIcon icon = icon_provider.icon(f_info);
|
||||
_ui->label_icon->setPixmap(icon.pixmap(40,40));
|
||||
|
||||
QString name;
|
||||
if( f_info.isDir() ) {
|
||||
name = tr("Share Directory");
|
||||
} else {
|
||||
name = tr("Share File");
|
||||
}
|
||||
_ui->groupBox->setTitle(name);
|
||||
|
||||
QString lPath(_localPath);
|
||||
if( lPath.length() > 50) {
|
||||
lPath = QLatin1String("...")+lPath.right(50);
|
||||
}
|
||||
_ui->label_name->setText(tr("Local path: %1").arg(lPath));
|
||||
QFileInfo lPath(_localPath);
|
||||
QString fileName = lPath.fileName();
|
||||
_ui->label_name->setText(tr("%1").arg(fileName));
|
||||
QFont f( _ui->label_name->font());
|
||||
f.setPointSize( f.pointSize() * 1.4 );
|
||||
_ui->label_name->setFont( f );
|
||||
|
||||
_ui->label_sharePath->setWordWrap(true);
|
||||
_ui->label_sharePath->setText(tr("%1 path: %2").arg(Theme::instance()->appNameGUI()).arg(_sharePath));
|
||||
QString ocDir(_sharePath);
|
||||
ocDir.truncate(ocDir.length()-fileName.length());
|
||||
|
||||
if( ocDir == QLatin1String("/")) {
|
||||
_ui->label_sharePath->setText(QString());
|
||||
} else {
|
||||
if( ocDir.startsWith(QLatin1Char('/')) ) {
|
||||
ocDir = ocDir.mid(1, -1);
|
||||
}
|
||||
if( ocDir.endsWith(QLatin1Char('/')) ) {
|
||||
ocDir.chop(1);
|
||||
}
|
||||
_ui->label_sharePath->setText(tr("Folder: %2").arg(ocDir));
|
||||
}
|
||||
|
||||
this->setWindowTitle(tr("%1 Sharing").arg(Theme::instance()->appNameGUI()));
|
||||
_ui->label_password->setText(tr("Set password"));
|
||||
_ui->checkBox_password->setText(tr("P&assword protect"));
|
||||
// check if the file is already inside of a synced folder
|
||||
if( sharePath.isEmpty() ) {
|
||||
// The file is not yet in an ownCloud synced folder. We could automatically
|
||||
@@ -123,6 +138,12 @@ ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QSt
|
||||
_ui->errorLabel->hide();
|
||||
}
|
||||
|
||||
void ShareDialog::done( int r ) {
|
||||
ConfigFile cfg;
|
||||
cfg.saveGeometry(this);
|
||||
QDialog::done(r);
|
||||
}
|
||||
|
||||
void ShareDialog::setExpireDate(const QDate &date)
|
||||
{
|
||||
if( _public_share_id == 0 ) {
|
||||
@@ -176,6 +197,12 @@ void ShareDialog::slotPasswordReturnPressed()
|
||||
_ui->lineEdit_password->clearFocus();
|
||||
}
|
||||
|
||||
void ShareDialog::slotPasswordChanged(const QString& newText)
|
||||
{
|
||||
// disable the set-passwort button
|
||||
_ui->pushButton_setPassword->setEnabled( newText.length() > 0 );
|
||||
}
|
||||
|
||||
void ShareDialog::setPassword(const QString &password)
|
||||
{
|
||||
if( _passwordJobRunning ) {
|
||||
@@ -199,7 +226,7 @@ void ShareDialog::setPassword(const QString &password)
|
||||
verb = "POST";
|
||||
|
||||
if( _ui->checkBox_expire->isChecked() ) {
|
||||
QDate date = _ui->calendar->selectedDate();
|
||||
QDate date = _ui->calendar->date();
|
||||
if( date.isValid() ) {
|
||||
requestParams.append(qMakePair(QString::fromLatin1("expireDate"), date.toString("yyyy-MM-dd")));
|
||||
}
|
||||
@@ -281,12 +308,12 @@ void ShareDialog::slotSharesFetched(const QString &reply)
|
||||
}
|
||||
|
||||
if (data.value("expiration").isValid()) {
|
||||
_ui->calendar->setSelectedDate(QDate::fromString(data.value("expiration").toString(), "yyyy-MM-dd 00:00:00"));
|
||||
_ui->calendar->setDate(QDate::fromString(data.value("expiration").toString(), "yyyy-MM-dd 00:00:00"));
|
||||
_ui->calendar->setMinimumDate(QDate::currentDate().addDays(1));
|
||||
_ui->calendar->show();
|
||||
_ui->calendar->setEnabled(true);
|
||||
_ui->checkBox_expire->setChecked(true);
|
||||
} else {
|
||||
_ui->calendar->hide();
|
||||
_ui->calendar->setEnabled(false);
|
||||
_ui->checkBox_expire->setChecked(false);
|
||||
}
|
||||
|
||||
@@ -300,10 +327,61 @@ void ShareDialog::slotSharesFetched(const QString &reply)
|
||||
queryArgs.append(qMakePair(QString("t"), data.value("token").toString()));
|
||||
url = Account::concatUrlPath(_account->url(), QLatin1String("public.php"), queryArgs).toString();
|
||||
}
|
||||
_ui->lineEdit_shareLink->setText(url);
|
||||
setShareLink(url);
|
||||
|
||||
_ui->pushButton_copy->setEnabled(true);
|
||||
}
|
||||
}
|
||||
setShareCheckBoxTitle(_shares.count() > 0);
|
||||
if( _shares.count()>0 ) {
|
||||
setShareCheckBoxTitle(true);
|
||||
} else {
|
||||
// If there are no shares yet, check the checkbox to create a link automatically.
|
||||
// If its clear that resharing is not allowed, display an error
|
||||
if( !_resharingAllowed ) {
|
||||
displayError(tr("The file can not be shared because it was shared without sharing permission."));
|
||||
_ui->checkBox_shareLink->setEnabled(false);
|
||||
} else {
|
||||
_ui->checkBox_shareLink->setChecked(true);
|
||||
slotCheckBoxShareLinkClicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShareDialog::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QDialog::resizeEvent(e);
|
||||
redrawElidedUrl();
|
||||
}
|
||||
|
||||
void ShareDialog::redrawElidedUrl()
|
||||
{
|
||||
QString u;
|
||||
|
||||
if( !_shareUrl.isEmpty() ) {
|
||||
QFontMetrics fm( _ui->_labelShareLink->font() );
|
||||
int linkLengthPixel = _ui->_labelShareLink->width();
|
||||
|
||||
const QUrl realUrl(_shareUrl);
|
||||
QString elidedUrl = fm.elidedText(_shareUrl, Qt::ElideRight, linkLengthPixel);
|
||||
|
||||
u = QString("<a href=\"%1\">%2</a>").arg(realUrl.toString(QUrl::None)).arg(elidedUrl);
|
||||
}
|
||||
_ui->_labelShareLink->setText(u);
|
||||
}
|
||||
|
||||
void ShareDialog::setShareLink( const QString& url )
|
||||
{
|
||||
// FIXME: shorten the url for output.
|
||||
const QUrl realUrl(url);
|
||||
if( realUrl.isValid() ) {
|
||||
_shareUrl = url;
|
||||
_ui->pushButton_copy->setEnabled(true);
|
||||
} else {
|
||||
_shareUrl.clear();
|
||||
_ui->_labelShareLink->setText(QString::null);
|
||||
}
|
||||
redrawElidedUrl();
|
||||
|
||||
}
|
||||
|
||||
void ShareDialog::slotDeleteShareFetched(const QString &reply)
|
||||
@@ -319,12 +397,17 @@ void ShareDialog::slotDeleteShareFetched(const QString &reply)
|
||||
_public_share_id = 0;
|
||||
_pi_link->stopAnimation();
|
||||
_ui->lineEdit_password->clear();
|
||||
_ui->lineEdit_shareLink->clear();
|
||||
_ui->_labelShareLink->clear();
|
||||
_ui->pushButton_copy->setEnabled(false);
|
||||
_ui->widget_shareLink->hide();
|
||||
_ui->lineEdit_password->hide();
|
||||
_ui->pushButton_setPassword->setEnabled(false);
|
||||
_ui->pushButton_setPassword->hide();
|
||||
_ui->checkBox_expire->setChecked(false);
|
||||
_ui->calendar->hide();
|
||||
_ui->checkBox_password->setChecked(false);
|
||||
_ui->calendar->setEnabled(false);
|
||||
|
||||
_shareUrl.clear();
|
||||
|
||||
setShareCheckBoxTitle(false);
|
||||
|
||||
@@ -361,7 +444,7 @@ void ShareDialog::slotCreateShareFetched(const QString &reply)
|
||||
// there needs to be a password
|
||||
_ui->checkBox_password->setChecked(true);
|
||||
_ui->checkBox_password->setVisible(false);
|
||||
_ui->label_password->setText(tr("Public sharing requires a password:"));
|
||||
_ui->checkBox_password->setText(tr("Public shå requires a password:"));
|
||||
_ui->lineEdit_password->setFocus();
|
||||
_ui->widget_shareLink->show();
|
||||
|
||||
@@ -375,23 +458,17 @@ void ShareDialog::slotCreateShareFetched(const QString &reply)
|
||||
bool success;
|
||||
QVariantMap json = QtJson::parse(reply, success).toMap();
|
||||
_public_share_id = json.value("ocs").toMap().values("data")[0].toMap().value("id").toULongLong();
|
||||
QString url = json.value("ocs").toMap().values("data")[0].toMap().value("url").toString();
|
||||
_ui->lineEdit_shareLink->setText(url);
|
||||
setShareCheckBoxTitle(true);
|
||||
|
||||
_ui->widget_shareLink->show();
|
||||
getShares();
|
||||
}
|
||||
|
||||
void ShareDialog::slotCheckBoxPasswordClicked()
|
||||
{
|
||||
if (_ui->checkBox_password->checkState() == Qt::Checked)
|
||||
{
|
||||
if (_ui->checkBox_password->checkState() == Qt::Checked) {
|
||||
_ui->lineEdit_password->show();
|
||||
_ui->pushButton_setPassword->show();
|
||||
_ui->lineEdit_password->setPlaceholderText(tr("Choose a password for the public link"));
|
||||
}
|
||||
else
|
||||
{
|
||||
_ui->lineEdit_password->setFocus();
|
||||
} else {
|
||||
ShareDialog::setPassword(QString());
|
||||
_ui->lineEdit_password->setPlaceholderText(QString());
|
||||
_pi_password->startAnimation();
|
||||
@@ -406,21 +483,21 @@ void ShareDialog::slotCheckBoxExpireClicked()
|
||||
{
|
||||
const QDate date = QDate::currentDate().addDays(1);
|
||||
ShareDialog::setExpireDate(date);
|
||||
_ui->calendar->setSelectedDate(date);
|
||||
_ui->calendar->setDate(date);
|
||||
_ui->calendar->setMinimumDate(date);
|
||||
_ui->calendar->show();
|
||||
_ui->calendar->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShareDialog::setExpireDate(QDate());
|
||||
_ui->calendar->hide();
|
||||
_ui->calendar->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ShareDialog::slotPushButtonCopyLinkPressed()
|
||||
{
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(_ui->lineEdit_shareLink->text());
|
||||
clipboard->setText(_shareUrl);
|
||||
}
|
||||
|
||||
int ShareDialog::checkJsonReturnCode(const QString &reply, QString &message)
|
||||
@@ -441,8 +518,8 @@ int ShareDialog::checkJsonReturnCode(const QString &reply, QString &message)
|
||||
|
||||
void ShareDialog::setShareCheckBoxTitle(bool haveShares)
|
||||
{
|
||||
const QString noSharesTitle(tr("Check to share by public link"));
|
||||
const QString haveSharesTitle(tr("Shared by public link (uncheck to delete share)"));
|
||||
const QString noSharesTitle(tr("&Share link"));
|
||||
const QString haveSharesTitle(tr("&Share link"));
|
||||
|
||||
if( haveShares ) {
|
||||
_ui->checkBox_shareLink->setText( haveSharesTitle );
|
||||
@@ -452,19 +529,24 @@ void ShareDialog::setShareCheckBoxTitle(bool haveShares)
|
||||
|
||||
}
|
||||
|
||||
void ShareDialog::displayError(int code)
|
||||
void ShareDialog::displayError(const QString& errMsg)
|
||||
{
|
||||
const QString errMsg = tr("OCS API error code: %1").arg(code);
|
||||
_ui->errorLabel->setText( errMsg );
|
||||
_ui->errorLabel->show();
|
||||
}
|
||||
|
||||
void ShareDialog::displayError(int code)
|
||||
{
|
||||
const QString errMsg = tr("OCS API error code: %1").arg(code);
|
||||
displayError(errMsg);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void ShareDialog::displayInfo( const QString& msg )
|
||||
{
|
||||
_ui->label_sharePath->setText(msg);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* This code is disabled for now as we do not have answers for all the questions involved
|
||||
* here, see https://github.com/owncloud/client/issues/2732
|
||||
|
||||
@@ -57,7 +57,8 @@ class ShareDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath, QWidget *parent = 0);
|
||||
explicit ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath,
|
||||
bool resharingAllowed, QWidget *parent = 0);
|
||||
~ShareDialog();
|
||||
void getShares();
|
||||
|
||||
@@ -72,20 +73,29 @@ private slots:
|
||||
void slotCheckBoxPasswordClicked();
|
||||
void slotCheckBoxExpireClicked();
|
||||
void slotPasswordReturnPressed();
|
||||
void slotPasswordChanged(const QString& newText);
|
||||
void slotPushButtonCopyLinkPressed();
|
||||
void slotThumbnailFetched(const int &statusCode, const QByteArray &reply);
|
||||
|
||||
void done( int r );
|
||||
private:
|
||||
void setShareCheckBoxTitle(bool haveShares);
|
||||
void displayError(int code);
|
||||
void displayInfo( const QString& msg );
|
||||
void displayError(const QString& errMsg);
|
||||
void setShareLink( const QString& url );
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void redrawElidedUrl();
|
||||
|
||||
Ui::ShareDialog *_ui;
|
||||
AccountPtr _account;
|
||||
QString _sharePath;
|
||||
QString _localPath;
|
||||
QString _shareUrl;
|
||||
#if 0
|
||||
QString _folderAlias;
|
||||
int _uploadFails;
|
||||
QString _expectedSyncFile;
|
||||
#endif
|
||||
|
||||
bool _passwordJobRunning;
|
||||
QList<QVariant> _shares;
|
||||
@@ -98,6 +108,7 @@ private:
|
||||
QProgressIndicator *_pi_password;
|
||||
QProgressIndicator *_pi_date;
|
||||
|
||||
bool _resharingAllowed;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -6,121 +6,163 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>362</width>
|
||||
<height>427</height>
|
||||
<width>372</width>
|
||||
<height>241</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Share NewDocument.odt</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Share Info</string>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="label_icon">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>share label</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="2">
|
||||
<widget class="QProgressIndicator" name="pi_share" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_sharePath">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ownCloud Path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_shareLink">
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_shareLink">
|
||||
<property name="text">
|
||||
<string>Share link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QWidget" name="widget_shareLink" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="label_icon">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_name">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="_labelShareLink">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>share label</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="2">
|
||||
<widget class="QProgressIndicator" name="pi_share" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_sharePath">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_copy">
|
||||
<property name="text">
|
||||
<string>ownCloud Path:</string>
|
||||
<string>Copy &link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QWidget" name="widget_shareLink" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_password">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_password">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_password">
|
||||
<property name="text">
|
||||
<string>Set password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_expire">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_expire">
|
||||
<property name="text">
|
||||
<string>Set expiration date</string>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password">
|
||||
<property name="echoMode">
|
||||
@@ -130,32 +172,35 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_setPassword">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set Password</string>
|
||||
<string>Set &password </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCalendarWidget" name="calendar"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_shareLink">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
<widget class="QCheckBox" name="checkBox_expire">
|
||||
<property name="text">
|
||||
<string>Set &expiration date</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_copy">
|
||||
<property name="text">
|
||||
<string/>
|
||||
<widget class="QDateEdit" name="calendar">
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -164,7 +209,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="3" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -177,32 +222,37 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_shareLink">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_shareLink">
|
||||
<property name="text">
|
||||
<string>Share link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="errorLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>errorLabel</zorder>
|
||||
<zorder>widget_shareLink</zorder>
|
||||
<zorder>buttonBox</zorder>
|
||||
<zorder>checkBox_password</zorder>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) by Dominik Schmidt <dev@dominik-schmidt.de>
|
||||
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
||||
* Copyright (C) by Roeland Jago Douma <roeland@famdouma.nl>
|
||||
*
|
||||
* 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
|
||||
@@ -24,6 +25,7 @@
|
||||
#include "syncfileitem.h"
|
||||
#include "filesystem.h"
|
||||
#include "version.h"
|
||||
#include "accountstate.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QUrl>
|
||||
@@ -136,7 +138,9 @@ SocketApi::~SocketApi()
|
||||
{
|
||||
DEBUG << "dtor";
|
||||
_localServer.close();
|
||||
qDeleteAll(_listeners);
|
||||
// All remaining sockets will be destroyed with _localServer, their parent
|
||||
Q_ASSERT(_listeners.isEmpty() || _listeners.first()->parent() == &_localServer);
|
||||
_listeners.clear();
|
||||
slotClearExcludesList();
|
||||
}
|
||||
|
||||
@@ -163,7 +167,7 @@ void SocketApi::slotReadExcludes()
|
||||
|
||||
void SocketApi::slotNewConnection()
|
||||
{
|
||||
SocketType* socket = _localServer.nextPendingConnection();
|
||||
QLocalSocket* socket = _localServer.nextPendingConnection();
|
||||
|
||||
if( ! socket ) {
|
||||
return;
|
||||
@@ -185,8 +189,9 @@ void SocketApi::slotNewConnection()
|
||||
broadcastMessage(QLatin1String("ICON_PATH"), iconPath );
|
||||
#endif
|
||||
|
||||
foreach( QString alias, FolderMan::instance()->map().keys() ) {
|
||||
slotRegisterPath(alias);
|
||||
foreach( Folder *f, FolderMan::instance()->map() ) {
|
||||
QString message = buildRegisterPathMessage(f->path());
|
||||
sendMessage(socket, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +199,7 @@ void SocketApi::onLostConnection()
|
||||
{
|
||||
DEBUG << "Lost connection " << sender();
|
||||
|
||||
SocketType* socket = qobject_cast<SocketType*>(sender());
|
||||
QLocalSocket* socket = qobject_cast<QLocalSocket*>(sender());
|
||||
_listeners.removeAll(socket);
|
||||
socket->deleteLater();
|
||||
}
|
||||
@@ -202,7 +207,7 @@ void SocketApi::onLostConnection()
|
||||
|
||||
void SocketApi::slotReadSocket()
|
||||
{
|
||||
SocketType* socket = qobject_cast<SocketType*>(sender());
|
||||
QLocalSocket* socket = qobject_cast<QLocalSocket*>(sender());
|
||||
Q_ASSERT(socket);
|
||||
|
||||
while(socket->canReadLine()) {
|
||||
@@ -210,12 +215,12 @@ void SocketApi::slotReadSocket()
|
||||
QString command = line.split(":").first();
|
||||
QString function = QString(QLatin1String("command_")).append(command);
|
||||
|
||||
QString functionWithArguments = function + QLatin1String("(QString,SocketType*)");
|
||||
QString functionWithArguments = function + QLatin1String("(QString,QLocalSocket*)");
|
||||
int indexOfMethod = this->metaObject()->indexOfMethod(functionWithArguments.toAscii());
|
||||
|
||||
QString argument = line.remove(0, command.length()+1).trimmed();
|
||||
if(indexOfMethod != -1) {
|
||||
QMetaObject::invokeMethod(this, function.toAscii(), Q_ARG(QString, argument), Q_ARG(SocketType*, socket));
|
||||
QMetaObject::invokeMethod(this, function.toAscii(), Q_ARG(QString, argument), Q_ARG(QLocalSocket*, socket));
|
||||
} else {
|
||||
DEBUG << "The command is not supported by this version of the client:" << command << "with argument:" << argument;
|
||||
}
|
||||
@@ -226,7 +231,10 @@ void SocketApi::slotRegisterPath( const QString& alias )
|
||||
{
|
||||
Folder *f = FolderMan::instance()->folder(alias);
|
||||
if (f) {
|
||||
broadcastMessage(QLatin1String("REGISTER_PATH"), f->path() );
|
||||
QString message = buildRegisterPathMessage(f->path());
|
||||
foreach(QLocalSocket *socket, _listeners) {
|
||||
sendMessage(socket, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +337,7 @@ void SocketApi::slotSyncItemDiscovered(const QString &folder, const SyncFileItem
|
||||
|
||||
|
||||
|
||||
void SocketApi::sendMessage(SocketType *socket, const QString& message, bool doWait)
|
||||
void SocketApi::sendMessage(QLocalSocket *socket, const QString& message, bool doWait)
|
||||
{
|
||||
DEBUG << "Sending message: " << message;
|
||||
QString localMessage = message;
|
||||
@@ -364,12 +372,12 @@ void SocketApi::broadcastMessage( const QString& verb, const QString& path, cons
|
||||
|
||||
// sendMessage already has a debug output
|
||||
//DEBUG << "Broadcasting to" << _listeners.count() << "listeners: " << msg;
|
||||
foreach(SocketType *socket, _listeners) {
|
||||
foreach(QLocalSocket *socket, _listeners) {
|
||||
sendMessage(socket, msg, doWait);
|
||||
}
|
||||
}
|
||||
|
||||
void SocketApi::command_RETRIEVE_FOLDER_STATUS(const QString& argument, SocketType* socket)
|
||||
void SocketApi::command_RETRIEVE_FOLDER_STATUS(const QString& argument, QLocalSocket* socket)
|
||||
{
|
||||
// This command is the same as RETRIEVE_FILE_STATUS
|
||||
|
||||
@@ -377,7 +385,7 @@ void SocketApi::command_RETRIEVE_FOLDER_STATUS(const QString& argument, SocketTy
|
||||
command_RETRIEVE_FILE_STATUS(argument, socket);
|
||||
}
|
||||
|
||||
void SocketApi::command_RETRIEVE_FILE_STATUS(const QString& argument, SocketType* socket)
|
||||
void SocketApi::command_RETRIEVE_FILE_STATUS(const QString& argument, QLocalSocket* socket)
|
||||
{
|
||||
if( !socket ) {
|
||||
qDebug() << "No valid socket object.";
|
||||
@@ -405,7 +413,7 @@ void SocketApi::command_RETRIEVE_FILE_STATUS(const QString& argument, SocketType
|
||||
sendMessage(socket, message);
|
||||
}
|
||||
|
||||
void SocketApi::command_SHARE(const QString& localFile, SocketType* socket)
|
||||
void SocketApi::command_SHARE(const QString& localFile, QLocalSocket* socket)
|
||||
{
|
||||
if (!socket) {
|
||||
qDebug() << Q_FUNC_INFO << "No valid socket object.";
|
||||
@@ -419,26 +427,48 @@ void SocketApi::command_SHARE(const QString& localFile, SocketType* socket)
|
||||
const QString message = QLatin1String("SHARE:NOP:")+QDir::toNativeSeparators(localFile);
|
||||
// files that are not within a sync folder are not synced.
|
||||
sendMessage(socket, message);
|
||||
} else if (!shareFolder->accountState()->isConnected()) {
|
||||
const QString message = QLatin1String("SHARE:NOTCONNECTED:")+QDir::toNativeSeparators(localFile);
|
||||
// if the folder isn't connected, don't open the share dialog
|
||||
sendMessage(socket, message);
|
||||
} else {
|
||||
const QString folderForPath = shareFolder->path();
|
||||
const QString remotePath = shareFolder->remotePath() + localFile.right(localFile.count()-folderForPath.count()+1);
|
||||
|
||||
SyncJournalFileRecord rec = dbFileRecord_capi(shareFolder, localFile);
|
||||
|
||||
bool allowReshare = true; // lets assume the good
|
||||
if( rec.isValid() ) {
|
||||
// check the permission: Is resharing allowed?
|
||||
if( !rec._remotePerm.contains('R') ) {
|
||||
allowReshare = false;
|
||||
}
|
||||
}
|
||||
const QString message = QLatin1String("SHARE:OK:")+QDir::toNativeSeparators(localFile);
|
||||
sendMessage(socket, message);
|
||||
|
||||
const QString folderForPath = shareFolder->path();
|
||||
const QString remotePath = shareFolder->remotePath() + localFile.right(localFile.count()-folderForPath.count()+1);
|
||||
emit shareCommandReceived(remotePath, localFile);
|
||||
emit shareCommandReceived(remotePath, localFile, allowReshare);
|
||||
}
|
||||
}
|
||||
|
||||
void SocketApi::command_VERSION(const QString&, SocketType* socket)
|
||||
void SocketApi::command_VERSION(const QString&, QLocalSocket* socket)
|
||||
{
|
||||
sendMessage(socket, QLatin1String("VERSION:" MIRALL_VERSION_STRING ":" MIRALL_SOCKET_API_VERSION));
|
||||
}
|
||||
|
||||
void SocketApi::command_SHARE_MENU_TITLE(const QString &, SocketType* socket)
|
||||
void SocketApi::command_SHARE_MENU_TITLE(const QString &, QLocalSocket* socket)
|
||||
{
|
||||
sendMessage(socket, QLatin1String("SHARE_MENU_TITLE:") + tr("Share with %1", "parameter is ownCloud").arg(Theme::instance()->appNameGUI()));
|
||||
}
|
||||
|
||||
QString SocketApi::buildRegisterPathMessage(const QString& path)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
QString message = QLatin1String("REGISTER_PATH:");
|
||||
message.append(QDir::toNativeSeparators(fi.absoluteFilePath()));
|
||||
return message;
|
||||
}
|
||||
|
||||
SqlQuery* SocketApi::getSqlQuery( Folder *folder )
|
||||
{
|
||||
if( !folder ) {
|
||||
@@ -491,6 +521,10 @@ SyncJournalFileRecord SocketApi::dbFileRecord_capi( Folder *folder, QString file
|
||||
fileName.remove(0, folder->path().length());
|
||||
}
|
||||
|
||||
// remove trailing slash
|
||||
if( fileName.endsWith( QLatin1Char('/') ) ) {
|
||||
fileName.truncate(fileName.length()-1);
|
||||
}
|
||||
SqlQuery *query = getSqlQuery(folder);
|
||||
SyncJournalFileRecord rec;
|
||||
|
||||
|
||||
@@ -37,8 +37,6 @@ class QStringList;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
typedef QLocalSocket SocketType;
|
||||
|
||||
class SyncFileStatus;
|
||||
class Folder;
|
||||
|
||||
@@ -58,7 +56,7 @@ public slots:
|
||||
void slotClearExcludesList();
|
||||
|
||||
signals:
|
||||
void shareCommandReceived(const QString &sharePath, const QString &localPath);
|
||||
void shareCommandReceived(const QString &sharePath, const QString &localPath, bool resharingAllowed);
|
||||
|
||||
private slots:
|
||||
void slotNewConnection();
|
||||
@@ -72,23 +70,20 @@ private:
|
||||
SyncJournalFileRecord dbFileRecord_capi( Folder *folder, QString fileName );
|
||||
SqlQuery *getSqlQuery( Folder *folder );
|
||||
|
||||
void sendMessage(SocketType* socket, const QString& message, bool doWait = false);
|
||||
void sendMessage(QLocalSocket* socket, const QString& message, bool doWait = false);
|
||||
void broadcastMessage(const QString& verb, const QString &path, const QString &status = QString::null, bool doWait = false);
|
||||
|
||||
Q_INVOKABLE void command_RETRIEVE_FOLDER_STATUS(const QString& argument, SocketType* socket);
|
||||
Q_INVOKABLE void command_RETRIEVE_FILE_STATUS(const QString& argument, SocketType* socket);
|
||||
Q_INVOKABLE void command_SHARE(const QString& localFile, SocketType* socket);
|
||||
Q_INVOKABLE void command_RETRIEVE_FOLDER_STATUS(const QString& argument, QLocalSocket* socket);
|
||||
Q_INVOKABLE void command_RETRIEVE_FILE_STATUS(const QString& argument, QLocalSocket* socket);
|
||||
Q_INVOKABLE void command_SHARE(const QString& localFile, QLocalSocket* socket);
|
||||
|
||||
Q_INVOKABLE void command_VERSION(const QString& argument, SocketType* socket);
|
||||
Q_INVOKABLE void command_VERSION(const QString& argument, QLocalSocket* socket);
|
||||
|
||||
Q_INVOKABLE void command_SHARE_MENU_TITLE(const QString& argument, SocketType* socket);
|
||||
Q_INVOKABLE void command_SHARE_MENU_TITLE(const QString& argument, QLocalSocket* socket);
|
||||
QString buildRegisterPathMessage(const QString& path);
|
||||
|
||||
#ifdef SOCKETAPI_TCP
|
||||
QTcpServer _localServer;
|
||||
#else
|
||||
QLocalServer _localServer;
|
||||
#endif
|
||||
QList<SocketType*> _listeners;
|
||||
QList<QLocalSocket*> _listeners;
|
||||
c_strlist_t *_excludes;
|
||||
QHash<Folder*, SqlQuery*> _dbQueries;
|
||||
QHash<Folder*, SqlDatabase*> _openDbs;
|
||||
|
||||
@@ -31,6 +31,10 @@ SslButton::SslButton(QWidget *parent) :
|
||||
{
|
||||
setPopupMode(QToolButton::InstantPopup);
|
||||
setAutoRaise(true);
|
||||
|
||||
setMenu(new QMenu(this));
|
||||
QObject::connect(menu(), SIGNAL(aboutToShow()),
|
||||
this, SLOT(slotUpdateMenu()));
|
||||
}
|
||||
|
||||
QString SslButton::protoToString(QSsl::SslProtocol proto)
|
||||
@@ -178,19 +182,39 @@ void SslButton::updateAccountState(AccountState *accountState)
|
||||
} else {
|
||||
setVisible(true);
|
||||
}
|
||||
AccountPtr account = accountState->account();
|
||||
if(QMenu *oldMenu = menu()) {
|
||||
oldMenu->hide(); // Need to be hidden because the QToolButton would be left in invalid state if the menu is deleted while it is visible
|
||||
setMenu(0);
|
||||
oldMenu->deleteLater(); // setMenu do not delete the previous menu.
|
||||
}
|
||||
_accountState = accountState;
|
||||
|
||||
AccountPtr account = _accountState->account();
|
||||
if (account->url().scheme() == QLatin1String("https")) {
|
||||
setIcon(QIcon(QPixmap(Theme::hidpiFileName(":/client/resources/lock-https.png"))));
|
||||
QPixmap pm(Theme::hidpiFileName(":/client/resources/lock-https.png"));
|
||||
setIcon(QIcon(pm));
|
||||
QSslCipher cipher = account->sslConfiguration().sessionCipher();
|
||||
setToolTip(tr("This connection is encrypted using %1 bit %2.\n").arg(cipher.usedBits()).arg(cipher.name()));
|
||||
QMenu *menu = new QMenu(this);
|
||||
} else {
|
||||
setIcon(QIcon(QPixmap(Theme::hidpiFileName(":/client/resources/lock-http.png"))));
|
||||
setToolTip(tr("This connection is NOT secure as it is not encrypted.\n"));
|
||||
}
|
||||
}
|
||||
|
||||
void SslButton::slotUpdateMenu() {
|
||||
menu()->clear();
|
||||
|
||||
if (!_accountState) {
|
||||
return;
|
||||
}
|
||||
|
||||
AccountPtr account = _accountState->account();
|
||||
|
||||
if (account->url().scheme() == QLatin1String("https")) {
|
||||
|
||||
QList<QSslCertificate> chain = account->sslConfiguration().peerCertificateChain();
|
||||
menu->addAction(tr("Certificate information:"))->setEnabled(false);
|
||||
|
||||
if (chain.isEmpty()) {
|
||||
qWarning() << "empty certificate chain";
|
||||
return;
|
||||
}
|
||||
|
||||
menu()->addAction(tr("Certificate information:"))->setEnabled(false);
|
||||
|
||||
QList<QSslCertificate> tmpChain;
|
||||
foreach(QSslCertificate cert, chain) {
|
||||
@@ -213,13 +237,9 @@ void SslButton::updateAccountState(AccountState *accountState)
|
||||
it.toBack();
|
||||
int i = 0;
|
||||
while (it.hasPrevious()) {
|
||||
menu->addMenu(buildCertMenu(menu, it.previous(), account->approvedCerts(), i));
|
||||
menu()->addMenu(buildCertMenu(menu(), it.previous(), account->approvedCerts(), i));
|
||||
i++;
|
||||
}
|
||||
setMenu(menu);
|
||||
} else {
|
||||
setIcon(QIcon(QPixmap(Theme::hidpiFileName(":/client/resources/lock-http.png"))));
|
||||
setToolTip(tr("This connection is NOT secure as it is not encrypted.\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ class QSslConfiguration;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class Account;
|
||||
class AccountState;
|
||||
|
||||
class SslButton : public QToolButton
|
||||
@@ -35,9 +34,13 @@ public:
|
||||
QString protoToString(QSsl::SslProtocol proto);
|
||||
void updateAccountState(AccountState *accountState);
|
||||
|
||||
public slots:
|
||||
void slotUpdateMenu();
|
||||
|
||||
private:
|
||||
QMenu* buildCertMenu(QMenu *parent, const QSslCertificate& cert,
|
||||
const QList<QSslCertificate>& userApproved, int pos);
|
||||
QPointer<AccountState> _accountState;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -34,8 +34,9 @@ namespace Utility {
|
||||
}
|
||||
#endif
|
||||
|
||||
bool SslDialogErrorHandler::handleErrors(QList<QSslError> errors, QList<QSslCertificate> *certs, AccountPtr account)
|
||||
bool SslDialogErrorHandler::handleErrors(QList<QSslError> errors, const QSslConfiguration &conf, QList<QSslCertificate> *certs, AccountPtr account)
|
||||
{
|
||||
(void) conf;
|
||||
if (!certs) {
|
||||
qDebug() << "Certs parameter required but is NULL!";
|
||||
return false;
|
||||
|
||||
@@ -33,7 +33,7 @@ class SslErrorDialog;
|
||||
|
||||
class SslDialogErrorHandler : public AbstractSslErrorHandler {
|
||||
public:
|
||||
bool handleErrors(QList<QSslError> errors, QList<QSslCertificate> *certs, AccountPtr) Q_DECL_OVERRIDE;
|
||||
bool handleErrors(QList<QSslError> errors, const QSslConfiguration &conf, QList<QSslCertificate> *certs, AccountPtr) Q_DECL_OVERRIDE;
|
||||
};
|
||||
|
||||
class SslErrorDialog : public QDialog
|
||||
|
||||
@@ -129,7 +129,7 @@ void SyncRunFileLog::logItem( const SyncFileItem& item )
|
||||
if( item._direction == SyncFileItem::None ) {
|
||||
return;
|
||||
}
|
||||
QString ts = item._responseTimeStamp;
|
||||
QString ts = QString::fromAscii(item._responseTimeStamp);
|
||||
if( ts.length() > 6 ) {
|
||||
QRegExp rx("(\\d\\d:\\d\\d:\\d\\d)");
|
||||
if( ts.contains(rx) ) {
|
||||
|
||||
@@ -52,9 +52,10 @@ bool OCUpdater::performUpdate()
|
||||
QSettings settings(cfg.configFile(), QSettings::IniFormat);
|
||||
QString updateFile = settings.value(updateAvailableC).toString();
|
||||
if (!updateFile.isEmpty() && QFile(updateFile).exists()) {
|
||||
if (QMessageBox::information(0, tr("New Update Ready"),
|
||||
tr("A new update is about to be installed. The updater may ask\n"
|
||||
"for additional privileges during the process."), QMessageBox::Ok)) {
|
||||
const QString name = Theme::instance()->appNameGUI();
|
||||
if (QMessageBox::information(0, tr("New %1 Update Ready").arg(name),
|
||||
tr("A new update for %1 is about to be installed. The updater may ask\n"
|
||||
"for additional privileges during the process.").arg(name), QMessageBox::Ok)) {
|
||||
slotStartInstaller();
|
||||
return true;
|
||||
}
|
||||
|
||||
25
src/gui/version.rc.in
Normal file
25
src/gui/version.rc.in
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "winresrc.h"
|
||||
|
||||
#define VER_FILEVERSION @MIRALL_VERSION_MAJOR@,@MIRALL_VERSION_MINOR@,@MIRALL_VERSION_PATCH@,@MIRALL_VERSION_BUILD@
|
||||
#define VER_FILEVERSION_STR "@MIRALL_VERSION_MAJOR@.@MIRALL_VERSION_MINOR@.@MIRALL_VERSION_PATCH@.@MIRALL_VERSION_BUILD@\0"
|
||||
|
||||
#define VER_PRODUCTVERSION @MIRALL_VERSION_MAJOR@,@MIRALL_VERSION_MINOR@,@MIRALL_VERSION_PATCH@,@MIRALL_VERSION_BUILD@
|
||||
#define VER_PRODUCTVERSION_STR "@MIRALL_VERSION_MAJOR@.@MIRALL_VERSION_MINOR@.@MIRALL_VERSION_PATCH@.@MIRALL_VERSION_BUILD@\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VER_FILEVERSION
|
||||
PRODUCTVERSION VER_PRODUCTVERSION
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "080904b0"
|
||||
BEGIN
|
||||
VALUE "FileVersion", VER_FILEVERSION_STR
|
||||
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x809, 1200
|
||||
END
|
||||
END
|
||||
@@ -64,7 +64,6 @@ set(libsync_SRCS
|
||||
creds/dummycredentials.cpp
|
||||
creds/abstractcredentials.cpp
|
||||
creds/credentialsfactory.cpp
|
||||
creds/http/httpconfigfile.cpp
|
||||
creds/credentialscommon.cpp
|
||||
../3rdparty/qjson/json.cpp
|
||||
../3rdparty/certificates/p12topem.cpp
|
||||
|
||||
@@ -63,7 +63,9 @@ void AccountManager::setAccount(AccountPtr account)
|
||||
emit accountRemoved(_account);
|
||||
}
|
||||
_account = account;
|
||||
emit accountAdded(account);
|
||||
if (account) {
|
||||
emit accountAdded(account);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +131,15 @@ void Account::save()
|
||||
if (!certs.isEmpty()) {
|
||||
settings->setValue( QLatin1String(caCertsKeyC), certs );
|
||||
}
|
||||
|
||||
// Save cookies.
|
||||
if (_am) {
|
||||
CookieJar* jar = qobject_cast<CookieJar*>(_am->cookieJar());
|
||||
if (jar) {
|
||||
qDebug() << "Saving cookies.";
|
||||
jar->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AccountPtr Account::restore()
|
||||
@@ -271,6 +282,21 @@ void Account::clearCookieJar()
|
||||
_am->setCookieJar(new CookieJar);
|
||||
}
|
||||
|
||||
void Account::resetNetworkAccessManager()
|
||||
{
|
||||
if (!_credentials || !_am) {
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Resetting QNAM";
|
||||
QNetworkCookieJar* jar = _am->cookieJar();
|
||||
_am->deleteLater();
|
||||
_am = _credentials->getQNAM();
|
||||
_am->setCookieJar(jar); // takes ownership of the old cookie jar
|
||||
connect(_am, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
|
||||
SLOT(slotHandleErrors(QNetworkReply*,QList<QSslError>)));
|
||||
}
|
||||
|
||||
QNetworkAccessManager *Account::networkAccessManager()
|
||||
{
|
||||
return _am;
|
||||
@@ -460,7 +486,7 @@ void Account::slotHandleErrors(QNetworkReply *reply , QList<QSslError> errors)
|
||||
return;
|
||||
}
|
||||
|
||||
if (_sslErrorHandler->handleErrors(errors, &approvedCerts, sharedFromThis())) {
|
||||
if (_sslErrorHandler->handleErrors(errors, reply->sslConfiguration(), &approvedCerts, sharedFromThis())) {
|
||||
QSslSocket::addDefaultCaCertificates(approvedCerts);
|
||||
addApprovedCerts(approvedCerts);
|
||||
// all ssl certs are known and accepted. We can ignore the problems right away.
|
||||
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
class AbstractSslErrorHandler {
|
||||
public:
|
||||
virtual ~AbstractSslErrorHandler() {}
|
||||
virtual bool handleErrors(QList<QSslError>, QList<QSslCertificate>*, AccountPtr) = 0;
|
||||
virtual bool handleErrors(QList<QSslError>, const QSslConfiguration &conf, QList<QSslCertificate>*, AccountPtr) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -156,6 +156,7 @@ public:
|
||||
|
||||
void clearCookieJar();
|
||||
|
||||
void resetNetworkAccessManager();
|
||||
QNetworkAccessManager* networkAccessManager();
|
||||
|
||||
/// Called by network jobs on credential errors.
|
||||
@@ -185,7 +186,6 @@ private:
|
||||
QNetworkAccessManager *_am;
|
||||
AbstractCredentials* _credentials;
|
||||
bool _treatSslErrorsAsFailure;
|
||||
int _state;
|
||||
static QString _configFileName;
|
||||
QByteArray _pemCertificate;
|
||||
QString _pemPrivateKey;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "configfile.h"
|
||||
#include <QUrl>
|
||||
#include <QThreadPool>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
@@ -23,7 +24,7 @@ ClientProxy::ClientProxy(QObject *parent) :
|
||||
{
|
||||
}
|
||||
|
||||
QNetworkProxy ClientProxy::proxyFromConfig(const ConfigFile& cfg)
|
||||
static QNetworkProxy proxyFromConfig(const ConfigFile& cfg)
|
||||
{
|
||||
QNetworkProxy proxy;
|
||||
|
||||
@@ -39,6 +40,22 @@ QNetworkProxy ClientProxy::proxyFromConfig(const ConfigFile& cfg)
|
||||
return proxy;
|
||||
}
|
||||
|
||||
bool ClientProxy::isUsingSystemDefault() {
|
||||
OCC::ConfigFile cfg;
|
||||
|
||||
// if there is no config file, default to system proxy.
|
||||
if( cfg.exists() ) {
|
||||
return cfg.proxyType() == QNetworkProxy::DefaultProxy;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QString printQNetworkProxy(const QNetworkProxy &proxy)
|
||||
{
|
||||
return QString("%1://%2:%3").arg(proxy.type()).arg(proxy.hostName()).arg(proxy.port());
|
||||
}
|
||||
|
||||
void ClientProxy::setupQtProxyFromConfig()
|
||||
{
|
||||
OCC::ConfigFile cfg;
|
||||
@@ -53,19 +70,23 @@ void ClientProxy::setupQtProxyFromConfig()
|
||||
|
||||
switch(proxyType) {
|
||||
case QNetworkProxy::NoProxy:
|
||||
qDebug() << "Set proxy configuration to use NO proxy";
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(false);
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
|
||||
break;
|
||||
case QNetworkProxy::DefaultProxy:
|
||||
qDebug() << "Set proxy configuration to use system configuration";
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||
break;
|
||||
case QNetworkProxy::Socks5Proxy:
|
||||
proxy.setType(QNetworkProxy::Socks5Proxy);
|
||||
qDebug() << "Set proxy configuration to SOCKS5" << printQNetworkProxy(proxy);
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(false);
|
||||
QNetworkProxy::setApplicationProxy(proxy);
|
||||
break;
|
||||
case QNetworkProxy::HttpProxy:
|
||||
proxy.setType(QNetworkProxy::HttpProxy);
|
||||
qDebug() << "Set proxy configuration to HTTP" << printQNetworkProxy(proxy);
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(false);
|
||||
QNetworkProxy::setApplicationProxy(proxy);
|
||||
break;
|
||||
@@ -96,6 +117,7 @@ const char* ClientProxy::proxyTypeToCStr(QNetworkProxy::ProxyType type)
|
||||
|
||||
void ClientProxy::setCSyncProxy( const QUrl& url, CSYNC *csync_ctx )
|
||||
{
|
||||
#ifdef USE_NEON
|
||||
/* Store proxy */
|
||||
QList<QNetworkProxy> proxies = QNetworkProxyFactory::proxyForQuery(QNetworkProxyQuery(url));
|
||||
// We set at least one in Application
|
||||
@@ -118,7 +140,38 @@ void ClientProxy::setCSyncProxy( const QUrl& url, CSYNC *csync_ctx )
|
||||
csync_set_module_property( csync_ctx, "proxy_port", &proxy_port );
|
||||
csync_set_module_property( csync_ctx, "proxy_user", proxy.user().toUtf8().data());
|
||||
csync_set_module_property( csync_ctx, "proxy_pwd", proxy.password().toUtf8().data());
|
||||
#else
|
||||
Q_UNUSED(url);
|
||||
Q_UNUSED(csync_ctx);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ClientProxy::lookupSystemProxyAsync(const QUrl &url, QObject *dst, const char *slot)
|
||||
{
|
||||
SystemProxyRunnable *runnable = new SystemProxyRunnable(url);
|
||||
QObject::connect(runnable, SIGNAL(systemProxyLookedUp(QNetworkProxy)), dst, slot);
|
||||
QThreadPool::globalInstance()->start(runnable); // takes ownership and deletes
|
||||
}
|
||||
|
||||
SystemProxyRunnable::SystemProxyRunnable(const QUrl &url) : QObject(), QRunnable(), _url(url)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SystemProxyRunnable::run()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Starting system proxy lookup";
|
||||
QList<QNetworkProxy> proxies = QNetworkProxyFactory::systemProxyForQuery(QNetworkProxyQuery(_url));
|
||||
|
||||
if (proxies.isEmpty()) {
|
||||
emit systemProxyLookedUp(QNetworkProxy(QNetworkProxy::NoProxy));
|
||||
} else {
|
||||
emit systemProxyLookedUp(proxies.first());
|
||||
// FIXME Would we really ever return more?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QNetworkProxy>
|
||||
#include <QRunnable>
|
||||
#include <QUrl>
|
||||
|
||||
#include <csync.h>
|
||||
#include "utility.h"
|
||||
@@ -30,17 +32,31 @@ class OWNCLOUDSYNC_EXPORT ClientProxy : public QObject
|
||||
public:
|
||||
explicit ClientProxy(QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
static bool isUsingSystemDefault();
|
||||
static void lookupSystemProxyAsync(const QUrl &url, QObject *dst, const char *slot);
|
||||
|
||||
public slots:
|
||||
void setCSyncProxy( const QUrl& url, CSYNC *csync_ctx );
|
||||
void setupQtProxyFromConfig();
|
||||
|
||||
private:
|
||||
QNetworkProxy proxyFromConfig(const ConfigFile& cfg);
|
||||
const char* proxyTypeToCStr(QNetworkProxy::ProxyType type);
|
||||
};
|
||||
|
||||
class SystemProxyRunnable : public QObject, public QRunnable {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SystemProxyRunnable(const QUrl &url);
|
||||
void run();
|
||||
signals:
|
||||
void systemProxyLookedUp(const QNetworkProxy &url);
|
||||
private:
|
||||
QUrl _url;
|
||||
};
|
||||
|
||||
QString printQNetworkProxy(const QNetworkProxy &proxy);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // CLIENTPROXY_H
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
namespace OCC {
|
||||
|
||||
static const char caCertsKeyC[] = "CaCertificates";
|
||||
//static const char caCertsKeyC[] = "CaCertificates"; only used from account.cpp
|
||||
static const char remotePollIntervalC[] = "remotePollInterval";
|
||||
static const char forceSyncIntervalC[] = "forceSyncInterval";
|
||||
static const char monoIconsC[] = "monoIcons";
|
||||
@@ -85,10 +85,10 @@ ConfigFile::ConfigFile()
|
||||
// qDebug() << Q_FUNC_INFO << "Loading config: " << config << " (URL is " << settings.value("url").toString() << ")";
|
||||
}
|
||||
|
||||
void ConfigFile::setConfDir(const QString &value)
|
||||
bool ConfigFile::setConfDir(const QString &value)
|
||||
{
|
||||
QString dirPath = value;
|
||||
if( dirPath.isEmpty() ) return;
|
||||
if( dirPath.isEmpty() ) return false;
|
||||
|
||||
QFileInfo fi(dirPath);
|
||||
if ( !fi.exists() && !fi.isAbsolute() ) {
|
||||
@@ -101,7 +101,9 @@ void ConfigFile::setConfDir(const QString &value)
|
||||
dirPath = fi.absoluteFilePath();
|
||||
qDebug() << "** Using custom config dir " << dirPath;
|
||||
_confDir=dirPath;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ConfigFile::optionalDesktopNotifications() const
|
||||
@@ -145,7 +147,7 @@ void ConfigFile::saveGeometryHeader(QHeaderView *header)
|
||||
{
|
||||
#ifndef TOKEN_AUTH_ONLY
|
||||
if(!header) return;
|
||||
Q_ASSERT(!header->objectName().isNull());
|
||||
Q_ASSERT(!header->objectName().isEmpty());
|
||||
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
settings.beginGroup(header->objectName());
|
||||
@@ -162,7 +164,7 @@ void ConfigFile::restoreGeometryHeader(QHeaderView *header)
|
||||
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
settings.beginGroup(header->objectName());
|
||||
header->restoreState(getValue(geometryC, header->objectName()).toByteArray());
|
||||
header->restoreState(settings.value(geometryC).toByteArray());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -315,20 +317,6 @@ bool ConfigFile::dataExists(const QString& group, const QString& key) const
|
||||
return settings.contains(key);
|
||||
}
|
||||
|
||||
QByteArray ConfigFile::caCerts( )
|
||||
{
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
return settings.value( QLatin1String(caCertsKeyC) ).toByteArray();
|
||||
}
|
||||
|
||||
void ConfigFile::setCaCerts( const QByteArray & certs )
|
||||
{
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
|
||||
settings.setValue( QLatin1String(caCertsKeyC), certs );
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
int ConfigFile::remotePollInterval( const QString& connection ) const
|
||||
{
|
||||
QString con( connection );
|
||||
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
void setUploadLimit(int kbytes);
|
||||
void setDownloadLimit(int kbytes);
|
||||
|
||||
static void setConfDir(const QString &value);
|
||||
static bool setConfDir(const QString &value);
|
||||
|
||||
bool optionalDesktopNotifications() const;
|
||||
void setOptionalDesktopNotifications(bool show);
|
||||
|
||||
@@ -13,11 +13,13 @@
|
||||
|
||||
#include <QtCore>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkProxyFactory>
|
||||
|
||||
#include "connectionvalidator.h"
|
||||
#include "theme.h"
|
||||
#include "account.h"
|
||||
#include "networkjobs.h"
|
||||
#include "clientproxy.h"
|
||||
#include <creds/abstractcredentials.h>
|
||||
|
||||
namespace OCC {
|
||||
@@ -61,8 +63,38 @@ void ConnectionValidator::checkServerAndAuth()
|
||||
reportResult( NotConfigured );
|
||||
return;
|
||||
}
|
||||
qDebug() << "Checking server and authentication";
|
||||
|
||||
_isCheckingServerAndAuth = true;
|
||||
|
||||
// Lookup system proxy in a thread https://github.com/owncloud/client/issues/2993
|
||||
if (ClientProxy::isUsingSystemDefault()) {
|
||||
qDebug() << "Trying to look up system proxy";
|
||||
ClientProxy::lookupSystemProxyAsync(_account->url(),
|
||||
this, SLOT(systemProxyLookupDone(QNetworkProxy)));
|
||||
} else {
|
||||
// We want to reset the QNAM proxy so that the global proxy settings are used (via ClientProxy settings)
|
||||
_account->networkAccessManager()->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
|
||||
// use a queued invocation so we're as asynchronous as with the other code path
|
||||
QMetaObject::invokeMethod(this, "slotCheckServerAndAuth", Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionValidator::systemProxyLookupDone(const QNetworkProxy &proxy) {
|
||||
if (!_account) {
|
||||
qDebug() << "Bailing out, Account had been deleted";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Setting QNAM proxy to be system proxy" << printQNetworkProxy(proxy);
|
||||
_account->networkAccessManager()->setProxy(proxy);
|
||||
|
||||
slotCheckServerAndAuth();
|
||||
}
|
||||
|
||||
// The actual check
|
||||
void ConnectionValidator::slotCheckServerAndAuth()
|
||||
{
|
||||
CheckServerJob *checkJob = new CheckServerJob(_account, this);
|
||||
checkJob->setIgnoreCredentialFailure(true);
|
||||
connect(checkJob, SIGNAL(instanceFound(QUrl,QVariantMap)), SLOT(slotStatusFound(QUrl,QVariantMap)));
|
||||
@@ -98,14 +130,22 @@ void ConnectionValidator::slotStatusFound(const QUrl&url, const QVariantMap &inf
|
||||
// Fetch them now! Once fetched, a new connectivity check will be
|
||||
// initiated anyway.
|
||||
creds->fetch();
|
||||
|
||||
// no result is reported
|
||||
deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
// status.php could not be loaded (network or server issue!).
|
||||
void ConnectionValidator::slotNoStatusFound(QNetworkReply *reply)
|
||||
{
|
||||
_errors.append(tr("Unable to connect to %1").arg(_account->url().toString()));
|
||||
_errors.append( reply->errorString() );
|
||||
qDebug() << Q_FUNC_INFO << reply->error() << reply->errorString();
|
||||
if( reply && ! _account->credentials()->stillValid(reply)) {
|
||||
_errors.append(tr("Authentication error: Either username or password are wrong."));
|
||||
} else {
|
||||
_errors.append(tr("Unable to connect to %1").arg(_account->url().toString()));
|
||||
_errors.append( reply->errorString() );
|
||||
}
|
||||
reportResult( StatusNotFound );
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user