Skip to content

Commit 75c3887

Browse files
author
Koen Deforche
committed
a batch of small improvements and bug fixes
1 parent a7f27d8 commit 75c3887

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+836
-361
lines changed

Changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
10-07-2013:
2+
* WSignal: Due to boost 1.54 complaining on boost.signals being
3+
deprecated, namespace Wt::Signals was created. This namespace contains
4+
the boost signals implementation that is optimal for your boost: for
5+
boost < 1.54 it will be signals, for boost > 1.54 it will be signals2.
6+
17
15-05-2013:
28
* WStandardItem, WStandardItemModel: before: checkboxes are rendered
39
in enabled state when ItemIsUserCheckable flag is set. Now: checkboxes

WConfig.h.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,10 @@
3939
#cmakedefine WT_NO_STD_WSTRING
4040
#cmakedefine WT_DEBUG_ENABLED
4141

42+
// Only one of the two below should be selected
43+
#cmakedefine WT_USE_BOOST_SIGNALS
44+
#cmakedefine WT_USE_BOOST_SIGNALS2
45+
#define WT_USE_BOOST_SIGNALS
46+
4247
#endif
4348

cmake/WtFindHaru.txt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ IF(WIN32)
2929
PATHS
3030
${HARU_PREFIX}/lib
3131
)
32+
SET(HARU_LIB ${HARU_LIB_RELEASE})
33+
IF(HARU_LIB_RELEASE AND HARU_LIB_DEBUG)
34+
SET(HARU_LIB optimized ${HARU_LIB_RELEASE} debug ${HARU_LIB_DEBUG})
35+
ENDIF(HARU_LIB_RELEASE AND HARU_LIB_DEBUG)
36+
3237
FIND_LIBRARY(PNG_LIB_RELEASE
3338
NAMES
3439
libpng
@@ -41,24 +46,24 @@ IF(WIN32)
4146
PATHS
4247
${HARU_PREFIX}/lib
4348
)
49+
SET(PNG_LIB ${PNG_LIB_RELEASE})
50+
IF(PNG_LIB_RELEASE AND PNG_LIB_DEBUG)
51+
SET(PNG_LIB optimized ${PNG_LIB_RELEASE} debug ${PNG_LIB_DEBUG})
52+
ENDIF(PNG_LIB_RELEASE AND PNG_LIB_DEBUG)
53+
4454
FIND_LIBRARY(Z_LIB
4555
NAMES
4656
zlib
57+
libz
4758
PATHS
4859
${HARU_PREFIX}/lib
4960
${USERLIB_PREFIX}/lib
5061
)
51-
IF(HARU_LIB_RELEASE AND HARU_LIB_DEBUG)
52-
SET(HARU_LIB optimized ${HARU_LIB_RELEASE} debug ${HARU_LIB_DEBUG})
53-
SET(HARU_SUPPORT_LIBS "")
54-
IF(PNG_LIB_RELEASE AND PNG_LIB_DEBUG)
55-
SET(HARU_SUPPORT_LIBS ${HARU_SUPPORT_LIBS} optimized ${PNG_LIB_RELEASE} debug ${PNG_LIB_DEBUG})
56-
ENDIF(PNG_LIB_RELEASE AND PNG_LIB_DEBUG)
57-
IF(Z_LIB)
58-
SET(HARU_SUPPORT_LIBS ${HARU_SUPPORT_LIBS} ${Z_LIB})
59-
ENDIF(Z_LIB)
60-
ENDIF(HARU_LIB_RELEASE AND HARU_LIB_DEBUG)
61-
SET(HARU_SUPPORT_LIBS_FOUND TRUE)
62+
SET(HARU_SUPPORT_LIBS_FOUND FALSE)
63+
IF (PNG_LIB AND Z_LIB)
64+
SET(HARU_SUPPORT_LIBS_FOUND TRUE)
65+
SET(HARU_SUPPORT_LIBS ${PNG_LIB} ${Z_LIB})
66+
ENDIF (PNG_LIB AND Z_LIB)
6267
ELSE(WIN32)
6368
FIND_LIBRARY(HARU_LIB
6469
NAMES

cmake/WtFindMysql.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ FIND_PATH(MYSQL_INCLUDE mysql.h
1717
/usr/local/include/mysql
1818
)
1919

20-
SET(MYSQL_LIBRARY "mariadb;mariadbclient" CACHE STRING "Library that provides MySQL/MariaDB API (set to mysqlclient for mysql on unix; libmysql on windows)")
20+
SET(MYSQL_LIBRARY mariadb mariadbclient mysqlclient libmysql CACHE STRING "Library that provides MySQL/MariaDB API (set to mysqlclient for mysql on unix; libmysql on windows)")
2121

2222
FIND_LIBRARY(MYSQL_LIB
2323
NAMES

examples/dragdrop/DragExample.C

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ WImage *createDragImage(const char *url, const char *smallurl,
2222
{
2323
WImage *result = new WImage(url, p);
2424
WImage *dragImage = new WImage(smallurl, p);
25+
dragImage->setMargin(-15, Left | Top);
2526

2627
/*
2728
* Set the image to be draggable, showing the other image (dragImage)

examples/widgetgallery/examples/SpinBox.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
SAMPLE_BEGIN(SpinBox)
66
Wt::WContainerWidget *container = new Wt::WContainerWidget();
7+
container->addStyleClass("control-group");
78

89
new Wt::WText("Enter a number between 0 and 100:", container);
910

@@ -16,9 +17,13 @@ sb->setMargin(10, Wt::Left | Wt::Right);
1617

1718
Wt::WText *out = new Wt::WText("", container);
1819

19-
sb->valueChanged().connect(std::bind([=] (double d) {
20-
out->setText(Wt::WString::fromUTF8("Spin box value changed to {1}.")
21-
.arg(d));
22-
}, std::placeholders::_1));
20+
sb->changed().connect(std::bind([=] () {
21+
if (sb->validate() == Wt::WValidator::Valid) {
22+
out->setText(Wt::WString::fromUTF8("Spin box value changed to {1}")
23+
.arg(sb->text()));
24+
} else {
25+
out->setText(Wt::WString::fromUTF8("Invalid spin box value!"));
26+
}
27+
}));
2328

2429
SAMPLE_END(return container)

src/Wt/Auth/AbstractUserDatabase

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ public:
119119
virtual User findWithIdentity(const std::string& provider,
120120
const WT_USTRING& identity) const = 0;
121121

122-
/*! \brief Sets an identifier for the user.
122+
/*! \brief Adds an identify for the user.
123123
*
124-
* This associates an identifier with the user.
124+
* This adds an identity to the user.
125125
*
126126
* You are free to support only one identity per user, e.g. if you
127127
* only use password-based authentication. But you may also want to
@@ -132,6 +132,13 @@ public:
132132
virtual void addIdentity(const User& user, const std::string& provider,
133133
const WT_USTRING& id) = 0;
134134

135+
/*! \brief Changes an identity for a user.
136+
*
137+
* The base implementation calls removeIdentity() followed by addIdentity().
138+
*/
139+
virtual void setIdentity(const User& user, const std::string& provider,
140+
const WT_USTRING& id);
141+
135142
/*! \brief Returns a user identity.
136143
*
137144
* Returns a user identity for the given provider, or an empty string
@@ -142,6 +149,12 @@ public:
142149
virtual WT_USTRING identity(const User& user, const std::string& provider)
143150
const = 0;
144151

152+
/*! \brief Removes a user identity.
153+
*
154+
* This removes all identities of a \p provider from the \p user.
155+
*
156+
* \sa addIdentity()
157+
*/
145158
virtual void removeIdentity(const User& user, const std::string& provider)
146159
= 0;
147160
//@}

src/Wt/Auth/AbstractUserDatabase.C

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ void AbstractUserDatabase::setPassword(const User& user,
6868
LOG_ERROR(Require("setPassword()", PASSWORDS).what());
6969
}
7070

71+
void AbstractUserDatabase::setIdentity(const User& user,
72+
const std::string& provider,
73+
const WT_USTRING& id)
74+
{
75+
removeIdentity(user, provider);
76+
addIdentity(user, provider, id);
77+
}
78+
7179
User AbstractUserDatabase::registerNew()
7280
{
7381
LOG_ERROR(Require("registerNew()", REGISTRATION).what());

src/Wt/Auth/Dbo/UserDatabase

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ public:
162162
.where("provider = ?").bind(provider).resultList().size() != 0) {
163163
Wt::log("error") << "cannot add identity " << provider
164164
<< ":'" << identity << "': already exists";
165+
return;
165166
}
166167

167168
/*
@@ -172,6 +173,23 @@ public:
172173
identity)));
173174
}
174175

176+
virtual void setIdentity(const User& user, const std::string& provider,
177+
const WT_USTRING& identity) {
178+
WithUser find(*this, user);
179+
180+
AuthIdentities c
181+
= user_->authIdentities().find().where("provider = ?").bind(provider);
182+
183+
typename AuthIdentities::const_iterator i = c.begin();
184+
185+
if (i != c.end())
186+
i->modify()->setIdentity(identity);
187+
else
188+
user_.modify()->authIdentities().insert
189+
(Wt::Dbo::ptr<AuthIdentityType>(new AuthIdentityType(provider,
190+
identity)));
191+
}
192+
175193
virtual bool setEmail(const User& user, const std::string& address) {
176194
WithUser find(*this, user);
177195

src/Wt/Auth/User

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,36 @@ public:
106106
*/
107107
const std::string& id() const { return id_; }
108108

109-
/*! \brief Returns the user's identity.
109+
/*! \brief Returns an identity.
110110
*/
111111
WT_USTRING identity(const std::string& provider) const;
112112

113-
/*! \brief Adds (or modifies) a user's identity.
113+
/*! \brief Adds an identity.
114+
*
115+
* Depending on whether the database supports multiple identities
116+
* per provider, this may change (like setIdentity()), or add
117+
* another identity to the user. For some identity providers (e.g. a
118+
* 3rd party identity provider), it may be sensible to have more
119+
* than one identity of the same provider for a single user
120+
* (e.g. multiple email accounts managed by the same provider, that
121+
* in fact identify the same user).
114122
*/
115123
void addIdentity(const std::string& provider, const WT_USTRING& identity);
116124

125+
/*! \brief Sets an identity.
126+
*
127+
* Unlike addIdentity() this overrides any other identity of the
128+
* given provider, in case the underlying database supports multiple
129+
* identities per user.
130+
*/
131+
void setIdentity(const std::string& provider, const WT_USTRING& identity);
132+
133+
/*! \brief Removes an identity.
134+
*
135+
* \sa addIdentity()
136+
*/
137+
void removeIdentity(const std::string& provider);
138+
117139
/*! \brief Sets a password.
118140
*
119141
* \sa AbstractUserDatabase::setPassword()

0 commit comments

Comments
 (0)