<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12813] CalendarServer/trunk/txdav</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/12813">12813</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-03-05 07:22:47 -0800 (Wed, 05 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make sure pre-existing inbox items are always set to transparent. Change code to always coerce inbox to transparent.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktxdavcaldavdatastoresqlpy">CalendarServer/trunk/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoretesttest_sqlpy">CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoreupgradesqlupgradescalendar_upgrade_from_5_to_6py">CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_5_to_6.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoreupgradesqlupgradestesttest_upgrade_from_5_to_6py">CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_5_to_6.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktxdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py (12812 => 12813)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-03-05 05:43:16 UTC (rev 12812)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-03-05 15:22:47 UTC (rev 12813)
</span><span class="lines">@@ -1258,25 +1258,27 @@
</span><span class="cx"> 
</span><span class="cx">     def isUsedForFreeBusy(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        Indicates whether the contents of this calendar contributes to free busy.
</del><ins>+        Indicates whether the contents of this calendar contributes to free busy. Always coerce
+        inbox to be transparent.
</ins><span class="cx"> 
</span><span class="cx">         @return: C{True} if it does, C{False} otherwise
</span><span class="cx">         @rtype: C{bool}
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        return self._transp == _TRANSP_OPAQUE
</del><ins>+        return (self._transp == _TRANSP_OPAQUE) and not self.isInbox()
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def setUsedForFreeBusy(self, use_it):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Mark this calendar as being used for free busy request. Note this is a per-user setting so we are setting
</span><del>-        this on the bind table entry which is related to the user viewing the calendar.
</del><ins>+        this on the bind table entry which is related to the user viewing the calendar. Always coerce inbox to be
+        transparent.
</ins><span class="cx"> 
</span><span class="cx">         @param use_it: C{True} if used for free busy, C{False} otherwise
</span><span class="cx">         @type use_it: C{bool}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        self._transp = _TRANSP_OPAQUE if use_it else _TRANSP_TRANSPARENT
</del><ins>+        self._transp = _TRANSP_OPAQUE if use_it and not self.isInbox() else _TRANSP_TRANSPARENT
</ins><span class="cx">         cal = self._bindSchema
</span><span class="cx">         yield Update(
</span><span class="cx">             {cal.TRANSP : self._transp},
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoretesttest_sqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py (12812 => 12813)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py        2014-03-05 05:43:16 UTC (rev 12812)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py        2014-03-05 15:22:47 UTC (rev 12813)
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx"> from txdav.common.datastore.sql import ECALENDARTYPE, CommonObjectResource, \
</span><span class="cx">     CommonStoreTransactionMonitor
</span><span class="cx"> from txdav.common.datastore.sql_tables import schema, _BIND_MODE_DIRECT, \
</span><del>-    _BIND_STATUS_ACCEPTED
</del><ins>+    _BIND_STATUS_ACCEPTED, _TRANSP_OPAQUE
</ins><span class="cx"> from txdav.common.datastore.test.util import populateCalendarsFrom, \
</span><span class="cx">     CommonCommonTests
</span><span class="cx"> from txdav.common.icommondatastore import NoSuchObjectResourceError
</span><span class="lines">@@ -1930,7 +1930,37 @@
</span><span class="cx">         self.assertTrue(token is not None)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    @inlineCallbacks
+    def test_inboxTransp(self):
+        &quot;&quot;&quot;
+        Make sure inbox is always transparent no matter what is stored in the DB.
+        &quot;&quot;&quot;
</ins><span class="cx"> 
</span><ins>+        home = yield self.homeUnderTest(name=&quot;user01&quot;, create=True)
+        self.assertNotEqual(home, None)
+        inbox = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;inbox&quot;)
+        self.assertFalse(inbox.isUsedForFreeBusy())
+        yield inbox.setUsedForFreeBusy(True)
+        self.assertFalse(inbox.isUsedForFreeBusy())
+        yield self.commit()
+
+        inbox = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;inbox&quot;)
+        self.assertFalse(inbox.isUsedForFreeBusy())
+
+        cb = schema.CALENDAR_BIND
+        yield Update(
+            {cb.TRANSP: _TRANSP_OPAQUE},
+            Where=(cb.CALENDAR_RESOURCE_NAME == &quot;inbox&quot;).And(
+                cb.CALENDAR_RESOURCE_ID == inbox.id()
+            )
+        ).on(self.transactionUnderTest())
+        yield self.commit()
+
+        inbox = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;inbox&quot;)
+        self.assertFalse(inbox.isUsedForFreeBusy())
+
+
+
</ins><span class="cx"> class SchedulingTests(CommonCommonTests, unittest.TestCase):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     CalendarObject splitting tests
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoreupgradesqlupgradescalendar_upgrade_from_5_to_6py"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_5_to_6.py (12812 => 12813)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_5_to_6.py        2014-03-05 05:43:16 UTC (rev 12812)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_5_to_6.py        2014-03-05 15:22:47 UTC (rev 12813)
</span><span class="lines">@@ -19,7 +19,8 @@
</span><span class="cx"> 
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks
</span><span class="cx"> 
</span><del>-from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
</del><ins>+from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN, \
+    _TRANSP_TRANSPARENT
</ins><span class="cx"> from txdav.common.datastore.upgrade.sql.upgrades.util import updateCalendarDataVersion, \
</span><span class="cx">     updateAllCalendarHomeDataVersions
</span><span class="cx"> 
</span><span class="lines">@@ -37,6 +38,8 @@
</span><span class="cx"> 
</span><span class="cx">     sqlTxn = sqlStore.newTransaction()
</span><span class="cx">     cb = schema.CALENDAR_BIND
</span><ins>+
+    # Fix shared calendar alarms which should default to &quot;empty&quot;
</ins><span class="cx">     yield Update(
</span><span class="cx">         {
</span><span class="cx">             cb.ALARM_VEVENT_TIMED: &quot;empty&quot;,
</span><span class="lines">@@ -46,6 +49,14 @@
</span><span class="cx">         },
</span><span class="cx">         Where=(cb.BIND_MODE != _BIND_MODE_OWN)
</span><span class="cx">     ).on(sqlTxn)
</span><ins>+
+    # Fix inbox transparency which should always be True
+    yield Update(
+        {
+            cb.TRANSP: _TRANSP_TRANSPARENT,
+        },
+        Where=(cb.CALENDAR_RESOURCE_NAME == &quot;inbox&quot;)
+    ).on(sqlTxn)
</ins><span class="cx">     yield sqlTxn.commit()
</span><span class="cx"> 
</span><span class="cx">     # Always bump the DB value
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoreupgradesqlupgradestesttest_upgrade_from_5_to_6py"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_5_to_6.py (12812 => 12813)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_5_to_6.py        2014-03-05 05:43:16 UTC (rev 12812)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_5_to_6.py        2014-03-05 15:22:47 UTC (rev 12813)
</span><span class="lines">@@ -20,10 +20,11 @@
</span><span class="cx"> 
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="cx"> 
</span><del>-from twext.enterprise.dal.syntax import Update
</del><ins>+from twext.enterprise.dal.syntax import Update, Select
</ins><span class="cx"> 
</span><span class="cx"> from txdav.caldav.datastore.test.util import CommonStoreTests
</span><del>-from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE, _BIND_MODE_READ
</del><ins>+from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE, _BIND_MODE_READ,\
+    _TRANSP_OPAQUE, schema
</ins><span class="cx"> from txdav.common.datastore.upgrade.sql.upgrades.calendar_upgrade_from_5_to_6 import doUpgrade
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -63,6 +64,14 @@
</span><span class="cx">         for vevent, timed, alarm in detailscalendar:
</span><span class="cx">             yield calendar.setDefaultAlarm(alarm, vevent, timed)
</span><span class="cx"> 
</span><ins>+        cb = schema.CALENDAR_BIND
+        yield Update(
+            {
+                cb.TRANSP: _TRANSP_OPAQUE,
+            },
+            Where=(cb.CALENDAR_RESOURCE_NAME == &quot;inbox&quot;)
+        ).on(self.transactionUnderTest())
+
</ins><span class="cx">         home2 = yield self.homeUnderTest(name=&quot;user02&quot;)
</span><span class="cx">         shared_name2 = yield calendar.shareWith(home2, _BIND_MODE_WRITE)
</span><span class="cx">         shared = yield self.calendarUnderTest(name=shared_name2, home=&quot;user02&quot;)
</span><span class="lines">@@ -98,7 +107,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def _upgrade_check(self, detailshome, detailscalendar, detailsshared, shared_name2, shared_name3):
</del><ins>+    def _upgrade_alarms_check(self, detailshome, detailscalendar, detailsshared, shared_name2, shared_name3):
</ins><span class="cx"> 
</span><span class="cx">         # Check each type of collection
</span><span class="cx">         home = yield self.homeUnderTest(name=&quot;user01&quot;)
</span><span class="lines">@@ -134,7 +143,32 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><ins>+    def _upgrade_inbox_check(self, detailshome, detailscalendar, detailsshared, shared_name2, shared_name3):
+
+        calendar = yield self.calendarUnderTest(name=&quot;calendar_1&quot;, home=&quot;user01&quot;)
+        self.assertTrue(calendar.isUsedForFreeBusy())
+        inbox = yield self.calendarUnderTest(name=&quot;inbox&quot;, home=&quot;user01&quot;)
+        self.assertFalse(inbox.isUsedForFreeBusy())
+
+        cb = schema.CALENDAR_BIND
+        rows = yield Select(
+            [cb.TRANSP],
+            From=cb,
+            Where=(cb.CALENDAR_RESOURCE_NAME == &quot;inbox&quot;)
+        ).on(self.transactionUnderTest())
+        self.assertTrue(len(rows) != 0)
+        self.assertTrue(all([row[0] for row in rows]))
+
+
+    @inlineCallbacks
</ins><span class="cx">     def test_defaultAlarmUpgrade(self):
</span><span class="cx">         detailshome, detailscalendar, detailsshared, shared_name2, shared_name3 = (yield self._upgrade_setup())
</span><span class="cx">         yield doUpgrade(self._sqlCalendarStore)
</span><del>-        yield self._upgrade_check(detailshome, detailscalendar, detailsshared, shared_name2, shared_name3)
</del><ins>+        yield self._upgrade_alarms_check(detailshome, detailscalendar, detailsshared, shared_name2, shared_name3)
+
+
+    @inlineCallbacks
+    def test_inboxTranspUpgrade(self):
+        detailshome, detailscalendar, detailsshared, shared_name2, shared_name3 = (yield self._upgrade_setup())
+        yield doUpgrade(self._sqlCalendarStore)
+        yield self._upgrade_inbox_check(detailshome, detailscalendar, detailsshared, shared_name2, shared_name3)
</ins></span></pre>
</div>
</div>

</body>
</html>