chunks+peek: stop using deprecated {get,set}FinalBlockId

Change-Id: I64ae1c33a6f83af34b3db3d5f48cee3f3e7b7cb1
Refs: #4526
diff --git a/tools/chunks/catchunks/pipeline-interests-aimd.cpp b/tools/chunks/catchunks/pipeline-interests-aimd.cpp
index cdf502d..eac9dfd 100644
--- a/tools/chunks/catchunks/pipeline-interests-aimd.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-aimd.cpp
@@ -215,8 +215,8 @@
   // Data name will not have extra components because MaxSuffixComponents is set to 1
   BOOST_ASSERT(data.getName().equals(interest.getName()));
 
-  if (!m_hasFinalBlockId && !data.getFinalBlockId().empty()) {
-    m_lastSegmentNo = data.getFinalBlockId().toSegment();
+  if (!m_hasFinalBlockId && data.getFinalBlock()) {
+    m_lastSegmentNo = data.getFinalBlock()->toSegment();
     m_hasFinalBlockId = true;
     cancelInFlightSegmentsGreaterThan(m_lastSegmentNo);
     if (m_hasFailure && m_lastSegmentNo >= m_failedSegNo) {
diff --git a/tools/chunks/catchunks/pipeline-interests-fixed-window.cpp b/tools/chunks/catchunks/pipeline-interests-fixed-window.cpp
index 69f9dc9..53178ee 100644
--- a/tools/chunks/catchunks/pipeline-interests-fixed-window.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-fixed-window.cpp
@@ -121,8 +121,8 @@
 
   onData(data);
 
-  if (!m_hasFinalBlockId && !data.getFinalBlockId().empty()) {
-    m_lastSegmentNo = data.getFinalBlockId().toSegment();
+  if (!m_hasFinalBlockId && data.getFinalBlock()) {
+    m_lastSegmentNo = data.getFinalBlock()->toSegment();
     m_hasFinalBlockId = true;
 
     for (auto& fetcher : m_segmentFetchers) {
diff --git a/tools/chunks/catchunks/pipeline-interests.cpp b/tools/chunks/catchunks/pipeline-interests.cpp
index e520bfe..68e0157 100644
--- a/tools/chunks/catchunks/pipeline-interests.cpp
+++ b/tools/chunks/catchunks/pipeline-interests.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2016-2017, Regents of the University of California,
+ * Copyright (c) 2016-2018, Regents of the University of California,
  *                          Colorado State University,
  *                          University Pierre & Marie Curie, Sorbonne University.
  *
@@ -56,8 +56,8 @@
   m_prefix = data.getName().getPrefix(-1);
   m_excludedSegmentNo = getSegmentFromPacket(data);
 
-  if (!data.getFinalBlockId().empty()) {
-    m_lastSegmentNo = data.getFinalBlockId().toSegment();
+  if (data.getFinalBlock()) {
+    m_lastSegmentNo = data.getFinalBlock()->toSegment();
     m_hasFinalBlockId = true;
   }
 
diff --git a/tools/chunks/putchunks/producer.cpp b/tools/chunks/putchunks/producer.cpp
index 3fb14c7..4483558 100644
--- a/tools/chunks/putchunks/producer.cpp
+++ b/tools/chunks/putchunks/producer.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2016-2017, Regents of the University of California,
+ * Copyright (c) 2016-2018, Regents of the University of California,
  *                          Colorado State University,
  *                          University Pierre & Marie Curie, Sorbonne University.
  *
@@ -129,7 +129,7 @@
 
   auto finalBlockId = name::Component::fromSegment(m_store.size() - 1);
   for (const auto& data : m_store) {
-    data->setFinalBlockId(finalBlockId);
+    data->setFinalBlock(finalBlockId);
     m_keyChain.sign(*data, m_options.signingInfo);
   }
 
diff --git a/tools/peek/ndn-poke.cpp b/tools/peek/ndn-poke.cpp
index adfe93e..ceb49b3 100644
--- a/tools/peek/ndn-poke.cpp
+++ b/tools/peek/ndn-poke.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -21,29 +21,6 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * ndn-tools, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- */
-/**
- * Copyright (c) 2014,  Regents of the University of California,
- *                      Arizona Board of Regents,
- *                      Colorado State University,
- *                      University Pierre & Marie Curie, Sorbonne University,
- *                      Washington University in St. Louis,
- *                      Beijing Institute of Technology,
- *                      The University of Memphis
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @author Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
  */
@@ -59,11 +36,11 @@
 {
 public:
   explicit
-  NdnPoke(char* programName)
+  NdnPoke(const char* programName)
     : m_programName(programName)
-    , m_isForceDataSet(false)
-    , m_isUseDigestSha256Set(false)
-    , m_isLastAsFinalBlockIdSet(false)
+    , m_wantForceData(false)
+    , m_wantDigestSha256(false)
+    , m_wantFinalBlockId(false)
     , m_freshnessPeriod(-1)
     , m_timeout(-1)
     , m_isDataSent(false)
@@ -93,17 +70,17 @@
   void
   setForceData()
   {
-    m_isForceDataSet = true;
+    m_wantForceData = true;
   }
 
   void
   setUseDigestSha256()
   {
-    m_isUseDigestSha256Set = true;
+    m_wantDigestSha256 = true;
   }
 
   void
-  setIdentityName(char* identityName)
+  setIdentityName(const char* identityName)
   {
     m_identityName = make_shared<Name>(identityName);
   }
@@ -111,7 +88,7 @@
   void
   setLastAsFinalBlockId()
   {
-    m_isLastAsFinalBlockIdSet = true;
+    m_wantFinalBlockId = true;
   }
 
   void
@@ -133,7 +110,7 @@
   }
 
   void
-  setPrefixName(char* prefixName)
+  setPrefixName(const char* prefixName)
   {
     m_prefixName = Name(prefixName);
   }
@@ -157,16 +134,16 @@
     if (m_freshnessPeriod >= time::milliseconds::zero())
       dataPacket->setFreshnessPeriod(m_freshnessPeriod);
 
-    if (m_isLastAsFinalBlockIdSet) {
+    if (m_wantFinalBlockId) {
       if (!m_prefixName.empty())
-        dataPacket->setFinalBlockId(m_prefixName.get(-1));
+        dataPacket->setFinalBlock(m_prefixName.get(-1));
       else {
         std::cerr << "Name Provided Has 0 Components" << std::endl;
         exit(1);
       }
     }
 
-    if (m_isUseDigestSha256Set) {
+    if (m_wantDigestSha256) {
       m_keyChain.sign(*dataPacket, signingWithSha256());
     }
     else {
@@ -182,11 +159,9 @@
   }
 
   void
-  onInterest(const Name& name,
-             const Interest& interest,
-             shared_ptr<Data> dataPacket)
+  onInterest(const Name& name, const Interest& interest, const shared_ptr<Data>& data)
   {
-    m_face.put(*dataPacket);
+    m_face.put(*data);
     m_isDataSent = true;
     m_face.shutdown();
   }
@@ -203,7 +178,7 @@
   {
     try {
       shared_ptr<Data> dataPacket = createDataPacket();
-      if (m_isForceDataSet) {
+      if (m_wantForceData) {
         m_face.put(*dataPacket);
         m_isDataSent = true;
       }
@@ -234,10 +209,10 @@
 private:
   KeyChain m_keyChain;
   std::string m_programName;
-  bool m_isForceDataSet;
-  bool m_isUseDigestSha256Set;
+  bool m_wantForceData;
+  bool m_wantDigestSha256;
   shared_ptr<Name> m_identityName;
-  bool m_isLastAsFinalBlockIdSet;
+  bool m_wantFinalBlockId;
   time::milliseconds m_freshnessPeriod;
   time::milliseconds m_timeout;
   Name m_prefixName;
@@ -248,8 +223,9 @@
 int
 main(int argc, char* argv[])
 {
-  int option;
   NdnPoke program(argv[0]);
+
+  int option;
   while ((option = getopt(argc, argv, "hfDi:Fx:w:V")) != -1) {
     switch (option) {
     case 'h':
@@ -285,7 +261,7 @@
   argc -= optind;
   argv += optind;
 
-  if (argv[0] == 0)
+  if (!argv[0])
     program.usage();
 
   program.setPrefixName(argv[0]);
@@ -301,7 +277,7 @@
 } // namespace ndn
 
 int
-main(int argc, char** argv)
+main(int argc, char* argv[])
 {
   return ndn::peek::main(argc, argv);
 }